Skip to content

Commit

Permalink
make encap_attach and encap_attach_func switchable, to help
Browse files Browse the repository at this point in the history
*BSD-current merge with different ip_encap.
  • Loading branch information
itojun committed Jul 29, 2001
1 parent 5d4db76 commit 0582f58
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
20 changes: 17 additions & 3 deletions kame/sys/netinet/in_gif.c
@@ -1,4 +1,4 @@
/* $KAME: in_gif.c,v 1.64 2001/07/25 02:55:58 itojun Exp $ */
/* $KAME: in_gif.c,v 1.65 2001/07/29 04:27:25 itojun Exp $ */

/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
Expand Down Expand Up @@ -42,6 +42,9 @@
#include "opt_iso.h"
#endif

/* define it if you want to use encap_attach_func (it helps *BSD merge) */
/*#define USE_ENCAPCHECK*/

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/socket.h>
Expand Down Expand Up @@ -366,12 +369,18 @@ in_gif_input(m, va_alist)

gifp = (struct ifnet *)encap_getarg(m);

if (gifp == NULL || (gifp->if_flags & IFF_UP) == 0 ||
!gif_validate4(ip, (struct gif_softc *)gifp, m->m_pkthdr.rcvif)) {
if (gifp == NULL || (gifp->if_flags & IFF_UP) == 0) {
m_freem(m);
ipstat.ips_nogif++;
return;
}
#ifndef USE_ENCAPCHECK
if (!gif_validate4(ip, (struct gif_softc *)gifp, m->m_pkthdr.rcvif)) {
m_freem(m);
ipstat.ips_nogif++;
return;
}
#endif

#ifdef __OpenBSD__
m->m_pkthdr.rcvif = gifp;
Expand Down Expand Up @@ -545,6 +554,7 @@ int
in_gif_attach(sc)
struct gif_softc *sc;
{
#ifndef USE_ENCAPCHECK
struct sockaddr_in mask4;

bzero(&mask4, sizeof(mask4));
Expand All @@ -556,6 +566,10 @@ in_gif_attach(sc)
sc->encap_cookie4 = encap_attach(AF_INET, -1, sc->gif_psrc,
(struct sockaddr *)&mask4, sc->gif_pdst, (struct sockaddr *)&mask4,
(struct protosw *)&in_gif_protosw, sc);
#else
sc->encap_cookie4 = encap_attach_func(AF_INET, -1, gif_encapcheck,
&in_gif_protosw, sc);
#endif
if (sc->encap_cookie4 == NULL)
return EEXIST;
return 0;
Expand Down
20 changes: 17 additions & 3 deletions kame/sys/netinet6/in6_gif.c
@@ -1,4 +1,4 @@
/* $KAME: in6_gif.c,v 1.61 2001/07/26 06:53:16 jinmei Exp $ */
/* $KAME: in6_gif.c,v 1.62 2001/07/29 04:27:25 itojun Exp $ */

/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
Expand Down Expand Up @@ -38,6 +38,9 @@
#include "opt_iso.h"
#endif

/* define it if you want to use encap_attach_func (it helps *BSD merge) */
/*#define USE_ENCAPCHECK*/

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/socket.h>
Expand Down Expand Up @@ -361,12 +364,18 @@ int in6_gif_input(mp, offp, proto)

gifp = (struct ifnet *)encap_getarg(m);

if (gifp == NULL || (gifp->if_flags & IFF_UP) == 0 ||
!gif_validate6(ip6, (struct gif_softc *)gifp, m->m_pkthdr.rcvif)) {
if (gifp == NULL || (gifp->if_flags & IFF_UP) == 0) {
m_freem(m);
ip6stat.ip6s_nogif++;
return IPPROTO_DONE;
}
#ifndef USE_ENCAPCHECK
if (!gif_validate6(ip6, (struct gif_softc *)gifp, m->m_pkthdr.rcvif)) {
m_freem(m);
ip6stat.ip6s_nogif++;
return IPPROTO_DONE;
}
#endif

#ifdef __OpenBSD__
m->m_pkthdr.rcvif = gifp;
Expand Down Expand Up @@ -514,6 +523,7 @@ int
in6_gif_attach(sc)
struct gif_softc *sc;
{
#ifndef USE_ENCAPCHECK
struct sockaddr_in6 mask6;

bzero(&mask6, sizeof(mask6));
Expand All @@ -526,6 +536,10 @@ in6_gif_attach(sc)
sc->encap_cookie6 = encap_attach(AF_INET6, -1, sc->gif_psrc,
(struct sockaddr *)&mask6, sc->gif_pdst, (struct sockaddr *)&mask6,
(struct protosw *)&in6_gif_protosw, sc);
#else
sc->encap_cookie6 = encap_attach(AF_INET6, -1, gif_encapcheck,
(struct protosw *)&in6_gif_protosw, sc);
#endif
if (sc->encap_cookie6 == NULL)
return EEXIST;
return 0;
Expand Down

0 comments on commit 0582f58

Please sign in to comment.