diff options
author | thompsa <thompsa@FreeBSD.org> | 2005-12-21 21:29:45 +0000 |
---|---|---|
committer | thompsa <thompsa@FreeBSD.org> | 2005-12-21 21:29:45 +0000 |
commit | 42c9ecf9f57f7681e401bcf499946dbe2f2cd09f (patch) | |
tree | fbd9c548f0727ef749bbae4f6181a65a63dbc539 /sys/netinet | |
parent | 09b665597401a6c52abc7955a365036782ba772a (diff) | |
download | FreeBSD-src-42c9ecf9f57f7681e401bcf499946dbe2f2cd09f.zip FreeBSD-src-42c9ecf9f57f7681e401bcf499946dbe2f2cd09f.tar.gz |
Add RFC 3378 EtherIP support. This change makes it possible to add gif
interfaces to bridges, which will then send and receive IP protocol 97 packets.
Packets are Ethernet frames with an EtherIP header prepended.
Obtained from: NetBSD
MFC after: 2 weeks
Diffstat (limited to 'sys/netinet')
-rw-r--r-- | sys/netinet/in_gif.c | 19 | ||||
-rw-r--r-- | sys/netinet/in_proto.c | 10 |
2 files changed, 29 insertions, 0 deletions
diff --git a/sys/netinet/in_gif.c b/sys/netinet/in_gif.c index 0eae228..cc6b64d 100644 --- a/sys/netinet/in_gif.c +++ b/sys/netinet/in_gif.c @@ -100,6 +100,7 @@ in_gif_output(ifp, family, m) struct sockaddr_in *sin_src = (struct sockaddr_in *)sc->gif_psrc; struct sockaddr_in *sin_dst = (struct sockaddr_in *)sc->gif_pdst; struct ip iphdr; /* capsule IP header, host byte ordered */ + struct etherip_header eiphdr; int proto, error; u_int8_t tos; @@ -142,6 +143,20 @@ in_gif_output(ifp, family, m) break; } #endif /* INET6 */ + case AF_LINK: + proto = IPPROTO_ETHERIP; + eiphdr.eip_ver = ETHERIP_VERSION & ETHERIP_VER_VERS_MASK; + eiphdr.eip_pad = 0; + /* prepend Ethernet-in-IP header */ + M_PREPEND(m, sizeof(struct etherip_header), M_DONTWAIT); + if (m && m->m_len < sizeof(struct etherip_header)) + m = m_pullup(m, sizeof(struct etherip_header)); + if (m == NULL) + return ENOBUFS; + bcopy(&eiphdr, mtod(m, struct etherip_header *), + sizeof(struct etherip_header)); + break; + default: #ifdef DEBUG printf("in_gif_output: warning: unknown family %d passed\n", @@ -302,6 +317,10 @@ in_gif_input(m, off) break; } #endif /* INET6 */ + case IPPROTO_ETHERIP: + af = AF_LINK; + break; + default: ipstat.ips_nogif++; m_freem(m); diff --git a/sys/netinet/in_proto.c b/sys/netinet/in_proto.c index fefb4bc..d8caddd 100644 --- a/sys/netinet/in_proto.c +++ b/sys/netinet/in_proto.c @@ -260,6 +260,16 @@ struct protosw inetsw[] = { { .pr_type = SOCK_RAW, .pr_domain = &inetdomain, + .pr_protocol = IPPROTO_ETHERIP, + .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, + .pr_input = encap4_input, + .pr_ctloutput = rip_ctloutput, + .pr_init = encap_init, + .pr_usrreqs = &rip_usrreqs +}, +{ + .pr_type = SOCK_RAW, + .pr_domain = &inetdomain, .pr_protocol = IPPROTO_GRE, .pr_flags = PR_ATOMIC|PR_ADDR|PR_LASTHDR, .pr_input = encap4_input, |