|
| 1 | +"============================================================================ |
| 2 | +" ferm syntax highlighter |
| 3 | +" |
| 4 | +" Language: ferm; "For Easy Rule Making", a frontend for iptables |
| 5 | +" Ferm Info: http://ferm.foo-projects.org/ |
| 6 | +" Version: 0.03 |
| 7 | +" Date: 2013-01-09 |
| 8 | +" Maintainer: Benjamin Leopold <benjamin-at-cometsong-dot-net> |
| 9 | +" URL: http://github.com/cometsong/ferm.vim |
| 10 | +" Credits: Modeled after Eric Haarbauer's iptables syntax file. |
| 11 | +" |
| 12 | +"============================================================================ |
| 13 | +" Section: Initialization {{{1 |
| 14 | +"============================================================================ |
| 15 | + |
| 16 | +" For version 5.x: Clear all syntax items |
| 17 | +" For version 6.x: Quit when a syntax file was already loaded |
| 18 | +if !exists("main_syntax") |
| 19 | + if version < 600 |
| 20 | + syntax clear |
| 21 | + elseif exists("b:current_syntax") |
| 22 | + finish |
| 23 | + endif |
| 24 | + let main_syntax = 'ferm' |
| 25 | +endif |
| 26 | + |
| 27 | +" Don't use standard HiLink, it will not work with included syntax files |
| 28 | +if version < 508 |
| 29 | + command! -nargs=+ FermHiLink highlight link <args> |
| 30 | +else |
| 31 | + command! -nargs=+ FermHiLink highlight default link <args> |
| 32 | +endif |
| 33 | + |
| 34 | +syntax case match |
| 35 | + |
| 36 | +if version < 600 |
| 37 | + set iskeyword+=- |
| 38 | +else |
| 39 | + setlocal iskeyword+=- |
| 40 | +endif |
| 41 | + |
| 42 | +" Initialize global public variables: {{{2 |
| 43 | + |
| 44 | +" Support deprecated variable name used prior to release 1.07. |
| 45 | +if exists("g:fermSpecialDelimiters") && |
| 46 | +\ !exists("g:Ferm_SpecialDelimiters") |
| 47 | + |
| 48 | + let g:Ferm_SpecialDelimiters = g:fermSpecialDelimiters |
| 49 | + unlet g:fermSpecialDelimiters |
| 50 | + " echohl WarningMsg | echo "Warning:" | echohl None |
| 51 | + " echo "The g:fermSpecialDelimiters variable is deprecated." |
| 52 | + " echo "Please use g:Ferm_SpecialDelimiters in your .vimrc instead" |
| 53 | + |
| 54 | +endif |
| 55 | + |
| 56 | +if exists("g:Ferm_SpecialDelimiters") |
| 57 | + let s:Ferm_SpecialDelimiters = g:Ferm_SpecialDelimiters |
| 58 | +else |
| 59 | + let s:Ferm_SpecialDelimiters = 0 |
| 60 | +endif |
| 61 | + |
| 62 | +"============================================================================ |
| 63 | +" Section: Syntax Definitions {{{1 |
| 64 | +"============================================================================ |
| 65 | + |
| 66 | +syntax keyword fermLocation domain table chain policy @subchain |
| 67 | + |
| 68 | +syntax keyword fermMatch interface outerface protocol proto |
| 69 | + \ saddr daddr fragment sport dport syn module mod |
| 70 | + |
| 71 | +syntax keyword fermBuiltinChain |
| 72 | + \ INPUT OUTPUT FORWARD PREROUTING POSTROUTING |
| 73 | + |
| 74 | +syntax match fermInterface "[eth|ppp]\d" |
| 75 | + |
| 76 | +syntax keyword fermTable filter nat mangle raw |
| 77 | + |
| 78 | +" TODO: check the use of duplicate terms in two syntax defs; then enable (arp|eb) tables. |
| 79 | +"syntax keyword fermArpTables source-ip destination-ip source-mac destination-mac |
| 80 | + "\ interface outerface h-length opcode h-type proto-type |
| 81 | + "\ mangle-ip-s mangle-ip-d mangle-mac-s mangle-mac-d mangle-target |
| 82 | +"syntax keyword fermEbTables proto interface outerface logical-in logical-out saddr daddr |
| 83 | + "\ 802.3 arp ip mark_m pkttype stp vlan log |
| 84 | + |
| 85 | +syntax keyword fermTarget |
| 86 | + \ ACCEPT DROP QUEUE RETURN BALANCE CLASSIFY CLUSTERIP CONNMARK |
| 87 | + \ CONNSECMARK CONNTRACK DNAT DSCP ECN HL IPMARK IPV4OPSSTRIP LOG |
| 88 | + \ MARK MASQUERADE MIRROR NETMAP NFLOG NFQUEUE NOTRACK REDIRECT REJECT |
| 89 | + \ ROUTE SAME SECMARK SET SNAT TARPIT TCPMSS TOS TRACE TTL ULOG XOR |
| 90 | + |
| 91 | +syntax keyword fermModuleName contained |
| 92 | + \ account addrtype ah childlevel comment condition connbytes connlimit |
| 93 | + \ connmark connrate conntrack dccp dscp dstlimit ecn esp fuzzy hashlimit |
| 94 | + \ helper icmp iprange ipv4options length limit lo mac mark mport multiport |
| 95 | + \ nth osf owner physdev pkttype policy psd quota random realm recent |
| 96 | + \ sctp set state string tcp tcpmss time tos ttl u32 udp unclean |
| 97 | + |
| 98 | +syntax keyword fermModuleType |
| 99 | + \ UNSPEC UNICAST LOCAL BROADCAST ANYCAST MULTICAST BLACKHOLE UNREACHABLE |
| 100 | + \ PROHIBIT THROW NAT XRESOLVE INVALID ESTABLISHED NEW RELATED SYN ACK FIN |
| 101 | + \ RST URG PSH ALL NONE |
| 102 | + |
| 103 | +" From --reject-with option |
| 104 | +syntax keyword fermModuleType |
| 105 | + \ icmp-net-unreachable |
| 106 | + \ icmp-host-unreachable |
| 107 | + \ icmp-port-unreachable |
| 108 | + \ icmp-proto-unreachable |
| 109 | + \ icmp-net-prohibited |
| 110 | + \ icmp-host-prohibited |
| 111 | + \ icmp-admin-prohibited |
| 112 | + |
| 113 | +" From --icmp-type option |
| 114 | +syntax keyword fermModuleType |
| 115 | + \ any |
| 116 | + \ echo-reply |
| 117 | + \ destination-unreachable |
| 118 | + \ network-unreachable |
| 119 | + \ host-unreachable |
| 120 | + \ protocol-unreachable |
| 121 | + \ port-unreachable |
| 122 | + \ fragmentation-needed |
| 123 | + \ source-route-failed |
| 124 | + \ network-unknown |
| 125 | + \ host-unknown |
| 126 | + \ network-prohibited |
| 127 | + \ host-prohibited |
| 128 | + \ TOS-network-unreachable |
| 129 | + \ TOS-host-unreachable |
| 130 | + \ communication-prohibited |
| 131 | + \ host-precedence-violation |
| 132 | + \ precedence-cutoff |
| 133 | + \ source-quench |
| 134 | + \ redirect |
| 135 | + \ network-redirect |
| 136 | + \ host-redirect |
| 137 | + \ TOS-network-redirect |
| 138 | + \ TOS-host-redirect |
| 139 | + \ echo-request |
| 140 | + \ router-advertisement |
| 141 | + \ router-solicitation |
| 142 | + \ time-exceeded |
| 143 | + \ ttl-zero-during-transit |
| 144 | + \ ttl-zero-during-reassembly |
| 145 | + \ parameter-problem |
| 146 | + \ ip-header-bad |
| 147 | + \ required-option-missing |
| 148 | + \ timestamp-request |
| 149 | + \ timestamp-reply |
| 150 | + \ address-mask-request |
| 151 | + \ address-mask-reply |
| 152 | + |
| 153 | +" TODO: check ferm "$variable" & "&function" character matches |
| 154 | +syntax match fermVariable "$[_A-Za-z0-9]+" |
| 155 | +syntax keyword fermVarDefine @def |
| 156 | + |
| 157 | +syntax keyword fermFunction @if @else @elsif @include @hook |
| 158 | + \ @eq @ne @not @resolve @cat @substr @length |
| 159 | + \ @basename @dirname @ipfilter |
| 160 | + |
| 161 | +syntax keyword fermUserFunction "&[_A-Za-z0-9]+" |
| 162 | + |
| 163 | +syntax region fermString start=+"+ skip=+\\"+ end=+"+ |
| 164 | +syntax region fermString start=+'+ skip=+\\'+ end=+'+ |
| 165 | + |
| 166 | +syntax region fermCommand start=+`+ skip=+\\'+ end=+`+ |
| 167 | + |
| 168 | +syntax match fermComment "#.*" |
| 169 | + |
| 170 | +"============================================================================ |
| 171 | +" Section: Group Linking {{{1 |
| 172 | +"============================================================================ |
| 173 | + |
| 174 | +FermHiLink fermLocation Title |
| 175 | +FermHiLink fermMatch Special |
| 176 | +FermHiLink fermTable ErrorMsg |
| 177 | +FermHiLink fermBuiltinChain Underlined |
| 178 | +FermHiLink fermTarget Statement |
| 179 | +FermHiLink fermFunction Identifier |
| 180 | +FermHiLink fermUserFunction Function |
| 181 | +FermHiLink fermModuleName PreProc |
| 182 | +FermHiLink fermModuleType Type |
| 183 | +FermHiLink fermVarDefine PreProc |
| 184 | +FermHiLink fermVariable Operator |
| 185 | +FermHiLink fermString Constant |
| 186 | +FermHiLink fermCommand Identifier |
| 187 | +FermHiLink fermComment Comment |
| 188 | + |
| 189 | +"============================================================================ |
| 190 | +" Section: Clean Up {{{1 |
| 191 | +"============================================================================ |
| 192 | + |
| 193 | +delcommand FermHiLink |
| 194 | + |
| 195 | +let b:current_syntax = "ferm" |
| 196 | + |
| 197 | +if main_syntax == 'ferm' |
| 198 | + unlet main_syntax |
| 199 | +endif |
| 200 | + |
| 201 | +" Autoconfigure vim indentation settings |
| 202 | +" vim:ts=4:sw=4:sts=4:fdm=marker:iskeyword+=- |
| 203 | + |
0 commit comments