From 9ef3092f3172c049beb847d1dca602e2b4b755c5 Mon Sep 17 00:00:00 2001 From: Stefan Siegl Date: Mon, 8 Oct 2007 21:12:31 +0000 Subject: 2007-10-08 Stefan Siegl Import a number of files from Linux 2.2.14. Renamed some of them, to have unique filenames as required by the make system. * linux-src/net/ipv6/addrconf.c: Import file. * linux-src/net/ipv6/af_inet6.c: Likewise. * linux-src/net/ipv6/exthdrs.c: Likewise. * linux-src/net/ipv6/ip6_fib.c: Likewise. * linux-src/net/ipv6/ip6_flowlabel.c: Likewise. * linux-src/net/ipv6/ip6_input.c: Likewise. * linux-src/net/ipv6/ip6_output.c: Likewise. * linux-src/net/ipv6/ipv6_sockglue.c: Likewise. * linux-src/net/ipv6/mcast.c: Likewise. * linux-src/net/ipv6/ndisc.c: Likewise. * linux-src/net/ipv6/reassembly.c: Likewise. * linux-src/net/ipv6/tcp_ipv6.c: Likewise. * linux-src/net/ipv6/datagram_ipv6.c: Import file (was datagram.c). * linux-src/net/ipv6/icmpv6.c: Import file (was icmp.c). * linux-src/net/ipv6/protocol_ipv6.c: Import file (was protocol.c). * linux-src/net/ipv6/raw_ipv6.c: Import file (was raw.c). * linux-src/net/ipv6/route_ipv6.c: Import file (was route.c). * linux-src/net/ipv6/udp_ipv6.c: Import file (was udp.c). --- pfinet/linux-src/net/ipv6/protocol_ipv6.c | 117 ++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 pfinet/linux-src/net/ipv6/protocol_ipv6.c (limited to 'pfinet/linux-src/net/ipv6/protocol_ipv6.c') diff --git a/pfinet/linux-src/net/ipv6/protocol_ipv6.c b/pfinet/linux-src/net/ipv6/protocol_ipv6.c new file mode 100644 index 00000000..ad871914 --- /dev/null +++ b/pfinet/linux-src/net/ipv6/protocol_ipv6.c @@ -0,0 +1,117 @@ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * PF_INET6 protocol dispatch tables. + * + * Version: $Id: protocol_ipv6.c,v 1.1 2007/10/08 21:12:31 stesie Exp $ + * + * Authors: Pedro Roque + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +struct inet6_protocol *inet6_protocol_base = NULL; +struct inet6_protocol *inet6_protos[MAX_INET_PROTOS] = +{ + NULL +}; + + +struct inet6_protocol *inet6_get_protocol(unsigned char prot) +{ + unsigned char hash; + struct inet6_protocol *p; + + hash = prot & (MAX_INET_PROTOS - 1); + for (p = inet6_protos[hash] ; p != NULL; p=p->next) { + if (p->protocol == prot) + return((struct inet6_protocol *) p); + } + return(NULL); +} + +void inet6_add_protocol(struct inet6_protocol *prot) +{ + unsigned char hash; + struct inet6_protocol *p2; + + hash = prot->protocol & (MAX_INET_PROTOS - 1); + prot->next = inet6_protos[hash]; + inet6_protos[hash] = prot; + prot->copy = 0; + + /* + * Set the copy bit if we need to. + */ + + p2 = (struct inet6_protocol *) prot->next; + while(p2 != NULL) { + if (p2->protocol == prot->protocol) { + prot->copy = 1; + break; + } + p2 = (struct inet6_protocol *) p2->next; + } +} + +/* + * Remove a protocol from the hash tables. + */ + +int inet6_del_protocol(struct inet6_protocol *prot) +{ + struct inet6_protocol *p; + struct inet6_protocol *lp = NULL; + unsigned char hash; + + hash = prot->protocol & (MAX_INET_PROTOS - 1); + if (prot == inet6_protos[hash]) { + inet6_protos[hash] = (struct inet6_protocol *) inet6_protos[hash]->next; + return(0); + } + + p = (struct inet6_protocol *) inet6_protos[hash]; + while(p != NULL) { + /* + * We have to worry if the protocol being deleted is + * the last one on the list, then we may need to reset + * someone's copied bit. + */ + if (p->next != NULL && p->next == prot) { + /* + * if we are the last one with this protocol and + * there is a previous one, reset its copy bit. + */ + if (p->copy == 0 && lp != NULL) + lp->copy = 0; + p->next = prot->next; + return(0); + } + if (p->next != NULL && p->next->protocol == prot->protocol) + lp = p; + + p = (struct inet6_protocol *) p->next; + } + return(-1); +} -- cgit v1.2.3