MCPcopy Create free account
hub / github.com/F-Stack/f-stack / show_dyn_state

Function show_dyn_state

tools/ipfw/ipfw2.c:2277–2357  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2275}
2276
2277static void
2278show_dyn_state(struct cmdline_opts *co, struct format_opts *fo,
2279 struct buf_pr *bp, ipfw_dyn_rule *d)
2280{
2281 struct protoent *pe;
2282 struct in_addr a;
2283 uint16_t rulenum;
2284 char buf[INET6_ADDRSTRLEN];
2285
2286 if (d->expire == 0 && d->dyn_type != O_LIMIT_PARENT)
2287 return;
2288
2289 bcopy(&d->rule, &rulenum, sizeof(rulenum));
2290 bprintf(bp, "%05d", rulenum);
2291 if (fo->pcwidth > 0 || fo->bcwidth > 0) {
2292 bprintf(bp, " ");
2293 pr_u64(bp, &d->pcnt, fo->pcwidth);
2294 pr_u64(bp, &d->bcnt, fo->bcwidth);
2295 bprintf(bp, "(%ds)", d->expire);
2296 }
2297 switch (d->dyn_type) {
2298 case O_LIMIT_PARENT:
2299 bprintf(bp, " PARENT %d", d->count);
2300 break;
2301 case O_LIMIT:
2302 bprintf(bp, " LIMIT");
2303 break;
2304 case O_KEEP_STATE: /* bidir, no mask */
2305 bprintf(bp, " STATE");
2306 break;
2307 }
2308
2309 if ((pe = getprotobynumber(d->id.proto)) != NULL)
2310 bprintf(bp, " %s", pe->p_name);
2311 else
2312 bprintf(bp, " proto %u", d->id.proto);
2313
2314 if (d->id.addr_type == 4) {
2315 a.s_addr = htonl(d->id.src_ip);
2316 bprintf(bp, " %s %d", inet_ntoa(a), d->id.src_port);
2317
2318 a.s_addr = htonl(d->id.dst_ip);
2319 bprintf(bp, " <-> %s %d", inet_ntoa(a), d->id.dst_port);
2320 } else if (d->id.addr_type == 6) {
2321 bprintf(bp, " %s %d", inet_ntop(AF_INET6_LINUX, &d->id.src_ip6, buf,
2322 sizeof(buf)), d->id.src_port);
2323 bprintf(bp, " <-> %s %d", inet_ntop(AF_INET6_LINUX, &d->id.dst_ip6,
2324 buf, sizeof(buf)), d->id.dst_port);
2325 } else
2326 bprintf(bp, " UNKNOWN <-> UNKNOWN");
2327 if (d->kidx != 0)
2328 bprintf(bp, " :%s", object_search_ctlv(fo->tstate,
2329 d->kidx, IPFW_TLV_STATE_NAME));
2330
2331#define BOTH_SYN (TH_SYN | (TH_SYN << 8))
2332#define BOTH_FIN (TH_FIN | (TH_FIN << 8))
2333 if (co->verbose) {
2334 bprintf(bp, " state 0x%08x%s", d->state,

Callers 1

list_dyn_stateFunction · 0.85

Calls 4

bprintfFunction · 0.85
pr_u64Function · 0.85
inet_ntopFunction · 0.85
object_search_ctlvFunction · 0.85

Tested by

no test coverage detected