/*1* INET An implementation of the TCP/IP protocol suite for the LINUX2* operating system. INET is implemented using the BSD Socket3* interface as the means of communication with the user level.4*5* INET protocol dispatch tables.6*7* Authors: Ross Biro8* Fred N. van Kempen, <[email protected]>9*10* Fixes:11* Alan Cox : Ahah! udp icmp errors don't work because12* udp_err is never called!13* Alan Cox : Added new fields for init and ready for14* proper fragmentation (_NO_ 4K limits!)15* Richard Colella : Hang on hash collision16* Vince Laviano : Modified inet_del_protocol() to correctly17* maintain copy bit.18*19* This program is free software; you can redistribute it and/or20* modify it under the terms of the GNU General Public License21* as published by the Free Software Foundation; either version22* 2 of the License, or (at your option) any later version.23*/24#include <linux/cache.h>25#include <linux/module.h>26#include <linux/netdevice.h>27#include <linux/spinlock.h>28#include <net/protocol.h>2930const struct net_protocol __rcu *inet_protos[MAX_INET_PROTOS] __read_mostly;3132/*33* Add a protocol handler to the hash tables34*/3536int inet_add_protocol(const struct net_protocol *prot, unsigned char protocol)37{38int hash = protocol & (MAX_INET_PROTOS - 1);3940return !cmpxchg((const struct net_protocol **)&inet_protos[hash],41NULL, prot) ? 0 : -1;42}43EXPORT_SYMBOL(inet_add_protocol);4445/*46* Remove a protocol from the hash tables.47*/4849int inet_del_protocol(const struct net_protocol *prot, unsigned char protocol)50{51int ret, hash = protocol & (MAX_INET_PROTOS - 1);5253ret = (cmpxchg((const struct net_protocol **)&inet_protos[hash],54prot, NULL) == prot) ? 0 : -1;5556synchronize_net();5758return ret;59}60EXPORT_SYMBOL(inet_del_protocol);616263