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

Function ip6proto_register

freebsd/netinet6/ip6_input.c:295–326  ·  view source on GitHub ↗

* The protocol to be inserted into ip6_protox[] must be already registered * in inet6sw[], either statically or through pf_proto_register(). */

Source from the content-addressed store, hash-verified

293 * in inet6sw[], either statically or through pf_proto_register().
294 */
295int
296ip6proto_register(short ip6proto)
297{
298 struct protosw *pr;
299
300 /* Sanity checks. */
301 if (ip6proto <= 0 || ip6proto >= IPPROTO_MAX)
302 return (EPROTONOSUPPORT);
303
304 /*
305 * The protocol slot must not be occupied by another protocol
306 * already. An index pointing to IPPROTO_RAW is unused.
307 */
308 pr = pffindproto(PF_INET6, IPPROTO_RAW, SOCK_RAW);
309 if (pr == NULL)
310 return (EPFNOSUPPORT);
311 if (ip6_protox[ip6proto] != pr - inet6sw) /* IPPROTO_RAW */
312 return (EEXIST);
313
314 /*
315 * Find the protocol position in inet6sw[] and set the index.
316 */
317 for (pr = inet6domain.dom_protosw;
318 pr < inet6domain.dom_protoswNPROTOSW; pr++) {
319 if (pr->pr_domain->dom_family == PF_INET6 &&
320 pr->pr_protocol && pr->pr_protocol == ip6proto) {
321 ip6_protox[pr->pr_protocol] = pr - inet6sw;
322 return (0);
323 }
324 }
325 return (EPROTONOSUPPORT);
326}
327
328int
329ip6proto_unregister(short ip6proto)

Callers 2

carp_mod_loadFunction · 0.85
sctp_module_loadFunction · 0.85

Calls 1

pffindprotoFunction · 0.85

Tested by

no test coverage detected