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

Function nat64lsn_print_states

tools/ipfw/nat64lsn.c:89–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87};
88
89static uint64_t
90nat64lsn_print_states(void *buf)
91{
92 char s[INET6_ADDRSTRLEN], a[INET_ADDRSTRLEN], f[INET_ADDRSTRLEN];
93 const char *proto;
94 char sflags[4], *sf;
95 ipfw_obj_header *oh;
96 ipfw_obj_data *od;
97 ipfw_nat64lsn_stg_v1 *stg;
98 ipfw_nat64lsn_state_v1 *ste;
99 uint64_t next_idx;
100 uint32_t i;
101 int sz;
102
103 oh = (ipfw_obj_header *)buf;
104 od = (ipfw_obj_data *)(oh + 1);
105 stg = (ipfw_nat64lsn_stg_v1 *)(od + 1);
106 sz = od->head.length - sizeof(*od);
107 next_idx = 0;
108 proto = NULL;
109 while (sz > 0 && next_idx != 0xFF) {
110 next_idx = stg->next.index;
111 sz -= sizeof(*stg);
112 if (stg->count == 0) {
113 stg++;
114 continue;
115 }
116 /*
117 * NOTE: addresses are in network byte order,
118 * ports are in host byte order.
119 */
120 inet_ntop(AF_INET, &stg->alias4, a, sizeof(a));
121 ste = (ipfw_nat64lsn_state_v1 *)(stg + 1);
122 for (i = 0; i < stg->count && sz > 0; i++) {
123 sf = sflags;
124 inet_ntop(AF_INET6, &ste->host6, s, sizeof(s));
125 inet_ntop(AF_INET, &ste->daddr, f, sizeof(f));
126 switch (ste->proto) {
127 case IPPROTO_TCP:
128 proto = "TCP";
129 if (ste->flags & 0x02)
130 *sf++ = 'S';
131 if (ste->flags & 0x04)
132 *sf++ = 'E';
133 if (ste->flags & 0x01)
134 *sf++ = 'F';
135 break;
136 case IPPROTO_UDP:
137 proto = "UDP";
138 break;
139 case IPPROTO_ICMP:
140 proto = "ICMPv6";
141 break;
142 }
143 *sf = '\0';
144 switch (ste->proto) {
145 case IPPROTO_TCP:
146 case IPPROTO_UDP:

Callers 1

nat64lsn_states_cbFunction · 0.85

Calls 2

inet_ntopFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected