summaryrefslogtreecommitdiff
path: root/completions/ebtables
blob: de6bc54964f065599f3ffdf7f379f69aea76a818 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# bash completion for ebtables                             -*- shell-script -*-

_ebtables()
{
    local cur prev words cword split
    _init_completion -s || return

    local table chain='s/^Bridge chain: \([^ ,]\{1,\}\).*$/\1/p' \
        targets='ACCEPT DROP CONTINUE RETURN'

    [[ ${words[*]} =~ [[:space:]]-(t|-table=?)[[:space:]]*([^[:space:]]+) ]] &&
        table="-t ${BASH_REMATCH[2]}"

    case $prev in
        -!(-*)[AIDPFXLZ])
            COMPREPLY=($(compgen -W '`"$1" $table -L 2>/dev/null | \
                command sed -ne "$chain"`' -- "$cur"))
            ;;
        -!(-*)t)
            COMPREPLY=($(compgen -W 'nat filter broute' -- "$cur"))
            ;;
        -!(-*)j)
            if [[ $table == "-t filter" || -z $table ]]; then
                COMPREPLY=($(compgen -W '$targets
                $("$1" $table -L 2>/dev/null | \
                  command sed -n -e "s/INPUT\|OUTPUT\|FORWARD//" \
                                 -e "$chain")' \
                    -- "$cur"))
            elif [[ $table == "-t nat" ]]; then
                COMPREPLY=($(compgen -W '$targets
                $("$1" $table -L 2>/dev/null | \
                  command sed -n -e "s/OUTPUT|PREROUTING|POSTROUTING//" \
                                 -e "$chain")' \
                    -- "$cur"))
            elif [[ $table == "-t broute" ]]; then
                COMPREPLY=($(compgen -W 'ACCEPT DROP
                $("$1" $table -L 2>/dev/null | \
                  command sed -n -e "s/BROUTING//" -e "$chain")' \
                    -- "$cur"))
            fi
            ;;
        *)
            if [[ $cur == -* ]]; then
                COMPREPLY=($(compgen -W '--802_3-sap --802_3-type --among-dst
            --among-dst-file --among-src --among-src-file --append
            --arp-gratuitous --arp-htype --arp-ip-dst --arp-ip-src
            --arp-mac-dst --arp-mac-src --arp-opcode --arp-ptype --arpreply-mac
            --arpreply-target --atomic-commit --atomic-file --atomic-init
            --atomic-save --change-counters --concurrent --delete
            --delete-chain --destination --dnat-target --dst --flush --help
            --in-if --in-interface --init-table --insert --ip6-destination
            --ip6-destination-port --ip6-dport --ip6-dst --ip6-icmp-type
            --ip6-prococol --ip6-proto --ip6-protocol --ip6-source
            --ip6-source-port --ip6-sport --ip6-src --ip6-tclass
            --ip-destination --ip-destination-port --ip-dport --ip-dst
            --ip-proto --ip-protocol --ip-source --ip-source-port --ip-sport
            --ip-src --ip-tos --jump --Lc --limit --limit-burst --list --Lmac2
            --Ln --log --log-arp --logical-in --logical-out --log-ip --log-ip6
            --log-level --log-prefix --Lx --mark --mark-and --mark-or
            --mark-set --mark-target --mark-xor --modprobe --new-chain --nflog
            --nflog-group --nflog-prefix --nflog-range --nflog-threshold
            --out-if --out-interface --pkttype-type --policy --proto --protocol
            --redirect-target --rename-chain --set-counter --snat-arp
            --snat-target --source --src --stp-flags --stp-forward-delay
            --stp-hello-time --stp-max-age --stp-msg-age --stp-port
            --stp-root-addr --stp-root-cost --stp-root-prio --stp-sender-addr
            --stp-sender-prio --stp-type --table --to-destination --to-dst
            --to-source --to-src --ulog --ulog-cprange --ulog-nlgroup
            --ulog-prefix --ulog-qthreshold --version --vlan-encap --vlan-id
            --vlan-prio --zero' -- "$cur"))
            fi
            ;;
    esac

} &&
    complete -F _ebtables ebtables

# ex: filetype=sh