003 File Manager
Current Path:
/usr/src/contrib/ipfilter/lib
usr
/
src
/
contrib
/
ipfilter
/
lib
/
📁
..
📄
Makefile
(18.78 KB)
📄
addicmp.c
(446 B)
📄
addipopt.c
(1.14 KB)
📄
alist_free.c
(334 B)
📄
alist_new.c
(1.59 KB)
📄
allocmbt.c
(383 B)
📄
assigndefined.c
(452 B)
📄
bcopywrap.c
(274 B)
📄
binprint.c
(411 B)
📄
buildopts.c
(823 B)
📄
checkrev.c
(803 B)
📄
connecttcp.c
(911 B)
📄
count4bits.c
(621 B)
📄
count6bits.c
(376 B)
📄
debug.c
(556 B)
📄
dupmbt.c
(482 B)
📄
facpri.c
(2.62 KB)
📄
facpri.h
(629 B)
📄
familyname.c
(184 B)
📄
fill6bits.c
(744 B)
📄
findword.c
(413 B)
📄
flags.c
(414 B)
📄
freembt.c
(233 B)
📄
ftov.c
(204 B)
📄
gethost.c
(1.42 KB)
📄
geticmptype.c
(452 B)
📄
getifname.c
(957 B)
📄
getnattype.c
(1.15 KB)
📄
getport.c
(1.75 KB)
📄
getportproto.c
(621 B)
📄
getproto.c
(462 B)
📄
getsumd.c
(344 B)
📄
hostname.c
(1.2 KB)
📄
icmpcode.c
(493 B)
📄
icmptypename.c
(494 B)
📄
icmptypes.c
(3.34 KB)
📄
inet_addr.c
(6.1 KB)
📄
initparse.c
(300 B)
📄
interror.c
(26.29 KB)
📄
ionames.c
(1.57 KB)
📄
ipf_dotuning.c
(1.61 KB)
📄
ipf_perror.c
(698 B)
📄
ipft_hx.c
(3.13 KB)
📄
ipft_pc.c
(4.41 KB)
📄
ipft_tx.c
(10.09 KB)
📄
ipoptsec.c
(1.15 KB)
📄
kmem.c
(1.85 KB)
📄
kmem.h
(504 B)
📄
kmemcpywrap.c
(314 B)
📄
kvatoname.c
(672 B)
📄
load_dstlist.c
(1.65 KB)
📄
load_dstlistnode.c
(1.47 KB)
📄
load_file.c
(1.56 KB)
📄
load_hash.c
(2.29 KB)
📄
load_hashnode.c
(1.35 KB)
📄
load_http.c
(4.02 KB)
📄
load_pool.c
(1.59 KB)
📄
load_poolnode.c
(1.4 KB)
📄
load_url.c
(542 B)
📄
mb_hexdump.c
(541 B)
📄
msgdsize.c
(333 B)
📄
mutex_emul.c
(2.66 KB)
📄
nametokva.c
(645 B)
📄
nat_setgroupmap.c
(756 B)
📄
ntomask.c
(635 B)
📄
optname.c
(1.13 KB)
📄
optprint.c
(1.73 KB)
📄
optprintv6.c
(894 B)
📄
optvalue.c
(520 B)
📄
parsefields.c
(984 B)
📄
parseipfexpr.c
(6.19 KB)
📄
parsewhoisline.c
(2.72 KB)
📄
poolio.c
(704 B)
📄
portname.c
(902 B)
📄
prependmbt.c
(307 B)
📄
print_toif.c
(882 B)
📄
printactiveaddr.c
(643 B)
📄
printactivenat.c
(4.18 KB)
📄
printaddr.c
(1.16 KB)
📄
printaps.c
(3.53 KB)
📄
printbuf.c
(414 B)
📄
printdstl_live.c
(1.72 KB)
📄
printdstlist.c
(1.04 KB)
📄
printdstlistdata.c
(974 B)
📄
printdstlistnode.c
(1.73 KB)
📄
printdstlistpolicy.c
(454 B)
📄
printfieldhdr.c
(972 B)
📄
printfr.c
(10.73 KB)
📄
printfraginfo.c
(801 B)
📄
printhash.c
(1.04 KB)
📄
printhash_live.c
(1.4 KB)
📄
printhashdata.c
(1.93 KB)
📄
printhashnode.c
(2.32 KB)
📄
printhost.c
(553 B)
📄
printhostmap.c
(626 B)
📄
printhostmask.c
(612 B)
📄
printifname.c
(339 B)
📄
printip.c
(690 B)
📄
printipfexpr.c
(3.58 KB)
📄
printiphdr.c
(462 B)
📄
printlog.c
(650 B)
📄
printlookup.c
(700 B)
📄
printmask.c
(450 B)
📄
printnat.c
(8.69 KB)
📄
printnataddr.c
(992 B)
📄
printnatfield.c
(3.2 KB)
📄
printnatside.c
(2.51 KB)
📄
printpacket.c
(2.06 KB)
📄
printpacket6.c
(1.29 KB)
📄
printpool.c
(1.2 KB)
📄
printpool_live.c
(1.39 KB)
📄
printpooldata.c
(1.08 KB)
📄
printpoolfield.c
(3.42 KB)
📄
printpoolnode.c
(1.66 KB)
📄
printportcmp.c
(632 B)
📄
printproto.c
(750 B)
📄
printsbuf.c
(542 B)
📄
printstate.c
(5.74 KB)
📄
printstatefields.c
(5.24 KB)
📄
printtcpflags.c
(451 B)
📄
printtqtable.c
(430 B)
📄
printtunable.c
(649 B)
📄
printunit.c
(652 B)
📄
remove_hash.c
(1 KB)
📄
remove_hashnode.c
(1.11 KB)
📄
remove_pool.c
(947 B)
📄
remove_poolnode.c
(1.08 KB)
📄
resetlexer.c
(331 B)
📄
rwlock_emul.c
(3.47 KB)
📄
save_execute.c
(1.14 KB)
📄
save_file.c
(1.88 KB)
📄
save_nothing.c
(821 B)
📄
save_syslog.c
(2.2 KB)
📄
save_v1trap.c
(7.93 KB)
📄
save_v2trap.c
(7.98 KB)
📄
tcp_flags.c
(770 B)
📄
tcpflags.c
(594 B)
📄
tcpoptnames.c
(513 B)
📄
v6ionames.c
(636 B)
📄
v6optvalue.c
(577 B)
📄
var.c
(2.92 KB)
📄
verbose.c
(511 B)
📄
vtof.c
(204 B)
Editing: parseipfexpr.c
#include "ipf.h" #include <ctype.h> typedef struct ipfopentry { int ipoe_cmd; int ipoe_nbasearg; int ipoe_maxarg; int ipoe_argsize; char *ipoe_word; } ipfopentry_t; static ipfopentry_t opwords[17] = { { IPF_EXP_IP_ADDR, 2, 0, 1, "ip.addr" }, { IPF_EXP_IP6_ADDR, 2, 0, 4, "ip6.addr" }, { IPF_EXP_IP_PR, 1, 0, 1, "ip.p" }, { IPF_EXP_IP_SRCADDR, 2, 0, 1, "ip.src" }, { IPF_EXP_IP_DSTADDR, 2, 0, 1, "ip.dst" }, { IPF_EXP_IP6_SRCADDR, 2, 0, 4, "ip6.src" }, { IPF_EXP_IP6_DSTADDR, 2, 0, 4, "ip6.dst" }, { IPF_EXP_TCP_PORT, 1, 0, 1, "tcp.port" }, { IPF_EXP_TCP_DPORT, 1, 0, 1, "tcp.dport" }, { IPF_EXP_TCP_SPORT, 1, 0, 1, "tcp.sport" }, { IPF_EXP_TCP_FLAGS, 2, 0, 1, "tcp.flags" }, { IPF_EXP_UDP_PORT, 1, 0, 1, "udp.port" }, { IPF_EXP_UDP_DPORT, 1, 0, 1, "udp.dport" }, { IPF_EXP_UDP_SPORT, 1, 0, 1, "udp.sport" }, { IPF_EXP_TCP_STATE, 1, 0, 1, "tcp.state" }, { IPF_EXP_IDLE_GT, 1, 1, 1, "idle-gt" }, { -1, 0, 0, 0, NULL } }; int * parseipfexpr(line, errorptr) char *line; char **errorptr; { int not, items, asize, *oplist, osize, i; char *temp, *arg, *s, *t, *ops, *error; ipfopentry_t *e; ipfexp_t *ipfe; asize = 0; error = NULL; oplist = NULL; temp = strdup(line); if (temp == NULL) { error = "strdup failed"; goto parseerror; } /* * Eliminate any white spaces to make parsing easier. */ for (s = temp; *s != '\0'; ) { if (ISSPACE(*s)) strcpy(s, s + 1); else s++; } /* * Parse the string. * It should be sets of "ip.dst=1.2.3.4/32;" things. * There must be a "=" or "!=" and it must end in ";". */ if (temp[strlen(temp) - 1] != ';') { error = "last character not ';'"; goto parseerror; } /* * Work through the list of complete operands present. */ for (ops = strtok(temp, ";"); ops != NULL; ops = strtok(NULL, ";")) { arg = strchr(ops, '='); if ((arg < ops + 2) || (arg == NULL)) { error = "bad 'arg' vlaue"; goto parseerror; } if (*(arg - 1) == '!') { *(arg - 1) = '\0'; not = 1; } else { not = 0; } *arg++ = '\0'; for (e = opwords; e->ipoe_word; e++) { if (strcmp(ops, e->ipoe_word) == 0) break; } if (e->ipoe_word == NULL) { error = malloc(32); if (error != NULL) { sprintf(error, "keyword (%.10s) not found", ops); } goto parseerror; } /* * Count the number of commas so we know how big to * build the array */ for (s = arg, items = 1; *s != '\0'; s++) if (*s == ',') items++; if ((e->ipoe_maxarg != 0) && (items > e->ipoe_maxarg)) { error = "too many items"; goto parseerror; } /* * osize will mark the end of where we have filled up to * and is thus where we start putting new data. */ osize = asize; asize += 4 + (items * e->ipoe_nbasearg * e->ipoe_argsize); if (oplist == NULL) oplist = calloc(asize + 2, sizeof(int)); else oplist = reallocarray(oplist, asize + 2, sizeof(int)); if (oplist == NULL) { error = "oplist alloc failed"; goto parseerror; } ipfe = (ipfexp_t *)(oplist + osize); osize += 4; ipfe->ipfe_cmd = e->ipoe_cmd; ipfe->ipfe_not = not; ipfe->ipfe_narg = items * e->ipoe_nbasearg; ipfe->ipfe_size = items * e->ipoe_nbasearg * e->ipoe_argsize; ipfe->ipfe_size += 4; for (s = arg; (*s != '\0') && (osize < asize); s = t) { /* * Look for the end of this arg or the ',' to say * there is another following. */ for (t = s; (*t != '\0') && (*t != ','); t++) ; if (*t == ',') *t++ = '\0'; if (!strcasecmp(ops, "ip.addr") || !strcasecmp(ops, "ip.src") || !strcasecmp(ops, "ip.dst")) { i6addr_t mask, addr; char *delim; delim = strchr(s, '/'); if (delim != NULL) { *delim++ = '\0'; if (genmask(AF_INET, delim, &mask) == -1) { error = "genmask failed"; goto parseerror; } } else { mask.in4.s_addr = 0xffffffff; } if (gethost(AF_INET, s, &addr) == -1) { error = "gethost failed"; goto parseerror; } oplist[osize++] = addr.in4.s_addr; oplist[osize++] = mask.in4.s_addr; #ifdef USE_INET6 } else if (!strcasecmp(ops, "ip6.addr") || !strcasecmp(ops, "ip6.src") || !strcasecmp(ops, "ip6.dst")) { i6addr_t mask, addr; char *delim; delim = strchr(s, '/'); if (delim != NULL) { *delim++ = '\0'; if (genmask(AF_INET6, delim, &mask) == -1) { error = "genmask failed"; goto parseerror; } } else { mask.i6[0] = 0xffffffff; mask.i6[1] = 0xffffffff; mask.i6[2] = 0xffffffff; mask.i6[3] = 0xffffffff; } if (gethost(AF_INET6, s, &addr) == -1) { error = "gethost failed"; goto parseerror; } oplist[osize++] = addr.i6[0]; oplist[osize++] = addr.i6[1]; oplist[osize++] = addr.i6[2]; oplist[osize++] = addr.i6[3]; oplist[osize++] = mask.i6[0]; oplist[osize++] = mask.i6[1]; oplist[osize++] = mask.i6[2]; oplist[osize++] = mask.i6[3]; #endif } else if (!strcasecmp(ops, "ip.p")) { int p; p = getproto(s); if (p == -1) goto parseerror; oplist[osize++] = p; } else if (!strcasecmp(ops, "tcp.flags")) { u_32_t mask, flags; char *delim; delim = strchr(s, '/'); if (delim != NULL) { *delim++ = '\0'; mask = tcpflags(delim); } else { mask = 0xff; } flags = tcpflags(s); oplist[osize++] = flags; oplist[osize++] = mask; } else if (!strcasecmp(ops, "tcp.port") || !strcasecmp(ops, "tcp.sport") || !strcasecmp(ops, "tcp.dport") || !strcasecmp(ops, "udp.port") || !strcasecmp(ops, "udp.sport") || !strcasecmp(ops, "udp.dport")) { char proto[4]; u_short port; strncpy(proto, ops, 3); proto[3] = '\0'; if (getport(NULL, s, &port, proto) == -1) goto parseerror; oplist[osize++] = port; } else if (!strcasecmp(ops, "tcp.state")) { oplist[osize++] = atoi(s); } else { error = "unknown word"; goto parseerror; } } } free(temp); if (errorptr != NULL) *errorptr = NULL; for (i = asize; i > 0; i--) oplist[i] = oplist[i - 1]; oplist[0] = asize + 2; oplist[asize + 1] = IPF_EXP_END; return oplist; parseerror: if (errorptr != NULL) *errorptr = error; if (oplist != NULL) free(oplist); if (temp != NULL) free(temp); return NULL; }
Upload File
Create Folder