Пример #1
0
static void
pfsync_print_upd_c(netdissect_options *ndo, const void *bp)
{
	const struct pfsync_upd_c *u = bp;

	ND_PRINT((ndo, "\n\tid: %016jx creatorid: %08x",
	    (uintmax_t)be64toh(u->id), ntohl(u->creatorid)));
	if (vflag > 2) {
		ND_PRINT((ndo, "\n\tTCP? :"));
		print_src_dst(ndo, &u->src, &u->dst, IPPROTO_TCP);
	}
}
Пример #2
0
static void
pfsync_print_upd_c(const void *bp)
{
	const struct pfsync_upd_c *u = bp;

	printf("\n\tid: %016jx creatorid: %08x", (uintmax_t )be64toh(u->id),
	    ntohl(u->creatorid));
	if (vflag > 2) {
		printf("\n\tTCP? :");
		print_src_dst(&u->src, &u->dst, IPPROTO_TCP);
	}
}
Пример #3
0
static void
print_state(netdissect_options *ndo, struct pfsync_state *s)
{
	struct pfsync_state_peer *src, *dst;
	struct pfsync_state_key *sk, *nk;
	int min, sec;

	if (s->direction == PF_OUT) {
		src = &s->src;
		dst = &s->dst;
		sk = &s->key[PF_SK_STACK];
		nk = &s->key[PF_SK_WIRE];
		if (s->proto == IPPROTO_ICMP || s->proto == IPPROTO_ICMPV6)
			sk->port[0] = nk->port[0];
	} else {
		src = &s->dst;
		dst = &s->src;
		sk = &s->key[PF_SK_WIRE];
		nk = &s->key[PF_SK_STACK];
		if (s->proto == IPPROTO_ICMP || s->proto == IPPROTO_ICMPV6)
			sk->port[1] = nk->port[1];
	}
	ND_PRINT((ndo, "\t%s ", s->ifname));
	ND_PRINT((ndo, "proto %u ", s->proto));

	print_host(ndo, &nk->addr[1], nk->port[1], s->af, NULL);
	if (PF_ANEQ(&nk->addr[1], &sk->addr[1], s->af) ||
	    nk->port[1] != sk->port[1]) {
		ND_PRINT((ndo, " ("));
		print_host(ndo, &sk->addr[1], sk->port[1], s->af, NULL);
		ND_PRINT((ndo, ")"));
	}
	if (s->direction == PF_OUT)
		ND_PRINT((ndo, " -> "));
	else
		ND_PRINT((ndo, " <- "));
	print_host(ndo, &nk->addr[0], nk->port[0], s->af, NULL);
	if (PF_ANEQ(&nk->addr[0], &sk->addr[0], s->af) ||
	    nk->port[0] != sk->port[0]) {
		ND_PRINT((ndo, " ("));
		print_host(ndo, &sk->addr[0], sk->port[0], s->af, NULL);
		ND_PRINT((ndo, ")"));
	}

	print_src_dst(ndo, src, dst, s->proto);

	if (vflag > 1) {
		uint64_t packets[2];
		uint64_t bytes[2];
		uint32_t creation = ntohl(s->creation);
		uint32_t expire = ntohl(s->expire);

		sec = creation % 60;
		creation /= 60;
		min = creation % 60;
		creation /= 60;
		ND_PRINT((ndo, "\n\tage %.2u:%.2u:%.2u", creation, min, sec));
		sec = expire % 60;
		expire /= 60;
		min = expire % 60;
		expire /= 60;
		ND_PRINT((ndo, ", expires in %.2u:%.2u:%.2u", expire, min, sec));

		bcopy(s->packets[0], &packets[0], sizeof(uint64_t));
		bcopy(s->packets[1], &packets[1], sizeof(uint64_t));
		bcopy(s->bytes[0], &bytes[0], sizeof(uint64_t));
		bcopy(s->bytes[1], &bytes[1], sizeof(uint64_t));
		ND_PRINT((ndo, ", %ju:%ju pkts, %ju:%ju bytes",
		    be64toh(packets[0]), be64toh(packets[1]),
		    be64toh(bytes[0]), be64toh(bytes[1])));
		if (s->anchor != ntohl(-1))
			ND_PRINT((ndo, ", anchor %u", ntohl(s->anchor)));
		if (s->rule != ntohl(-1))
			ND_PRINT((ndo, ", rule %u", ntohl(s->rule)));
	}
	if (vflag > 1) {
		uint64_t id;

		bcopy(&s->id, &id, sizeof(uint64_t));
		ND_PRINT((ndo, "\n\tid: %016jx creatorid: %08x",
		    (uintmax_t )be64toh(id), ntohl(s->creatorid)));
	}
}