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

Function ng_ipfw_rcvdata

freebsd/netgraph/ng_ipfw.c:228–283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226}
227
228static int
229ng_ipfw_rcvdata(hook_p hook, item_p item)
230{
231 struct m_tag *tag;
232 struct ipfw_rule_ref *r;
233 struct mbuf *m;
234 struct ip *ip;
235
236 NGI_GET_M(item, m);
237 NG_FREE_ITEM(item);
238
239 tag = m_tag_locate(m, MTAG_IPFW_RULE, 0, NULL);
240 if (tag == NULL) {
241 NG_FREE_M(m);
242 return (EINVAL); /* XXX: find smth better */
243 }
244
245 if (m->m_len < sizeof(struct ip) &&
246 (m = m_pullup(m, sizeof(struct ip))) == NULL)
247 return (ENOBUFS);
248
249 ip = mtod(m, struct ip *);
250
251 r = (struct ipfw_rule_ref *)(tag + 1);
252 if (r->info & IPFW_INFO_IN) {
253 switch (ip->ip_v) {
254#ifdef INET
255 case IPVERSION:
256 ip_input(m);
257 return (0);
258#endif
259#ifdef INET6
260 case IPV6_VERSION >> 4:
261 ip6_input(m);
262 return (0);
263#endif
264 }
265 } else {
266 switch (ip->ip_v) {
267#ifdef INET
268 case IPVERSION:
269 return (ip_output(m, NULL, NULL, IP_FORWARDING,
270 NULL, NULL));
271#endif
272#ifdef INET6
273 case IPV6_VERSION >> 4:
274 return (ip6_output(m, NULL, NULL, 0, NULL,
275 NULL, NULL));
276#endif
277 }
278 }
279
280 /* unknown IP protocol version */
281 NG_FREE_M(m);
282 return (EPROTONOSUPPORT);
283}
284
285static int

Callers

nothing calls this directly

Calls 6

m_tag_locateFunction · 0.85
m_pullupFunction · 0.85
ip_inputFunction · 0.85
ip6_inputFunction · 0.85
ip_outputFunction · 0.85
ip6_outputFunction · 0.85

Tested by

no test coverage detected