Patches from Keiichi SHIMA <keiichi@iij.ad.jp>

to make ip use the standard protosw structure again.

Obtained from: Well, KAME I guess.
This commit is contained in:
Julian Elischer 2001-09-03 20:03:55 +00:00
parent 3fe149a643
commit f0ffb944d2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=82884
23 changed files with 70 additions and 75 deletions

View file

@ -62,7 +62,6 @@
#include <netinet/in_var.h>
#include <netinet/in_gif.h>
#include <netinet/ip_var.h>
#include <netinet/ipprotosw.h>
#endif /* INET */
#ifdef INET6
@ -101,7 +100,7 @@ static int gif_encapcheck __P((const struct mbuf *, int, int, void *));
#ifdef INET
extern struct domain inetdomain;
struct ipprotosw in_gif_protosw =
struct protosw in_gif_protosw =
{ SOCK_RAW, &inetdomain, 0/*IPPROTO_IPV[46]*/, PR_ATOMIC|PR_ADDR,
in_gif_input, rip_output, 0, rip_ctloutput,
0,

View file

@ -98,7 +98,6 @@
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ipprotosw.h>
#include <netinet/ip_var.h>
#include <netinet/in_var.h>
@ -134,7 +133,7 @@ static MALLOC_DEFINE(M_STF, "stf", "6to4 Tunnel Interface");
static int ip_stf_ttl = 40;
extern struct domain inetdomain;
struct ipprotosw in_stf_protosw =
struct protosw in_stf_protosw =
{ SOCK_RAW, &inetdomain, IPPROTO_IPV6, PR_ATOMIC|PR_ADDR,
in_stf_input, rip_output, 0, rip_ctloutput,
0,
@ -550,7 +549,7 @@ in_stf_input(m, va_alist)
va_start(ap, m);
off = va_arg(ap, int);
proto = va_arg(ap, int);
proto = mtod(m, struct ip *)->ip_p;
va_end(ap);
if (proto != IPPROTO_IPV6) {

View file

@ -148,9 +148,9 @@ find_rti(ifp)
}
void
igmp_input(m, off, proto)
igmp_input(m, off)
register struct mbuf *m;
int off, proto;
int off;
{
register int iphlen = off;
register struct igmp *igmp;

View file

@ -86,7 +86,7 @@ struct igmpstat {
#define IGMP_AGE_THRESHOLD 540
void igmp_init __P((void));
void igmp_input __P((struct mbuf *, int, int));
void igmp_input __P((struct mbuf *, int));
void igmp_joingroup __P((struct in_multi *));
void igmp_leavegroup __P((struct in_multi *));
void igmp_fasttimo __P((void));

View file

@ -202,17 +202,18 @@ in_gif_output(ifp, family, m, rt)
}
void
in_gif_input(m, off, proto)
in_gif_input(m, off)
struct mbuf *m;
int off;
int proto;
{
struct ifnet *gifp = NULL;
struct ip *ip;
int af;
u_int8_t otos;
int proto;
ip = mtod(m, struct ip *);
proto = ip->ip_p;
gifp = (struct ifnet *)encap_getarg(m);

View file

@ -37,7 +37,7 @@
extern int ip_gif_ttl;
void in_gif_input __P((struct mbuf *, int off, int proto));
void in_gif_input __P((struct mbuf *, int off));
int in_gif_output __P((struct ifnet *, int, struct mbuf *, struct rtentry *));
int gif_encapcheck4 __P((const struct mbuf *, int, int, void *));

View file

@ -63,8 +63,6 @@
#include <netinet/udp_var.h>
#include <netinet/ip_encap.h>
#include <netinet/ipprotosw.h>
/*
* TCP/IP protocol family: IP, ICMP, UDP, TCP.
*/
@ -90,7 +88,7 @@
extern struct domain inetdomain;
static struct pr_usrreqs nousrreqs;
struct ipprotosw inetsw[] = {
struct protosw inetsw[] = {
{ 0, &inetdomain, 0, 0,
0, 0, 0, 0,
0,
@ -207,8 +205,8 @@ extern int in_inithead __P((void **, int));
struct domain inetdomain =
{ AF_INET, "internet", 0, 0, 0,
(struct protosw *)inetsw,
(struct protosw *)&inetsw[sizeof(inetsw)/sizeof(inetsw[0])], 0,
inetsw,
&inetsw[sizeof(inetsw)/sizeof(inetsw[0])], 0,
in_inithead, 32, sizeof(struct sockaddr_in)
};

View file

@ -128,7 +128,7 @@ div_init(void)
* with that protocol number to enter the system from the outside.
*/
void
div_input(struct mbuf *m, int off, int proto)
div_input(struct mbuf *m, int off)
{
ipstat.ips_noproto++;
m_freem(m);

View file

@ -77,7 +77,6 @@
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/ip_encap.h>
#include <netinet/ipprotosw.h>
#ifdef INET6
#include <netinet/ip6.h>
@ -138,17 +137,17 @@ encap4_input(m, va_alist)
int off, proto;
struct ip *ip;
struct sockaddr_in s, d;
const struct ipprotosw *psw;
const struct protosw *psw;
struct encaptab *ep, *match;
va_list ap;
int prio, matchprio;
va_start(ap, m);
off = va_arg(ap, int);
proto = va_arg(ap, int);
va_end(ap);
ip = mtod(m, struct ip *);
proto = ip->ip_p;
bzero(&s, sizeof(s));
s.sin_family = AF_INET;
@ -205,17 +204,23 @@ encap4_input(m, va_alist)
if (match) {
/* found a match, "match" has the best one */
psw = (const struct ipprotosw *)match->psw;
psw = match->psw;
if (psw && psw->pr_input) {
encap_fillarg(m, match);
(*psw->pr_input)(m, off, proto);
(*psw->pr_input)(m, off);
} else
m_freem(m);
return;
}
/* for backward compatibility - messy... */
if (proto == IPPROTO_IPV4) {
ipip_input(m, off);
return;
}
/* last resort: inject to raw socket */
rip_input(m, off, proto);
rip_input(m, off);
}
#endif

View file

@ -230,9 +230,9 @@ static struct sockaddr_in icmpgw = { sizeof (struct sockaddr_in), AF_INET };
* Process a received ICMP message.
*/
void
icmp_input(m, off, proto)
icmp_input(m, off)
register struct mbuf *m;
int off, proto;
int off;
{
int hlen = off;
register struct icmp *icp;
@ -576,7 +576,7 @@ icmp_input(m, off, proto)
}
raw:
rip_input(m, off, proto);
rip_input(m, off);
return;
freeit:

View file

@ -186,7 +186,7 @@ struct icmp {
#ifdef _KERNEL
void icmp_error __P((struct mbuf *, int, int, n_long, struct ifnet *));
void icmp_input __P((struct mbuf *, int, int));
void icmp_input __P((struct mbuf *, int));
#endif
#endif

View file

@ -75,8 +75,6 @@
#include <netinet/ip_icmp.h>
#include <machine/in_cksum.h>
#include <netinet/ipprotosw.h>
#include <sys/socketvar.h>
#include <netinet/ip_fw.h>
@ -153,7 +151,7 @@ static int ipprintfs = 0;
#endif
extern struct domain inetdomain;
extern struct ipprotosw inetsw[];
extern struct protosw inetsw[];
u_char ip_protox[IPPROTO_MAX];
static int ipqmaxlen = IFQ_MAXLEN;
struct in_ifaddrhead in_ifaddrhead; /* first inet address */
@ -236,17 +234,17 @@ static void ipintr __P((void));
void
ip_init()
{
register struct ipprotosw *pr;
register struct protosw *pr;
register int i;
TAILQ_INIT(&in_ifaddrhead);
pr = (struct ipprotosw *)pffindproto(PF_INET, IPPROTO_RAW, SOCK_RAW);
pr = pffindproto(PF_INET, IPPROTO_RAW, SOCK_RAW);
if (pr == 0)
panic("ip_init");
for (i = 0; i < IPPROTO_MAX; i++)
ip_protox[i] = pr - inetsw;
for (pr = (struct ipprotosw *)inetdomain.dom_protosw;
pr < (struct ipprotosw *)inetdomain.dom_protoswNPROTOSW; pr++)
for (pr = inetdomain.dom_protosw;
pr < inetdomain.dom_protoswNPROTOSW; pr++)
if (pr->pr_domain->dom_family == PF_INET &&
pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW)
ip_protox[pr->pr_protocol] = pr - inetsw;
@ -819,9 +817,9 @@ ip_input(struct mbuf *m)
*/
ipstat.ips_delivered++;
{
int off = hlen, nh = ip->ip_p;
int off = hlen;
(*inetsw[ip_protox[ip->ip_p]].pr_input)(m, off, nh);
(*inetsw[ip_protox[ip->ip_p]].pr_input)(m, off);
#ifdef IPFIREWALL_FORWARD
ip_fw_fwd_addr = NULL; /* tcp needed it */
#endif

View file

@ -37,7 +37,6 @@
#include <netinet/igmp.h>
#include <netinet/ip_encap.h>
#include <netinet/ip_mroute.h>
#include <netinet/ipprotosw.h>
#include <netinet/udp.h>
#include <machine/in_cksum.h>
@ -108,10 +107,9 @@ _mrt_ioctl(int req, caddr_t data)
int (*mrt_ioctl)(int, caddr_t) = _mrt_ioctl;
void
rsvp_input(m, off, proto) /* XXX must fixup manually */
rsvp_input(m, off) /* XXX must fixup manually */
struct mbuf *m;
int off;
int proto;
{
/* Can still get packets with rsvp_on = 0 if there is a local member
* of the group to which the RSVP packet is addressed. But in this
@ -125,15 +123,15 @@ rsvp_input(m, off, proto) /* XXX must fixup manually */
if (ip_rsvpd != NULL) {
if (rsvpdebug)
printf("rsvp_input: Sending packet up old-style socket\n");
rip_input(m, off, proto);
rip_input(m, off);
return;
}
/* Drop the packet */
m_freem(m);
}
void ipip_input(struct mbuf *m, int off, int proto) { /* XXX must fixup manually */
rip_input(m, off, proto);
void ipip_input(struct mbuf *m, int off) { /* XXX must fixup manually */
rip_input(m, off);
}
int (*legal_vif_num)(int) = 0;
@ -708,7 +706,7 @@ mroute_encapcheck(const struct mbuf *m, int off, int proto, void *arg)
* claimed).
*/
static void
mroute_encap_input(struct mbuf *m, int off, int proto)
mroute_encap_input(struct mbuf *m, int off)
{
struct ip *ip = mtod(m, struct ip *);
int hlen = ip->ip_hl << 2;
@ -732,7 +730,7 @@ mroute_encap_input(struct mbuf *m, int off, int proto)
}
extern struct domain inetdomain;
static struct ipprotosw mroute_encap_protosw =
static struct protosw mroute_encap_protosw =
{ SOCK_RAW, &inetdomain, IPPROTO_IPV4, PR_ATOMIC|PR_ADDR,
mroute_encap_input, 0, 0, rip_ctloutput,
0,
@ -2108,10 +2106,9 @@ ip_rsvp_force_done(so)
}
void
rsvp_input(m, off, proto)
rsvp_input(m, off)
struct mbuf *m;
int off;
int proto;
{
int vifi;
register struct ip *ip = mtod(m, struct ip *);
@ -2156,7 +2153,7 @@ rsvp_input(m, off, proto)
if (ip_rsvpd != NULL) {
if (rsvpdebug)
printf("rsvp_input: Sending packet up old-style socket\n");
rip_input(m, off, proto); /* xxx */
rip_input(m, off); /* xxx */
} else {
if (rsvpdebug && vifi == numvifs)
printf("rsvp_input: Can't find vif for packet.\n");

View file

@ -177,10 +177,10 @@ u_int16_t
int rip_ctloutput __P((struct socket *, struct sockopt *));
void rip_ctlinput __P((int, struct sockaddr *, void *));
void rip_init __P((void));
void rip_input __P((struct mbuf *, int, int));
void rip_input __P((struct mbuf *, int));
int rip_output __P((struct mbuf *, struct socket *, u_long));
void ipip_input __P((struct mbuf *, int, int));
void rsvp_input __P((struct mbuf *, int, int));
void ipip_input __P((struct mbuf *, int));
void rsvp_input __P((struct mbuf *, int));
int ip_rsvp_init __P((struct socket *));
int ip_rsvp_done __P((void));
int ip_rsvp_vif_init __P((struct socket *, struct sockopt *));
@ -189,7 +189,7 @@ void ip_rsvp_force_done __P((struct socket *));
#ifdef IPDIVERT
void div_init __P((void));
void div_input __P((struct mbuf *, int, int));
void div_input __P((struct mbuf *, int));
void divert_packet __P((struct mbuf *, int, int));
extern struct pr_usrreqs div_usrreqs;
extern u_int16_t ip_divert_cookie;

View file

@ -112,14 +112,15 @@ static struct sockaddr_in ripsrc = { sizeof(ripsrc), AF_INET };
* mbuf chain.
*/
void
rip_input(m, off, proto)
rip_input(m, off)
struct mbuf *m;
int off, proto;
int off;
{
register struct ip *ip = mtod(m, struct ip *);
register struct inpcb *inp;
struct inpcb *last = 0;
struct mbuf *opts = 0;
int proto = ip->ip_p;
ripsrc.sin_addr = ip->ip_src;
LIST_FOREACH(inp, &ripcb, inp_list) {

View file

@ -322,15 +322,15 @@ tcp6_input(mp, offp, proto)
return IPPROTO_DONE;
}
tcp_input(m, *offp, proto);
tcp_input(m, *offp);
return IPPROTO_DONE;
}
#endif
void
tcp_input(m, off0, proto)
tcp_input(m, off0)
register struct mbuf *m;
int off0, proto;
int off0;
{
register struct tcphdr *th;
register struct ip *ip = NULL;

View file

@ -322,15 +322,15 @@ tcp6_input(mp, offp, proto)
return IPPROTO_DONE;
}
tcp_input(m, *offp, proto);
tcp_input(m, *offp);
return IPPROTO_DONE;
}
#endif
void
tcp_input(m, off0, proto)
tcp_input(m, off0)
register struct mbuf *m;
int off0, proto;
int off0;
{
register struct tcphdr *th;
register struct ip *ip = NULL;

View file

@ -384,7 +384,7 @@ void tcp_fasttimo __P((void));
struct rmxp_tao *
tcp_gettaocache __P((struct inpcb *));
void tcp_init __P((void));
void tcp_input __P((struct mbuf *, int, int));
void tcp_input __P((struct mbuf *, int));
void tcp_mss __P((struct tcpcb *, int));
int tcp_mssopt __P((struct tcpcb *));
void tcp_drop_syn_sent __P((struct inpcb *, int));

View file

@ -149,9 +149,9 @@ udp_init()
}
void
udp_input(m, off, proto)
udp_input(m, off)
register struct mbuf *m;
int off, proto;
int off;
{
int iphlen = off;
register struct ip *ip;

View file

@ -105,7 +105,7 @@ extern int log_in_vain;
void udp_ctlinput __P((int, struct sockaddr *, void *));
void udp_init __P((void));
void udp_input __P((struct mbuf *, int, int));
void udp_input __P((struct mbuf *, int));
void udp_notify __P((struct inpcb *inp, int errno));
int udp_shutdown __P((struct socket *so));

View file

@ -94,8 +94,7 @@
#define IPLEN_FLIPPED
#ifdef INET
#include <netinet/ipprotosw.h>
extern struct ipprotosw inetsw[];
extern struct protosw inetsw[];
void
#if __STDC__
@ -122,7 +121,7 @@ ah4_input(m, va_alist)
va_start(ap, m);
off = va_arg(ap, int);
proto = va_arg(ap, int);
proto = mtod(m, struct ip *)->ip_p;
va_end(ap);
#ifndef PULLDOWN_TEST
@ -550,7 +549,7 @@ ah4_input(m, va_alist)
ipsecstat.in_polvio++;
goto fail;
}
(*inetsw[ip_protox[nxt]].pr_input)(m, off, nxt);
(*inetsw[ip_protox[nxt]].pr_input)(m, off);
} else
m_freem(m);
m = NULL;

View file

@ -97,8 +97,7 @@
? sizeof(struct newesp) : sizeof(struct esp))
#ifdef INET
#include <netinet/ipprotosw.h>
extern struct ipprotosw inetsw[];
extern struct protosw inetsw[];
void
#if __STDC__
@ -125,7 +124,7 @@ esp4_input(m, va_alist)
va_start(ap, m);
off = va_arg(ap, int);
proto = va_arg(ap, int);
proto = mtod(m, struct ip *)->ip_p;
va_end(ap);
/* sanity check for alignment. */
@ -445,7 +444,7 @@ esp4_input(m, va_alist)
ipsecstat.in_polvio++;
goto bad;
}
(*inetsw[ip_protox[nxt]].pr_input)(m, off, nxt);
(*inetsw[ip_protox[nxt]].pr_input)(m, off);
} else
m_freem(m);
m = NULL;

View file

@ -83,8 +83,7 @@
#define IPLEN_FLIPPED
#ifdef INET
#include <netinet/ipprotosw.h>
extern struct ipprotosw inetsw[];
extern struct protosw inetsw[];
void
#if __STDC__
@ -110,7 +109,7 @@ ipcomp4_input(m, va_alist)
va_start(ap, m);
off = va_arg(ap, int);
proto = va_arg(ap, int);
proto = mtod(m, struct ip *)->ip_p;
va_end(ap);
if (m->m_pkthdr.len < off + sizeof(struct ipcomp)) {
@ -231,7 +230,7 @@ ipcomp4_input(m, va_alist)
ipsecstat.in_polvio++;
goto fail;
}
(*inetsw[ip_protox[nxt]].pr_input)(m, off, nxt);
(*inetsw[ip_protox[nxt]].pr_input)(m, off);
} else
m_freem(m);
m = NULL;