From 24b96f35b9113919602b8e0e6177ac4dfb848482 Mon Sep 17 00:00:00 2001 From: Gleb Smirnoff Date: Mon, 3 Oct 2022 20:53:04 -0700 Subject: [PATCH] netinet*: move ipproto_register() and co to ip_var.h and ip6_var.h This is a FreeBSD KPI and belongs to private header not netinet/in.h. Reviewed by: melifaro Differential revision: https://reviews.freebsd.org/D36723 --- sys/netinet/in.h | 17 ----------------- sys/netinet/ip_var.h | 10 ++++++++++ sys/netinet6/ip6_input.c | 7 ++++--- sys/netinet6/ip6_var.h | 10 ++++++++++ 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/sys/netinet/in.h b/sys/netinet/in.h index 43d26b9f7804..44d64190ed01 100644 --- a/sys/netinet/in.h +++ b/sys/netinet/in.h @@ -696,23 +696,6 @@ void in_ifdetach(struct ifnet *); #define satosin(sa) ((struct sockaddr_in *)(sa)) #define sintosa(sin) ((struct sockaddr *)(sin)) #define ifatoia(ifa) ((struct in_ifaddr *)(ifa)) - -typedef int ipproto_input_t(struct mbuf **, int *, int); -typedef void ipproto_ctlinput_t(int, struct sockaddr *, void *); -int ipproto_register(uint8_t, ipproto_input_t, ipproto_ctlinput_t); -int ipproto_unregister(uint8_t); -int ip6proto_register(uint8_t, ipproto_input_t, ipproto_ctlinput_t); -int ip6proto_unregister(uint8_t); -#define IPPROTO_REGISTER(prot, input, ctl) do { \ - int error __diagused; \ - error = ipproto_register(prot, input, ctl); \ - MPASS(error == 0); \ -} while (0) -#define IP6PROTO_REGISTER(prot, input, ctl) do { \ - int error __diagused; \ - error = ip6proto_register(prot, input, ctl); \ - MPASS(error == 0); \ -} while (0) #endif /* _KERNEL */ /* INET6 stuff */ diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h index d7bdb154741c..70afa5e1bce8 100644 --- a/sys/netinet/ip_var.h +++ b/sys/netinet/ip_var.h @@ -239,6 +239,16 @@ extern int (*ip_rsvp_vif)(struct socket *, struct sockopt *); extern void (*ip_rsvp_force_done)(struct socket *); extern int (*rsvp_input_p)(struct mbuf **, int *, int); +typedef int ipproto_input_t(struct mbuf **, int *, int); +typedef void ipproto_ctlinput_t(int, struct sockaddr *, void *); +int ipproto_register(uint8_t, ipproto_input_t, ipproto_ctlinput_t); +int ipproto_unregister(uint8_t); +#define IPPROTO_REGISTER(prot, input, ctl) do { \ + int error __diagused; \ + error = ipproto_register(prot, input, ctl); \ + MPASS(error == 0); \ +} while (0) + VNET_DECLARE(struct pfil_head *, inet_pfil_head); #define V_inet_pfil_head VNET(inet_pfil_head) #define PFIL_INET_NAME "inet" diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c index 2407050f6905..5c802beae2ee 100644 --- a/sys/netinet6/ip6_input.c +++ b/sys/netinet6/ip6_input.c @@ -131,9 +131,9 @@ __FBSDID("$FreeBSD$"); #include -ipproto_input_t *ip6_protox[IPPROTO_MAX] = { +ip6proto_input_t *ip6_protox[IPPROTO_MAX] = { [0 ... IPPROTO_MAX - 1] = rip6_input }; -ipproto_ctlinput_t *ip6_ctlprotox[IPPROTO_MAX] = { +ip6proto_ctlinput_t *ip6_ctlprotox[IPPROTO_MAX] = { [0 ... IPPROTO_MAX - 1] = rip6_ctlinput }; VNET_DEFINE(struct in6_ifaddrhead, in6_ifaddrhead); @@ -308,7 +308,8 @@ ip6_init(void *arg __unused) SYSINIT(ip6_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_THIRD, ip6_init, NULL); int -ip6proto_register(uint8_t proto, ipproto_input_t input, ipproto_ctlinput_t ctl) +ip6proto_register(uint8_t proto, ip6proto_input_t input, + ip6proto_ctlinput_t ctl) { MPASS(proto > 0); diff --git a/sys/netinet6/ip6_var.h b/sys/netinet6/ip6_var.h index c78cf52946fe..69ed33bd8e70 100644 --- a/sys/netinet6/ip6_var.h +++ b/sys/netinet6/ip6_var.h @@ -413,6 +413,16 @@ int in6_selectroute(struct sockaddr_in6 *, struct ip6_pktopts *, u_int32_t ip6_randomid(void); u_int32_t ip6_randomflowlabel(void); void in6_delayed_cksum(struct mbuf *m, uint32_t plen, u_short offset); + +typedef int ip6proto_input_t(struct mbuf **, int *, int); +typedef void ip6proto_ctlinput_t(int, struct sockaddr *, void *); +int ip6proto_register(uint8_t, ip6proto_input_t, ip6proto_ctlinput_t); +int ip6proto_unregister(uint8_t); +#define IP6PROTO_REGISTER(prot, input, ctl) do { \ + int error __diagused; \ + error = ip6proto_register(prot, input, ctl); \ + MPASS(error == 0); \ +} while (0) #endif /* _KERNEL */ #endif /* !_NETINET6_IP6_VAR_H_ */