diff options
author | Ralf Corsepius <ralf.corsepius@rtems.org> | 2005-04-15 06:29:42 +0000 |
---|---|---|
committer | Ralf Corsepius <ralf.corsepius@rtems.org> | 2005-04-15 06:29:42 +0000 |
commit | e953e2df062e513d7343643e051dec500a13e172 (patch) | |
tree | 2a9219e5f900efa3b3fdf183db273c2f492400f1 /cpukit/libnetworking/netinet | |
parent | 2005-04-14 Ralf Corsepius <ralf.corsepius@rtems.org> (diff) | |
download | rtems-e953e2df062e513d7343643e051dec500a13e172.tar.bz2 |
Partial updates from FreeBSD.
Diffstat (limited to 'cpukit/libnetworking/netinet')
-rw-r--r-- | cpukit/libnetworking/netinet/ip.h | 53 | ||||
-rw-r--r-- | cpukit/libnetworking/netinet/ip_icmp.c | 65 |
2 files changed, 84 insertions, 34 deletions
diff --git a/cpukit/libnetworking/netinet/ip.h b/cpukit/libnetworking/netinet/ip.h index e6be7d305d..4d6ad4c204 100644 --- a/cpukit/libnetworking/netinet/ip.h +++ b/cpukit/libnetworking/netinet/ip.h @@ -10,10 +10,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -31,6 +27,10 @@ * SUCH DAMAGE. * * @(#)ip.h 8.2 (Berkeley) 6/1/94 + * $FreeBSD: src/sys/netinet/ip.h,v 1.29 2005/01/07 01:45:44 imp Exp $ + */ + +/* * $Id$ */ @@ -45,21 +45,17 @@ /* * Structure of an internet header, naked of options. - * - * We declare ip_len and ip_off to be short, rather than u_short - * pragmatically since otherwise unsigned comparisons can result - * against negative integers quite easily, and fail in subtle ways. */ struct ip { #ifdef _IP_VHL u_char ip_vhl; /* version << 4 | header length >> 2 */ #else #if BYTE_ORDER == LITTLE_ENDIAN - u_char ip_hl:4, /* header length */ + u_int ip_hl:4, /* header length */ ip_v:4; /* version */ #endif #if BYTE_ORDER == BIG_ENDIAN - u_char ip_v:4, /* version */ + u_int ip_v:4, /* version */ ip_hl:4; /* header length */ #endif #endif /* not _IP_VHL */ @@ -85,6 +81,10 @@ struct ip { #define IP_VHL_BORING 0x45 #endif +#ifdef CTASSERT +CTASSERT(sizeof (struct ip) == 20); +#endif + #define IP_MAXPACKET 65535 /* maximum packet size */ /* @@ -94,6 +94,11 @@ struct ip { #define IPTOS_THROUGHPUT 0x08 #define IPTOS_RELIABILITY 0x04 #define IPTOS_MINCOST 0x02 +#if 1 +/* ECN RFC3168 obsoletes RFC2481, and these will be deprecated soon. */ +#define IPTOS_CE 0x01 +#define IPTOS_ECT 0x02 +#endif /* * Definitions for IP precedence (also in ip_tos) (hopefully unused) @@ -108,6 +113,16 @@ struct ip { #define IPTOS_PREC_ROUTINE 0x00 /* + * ECN (Explicit Congestion Notification) codepoints in RFC3168 + * mapped to the lower 2 bits of the TOS field. + */ +#define IPTOS_ECN_NOTECT 0x00 /* not-ECT */ +#define IPTOS_ECN_ECT1 0x01 /* ECN-capable transport (1) */ +#define IPTOS_ECN_ECT0 0x02 /* ECN-capable transport (0) */ +#define IPTOS_ECN_CE 0x03 /* congestion experienced */ +#define IPTOS_ECN_MASK 0x03 /* ECN field mask */ + +/* * Definitions for options. */ #define IPOPT_COPIED(o) ((o)&0x80) @@ -126,6 +141,8 @@ struct ip { #define IPOPT_TS 68 /* timestamp */ #define IPOPT_SECURITY 130 /* provide s,c,h,tcc */ #define IPOPT_LSRR 131 /* loose source route */ +#define IPOPT_ESO 133 /* extended security */ +#define IPOPT_CIPSO 134 /* commerical security */ #define IPOPT_SATID 136 /* satnet id */ #define IPOPT_SSRR 137 /* strict source route */ #define IPOPT_RA 148 /* router alert */ @@ -146,11 +163,11 @@ struct ip_timestamp { u_char ipt_len; /* size of structure (variable) */ u_char ipt_ptr; /* index of current entry */ #if BYTE_ORDER == LITTLE_ENDIAN - u_char ipt_flg:4, /* flags, see below */ + u_int ipt_flg:4, /* flags, see below */ ipt_oflw:4; /* overflow counter */ #endif #if BYTE_ORDER == BIG_ENDIAN - u_char ipt_oflw:4, /* overflow counter */ + u_int ipt_oflw:4, /* overflow counter */ ipt_flg:4; /* flags, see below */ #endif union ipt_timestamp { @@ -188,4 +205,16 @@ struct ip_timestamp { #define IP_MSS 576 /* default maximum segment size */ +/* + * This is the real IPv4 pseudo header, used for computing the TCP and UDP + * checksums. For the Internet checksum, struct ipovly can be used instead. + * For stronger checksums, the real thing must be used. + */ +struct ippseudo { + struct in_addr ippseudo_src; /* source internet address */ + struct in_addr ippseudo_dst; /* destination internet address */ + u_char ippseudo_pad; /* pad, must be zero */ + u_char ippseudo_p; /* protocol */ + u_short ippseudo_len; /* protocol length */ +}; #endif diff --git a/cpukit/libnetworking/netinet/ip_icmp.c b/cpukit/libnetworking/netinet/ip_icmp.c index 44088ab713..ef3779c0cb 100644 --- a/cpukit/libnetworking/netinet/ip_icmp.c +++ b/cpukit/libnetworking/netinet/ip_icmp.c @@ -10,10 +10,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -31,7 +27,11 @@ * SUCH DAMAGE. * * @(#)ip_icmp.c 8.2 (Berkeley) 1/4/94 - * $Id$ + * $FreeBSD: src/sys/netinet/ip_icmp.c,v 1.98 2005/01/07 01:45:44 imp Exp $ + */ + +/* + * $Id$ */ #include <sys/param.h> @@ -57,6 +57,19 @@ #include <netinet/ip_var.h> #include <netinet/icmp_var.h> +#ifdef IPSEC +#include <netinet6/ipsec.h> +#include <netkey/key.h> +#endif + +#ifdef FAST_IPSEC +#include <netipsec/ipsec.h> +#include <netipsec/key.h> +#define IPSEC +#endif + +#include <machine/in_cksum.h> + /* * ICMP routines: error generation, receive packet processing, and * routines to turnaround packets back to the originator, and @@ -80,9 +93,9 @@ SYSCTL_INT(_net_inet_icmp, OID_AUTO, bmcastecho, CTLFLAG_RW, &icmpbmcastecho, int icmpprintfs = 0; #endif -static void icmp_reflect __P((struct mbuf *)); -static void icmp_send __P((struct mbuf *, struct mbuf *)); -static int ip_next_mtu __P((int, int)); +static void icmp_reflect(struct mbuf *); +static void icmp_send(struct mbuf *, struct mbuf *); +static int ip_next_mtu(int, int); extern struct protosw inetsw[]; @@ -131,7 +144,12 @@ icmp_error(n, type, code, dest, destifp) m = m_gethdr(M_DONTWAIT, MT_HEADER); if (m == NULL) goto freeit; - icmplen = oiplen + min(8, oip->ip_len); +#ifdef MAC + mac_create_mbuf_netlayer(n, m); +#endif + icmplen = min(oiplen + 8, oip->ip_len); + if (icmplen < sizeof(struct ip)) + panic("icmp_error: bad length"); m->m_len = icmplen + ICMP_MINLEN; MH_ALIGN(m, m->m_len); icp = mtod(m, struct icmp *); @@ -191,17 +209,17 @@ static struct sockaddr_in icmpgw = { sizeof (struct sockaddr_in), AF_INET }; * Process a received ICMP message. */ void -icmp_input(m, hlen) - register struct mbuf *m; - int hlen; +icmp_input(m, off) + struct mbuf *m; + int off; { - register struct icmp *icp; - register struct ip *ip = mtod(m, struct ip *); - int icmplen = ip->ip_len; - register int i; + struct icmp *icp; struct in_ifaddr *ia; - void (*ctlfunc) __P((int, struct sockaddr *, void *)); - int code; + struct ip *ip = mtod(m, struct ip *); + int hlen = off; + int icmplen = ip->ip_len; + int i, code; + void (*ctlfunc)(int, struct sockaddr *, void *); /* * Locate icmp structure in mbuf, and check @@ -257,7 +275,7 @@ icmp_input(m, hlen) case ICMP_UNREACH_PROTOCOL: case ICMP_UNREACH_PORT: case ICMP_UNREACH_SRCFAIL: - code += PRC_UNREACH_NET; + code = PRC_UNREACH_NET; break; case ICMP_UNREACH_NEEDFRAG: @@ -506,8 +524,8 @@ static void icmp_reflect(m) struct mbuf *m; { - register struct ip *ip = mtod(m, struct ip *); - register struct in_ifaddr *ia; + struct ip *ip = mtod(m, struct ip *); + struct in_ifaddr *ia; struct in_addr t; struct mbuf *opts = 0; int optlen = (IP_VHL_HL(ip->ip_vhl) << 2) - sizeof(struct ip); @@ -575,8 +593,11 @@ icmp_reflect(m) if (opt == IPOPT_NOP) len = 1; else { + if (cnt < IPOPT_OLEN + sizeof(*cp)) + break; len = cp[IPOPT_OLEN]; - if (len <= 0 || len > cnt) + if (len < IPOPT_OLEN + sizeof(*cp) || + len > cnt) break; } /* |