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

Function ipproto_register

freebsd/netinet/ip_input.c:872–901  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

870 * in inetsw[], either statically or through pf_proto_register().
871 */
872int
873ipproto_register(short ipproto)
874{
875 struct protosw *pr;
876
877 /* Sanity checks. */
878 if (ipproto <= 0 || ipproto >= IPPROTO_MAX)
879 return (EPROTONOSUPPORT);
880
881 /*
882 * The protocol slot must not be occupied by another protocol
883 * already. An index pointing to IPPROTO_RAW is unused.
884 */
885 pr = pffindproto(PF_INET, IPPROTO_RAW, SOCK_RAW);
886 if (pr == NULL)
887 return (EPFNOSUPPORT);
888 if (ip_protox[ipproto] != pr - inetsw) /* IPPROTO_RAW */
889 return (EEXIST);
890
891 /* Find the protocol position in inetsw[] and set the index. */
892 for (pr = inetdomain.dom_protosw;
893 pr < inetdomain.dom_protoswNPROTOSW; pr++) {
894 if (pr->pr_domain->dom_family == PF_INET &&
895 pr->pr_protocol && pr->pr_protocol == ipproto) {
896 ip_protox[pr->pr_protocol] = pr - inetsw;
897 return (0);
898 }
899 }
900 return (EPROTONOSUPPORT);
901}
902
903int
904ipproto_unregister(short ipproto)

Callers 3

pfsync_initFunction · 0.85
carp_mod_loadFunction · 0.85
sctp_module_loadFunction · 0.85

Calls 1

pffindprotoFunction · 0.85

Tested by

no test coverage detected