11da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 21da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * INET An implementation of the TCP/IP protocol suite for the LINUX 31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * operating system. INET is implemented using the BSD Socket 41da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * interface as the means of communication with the user level. 51da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 61da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Definitions for the protocol dispatcher. 71da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 81da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Version: @(#)protocol.h 1.0.2 05/07/93 91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> 111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * This program is free software; you can redistribute it and/or 131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * modify it under the terms of the GNU General Public License 141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * as published by the Free Software Foundation; either version 151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 2 of the License, or (at your option) any later version. 161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Changes: 181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Alan Cox : Added a name field and a frag handler 191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * field for later. 201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Alan Cox : Cleaned up, and sorted types. 211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Pedro Roque : inet6 protocols 221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifndef _PROTOCOL_H 251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define _PROTOCOL_H 261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/in6.h> 28c6b641a4c6b32f39db678c2441cb1ef824110d74Vlad Yasevich#include <linux/skbuff.h> 29dfd56b8b38fff3586f36232db58e1e9f7885a605Eric Dumazet#if IS_ENABLED(CONFIG_IPV6) 301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/ipv6.h> 311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif 32f191a1d17f227032c159e5499809f545402b6dc6Vlad Yasevich#include <linux/netdevice.h> 331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 34f9242b6b28d61295f2bf7e8adfb1060b382e5381David S. Miller/* This is one larger than the largest protocol value that can be 35f9242b6b28d61295f2bf7e8adfb1060b382e5381David S. Miller * found in an ipv4 or ipv6 header. Since in both cases the protocol 36f9242b6b28d61295f2bf7e8adfb1060b382e5381David S. Miller * value is presented in a __u8, this is defined to be 256. 37f9242b6b28d61295f2bf7e8adfb1060b382e5381David S. Miller */ 38f9242b6b28d61295f2bf7e8adfb1060b382e5381David S. Miller#define MAX_INET_PROTOS 256 391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* This is used to register protocols. */ 411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct net_protocol { 42160eb5a6b14ca2eab5c598bdbbb24c24624bad34David S. Miller void (*early_demux)(struct sk_buff *skb); 431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int (*handler)(struct sk_buff *skb); 441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds void (*err_handler)(struct sk_buff *skb, u32 info); 45f145049a06f470d0489f47cb83ff3ccb2a0de622Denis V. Lunev unsigned int no_policy:1, 468ed1dc44d3e9e8387a104b1ae8f92e9a3fbf1b1eHannes Frederic Sowa netns_ok:1, 478ed1dc44d3e9e8387a104b1ae8f92e9a3fbf1b1eHannes Frederic Sowa /* does the protocol do more stringent 488ed1dc44d3e9e8387a104b1ae8f92e9a3fbf1b1eHannes Frederic Sowa * icmp tag validation than simple 498ed1dc44d3e9e8387a104b1ae8f92e9a3fbf1b1eHannes Frederic Sowa * socket lookup? 508ed1dc44d3e9e8387a104b1ae8f92e9a3fbf1b1eHannes Frederic Sowa */ 518ed1dc44d3e9e8387a104b1ae8f92e9a3fbf1b1eHannes Frederic Sowa icmp_strict_tag_validation:1; 521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 54dfd56b8b38fff3586f36232db58e1e9f7885a605Eric Dumazet#if IS_ENABLED(CONFIG_IPV6) 55fd2c3ef761fbc5e6c27fa7d40b30cda06bfcd7d8Eric Dumazetstruct inet6_protocol { 56c7109986db3c945f50ceed884a30e0fd8af3b89bEric Dumazet void (*early_demux)(struct sk_buff *skb); 57c7109986db3c945f50ceed884a30e0fd8af3b89bEric Dumazet 58e5bbef20e017efcb10700398cc048c49b98628e0Herbert Xu int (*handler)(struct sk_buff *skb); 591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds void (*err_handler)(struct sk_buff *skb, 611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct inet6_skb_parm *opt, 62d5fdd6babcfc2b0e6a8da1acf492a69fb54b4c47Brian Haley u8 type, u8 code, int offset, 6304ce69093f91547d3a7c4fc815d2868195591340Al Viro __be32 info); 641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned int flags; /* INET6_PROTO_xxx */ 651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define INET6_PROTO_NOPOLICY 0x1 681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define INET6_PROTO_FINAL 0x2 691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif 701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 71de27d001d187721de775ed9e0c485aa6f517c745Vlad Yasevichstruct net_offload { 72f191a1d17f227032c159e5499809f545402b6dc6Vlad Yasevich struct offload_callbacks callbacks; 73f191a1d17f227032c159e5499809f545402b6dc6Vlad Yasevich unsigned int flags; /* Flags used by IPv6 for now */ 74de27d001d187721de775ed9e0c485aa6f517c745Vlad Yasevich}; 75c6b641a4c6b32f39db678c2441cb1ef824110d74Vlad Yasevich/* This should be set for any extension header which is compatible with GSO. */ 76c6b641a4c6b32f39db678c2441cb1ef824110d74Vlad Yasevich#define INET6_PROTO_GSO_EXTHDR 0x1 77de27d001d187721de775ed9e0c485aa6f517c745Vlad Yasevich 781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* This is used to register socket interfaces for IP protocols. */ 791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstruct inet_protosw { 801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct list_head list; 811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* These two fields form the lookup key. */ 831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned short type; /* This is the 2nd argument to socket(2). */ 84ee41e2dff1a0ac548f12871f4bb23fe9e69e13ebArnaldo Carvalho de Melo unsigned short protocol; /* This is the L4 protocol number. */ 851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct proto *prot; 8790ddc4f0470427df306f308ad03db6b6b21644b8Eric Dumazet const struct proto_ops *ops; 881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned char flags; /* See INET_PROTOSW_* below. */ 901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}; 911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define INET_PROTOSW_REUSE 0x01 /* Are ports automatically reusable? */ 921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define INET_PROTOSW_PERMANENT 0x02 /* Permanent protocols are unremovable. */ 93d83d8461f902c672bc1bd8fbc6a94e19f092da97Arnaldo Carvalho de Melo#define INET_PROTOSW_ICSK 0x04 /* Is this an inet_connection_sock? */ 941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 95e0ad61ec867fdd262804afa7a68e11fc9930c2b9Eric Dumazetextern const struct net_protocol __rcu *inet_protos[MAX_INET_PROTOS]; 96de27d001d187721de775ed9e0c485aa6f517c745Vlad Yasevichextern const struct net_offload __rcu *inet_offloads[MAX_INET_PROTOS]; 97c6b641a4c6b32f39db678c2441cb1ef824110d74Vlad Yasevichextern const struct net_offload __rcu *inet6_offloads[MAX_INET_PROTOS]; 981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 99dfd56b8b38fff3586f36232db58e1e9f7885a605Eric Dumazet#if IS_ENABLED(CONFIG_IPV6) 100e0ad61ec867fdd262804afa7a68e11fc9930c2b9Eric Dumazetextern const struct inet6_protocol __rcu *inet6_protos[MAX_INET_PROTOS]; 1011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif 1021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 103f307c6365648e919d7ac733f0b3a7e9ee3e31eb2Joe Perchesint inet_add_protocol(const struct net_protocol *prot, unsigned char num); 104f307c6365648e919d7ac733f0b3a7e9ee3e31eb2Joe Perchesint inet_del_protocol(const struct net_protocol *prot, unsigned char num); 105f307c6365648e919d7ac733f0b3a7e9ee3e31eb2Joe Perchesint inet_add_offload(const struct net_offload *prot, unsigned char num); 106f307c6365648e919d7ac733f0b3a7e9ee3e31eb2Joe Perchesint inet_del_offload(const struct net_offload *prot, unsigned char num); 107f307c6365648e919d7ac733f0b3a7e9ee3e31eb2Joe Perchesvoid inet_register_protosw(struct inet_protosw *p); 108f307c6365648e919d7ac733f0b3a7e9ee3e31eb2Joe Perchesvoid inet_unregister_protosw(struct inet_protosw *p); 1091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 110b582ef0990d457f7ce8ccf827af51a575ca0b4a6Or Gerlitzint udp_add_offload(struct udp_offload *prot); 111b582ef0990d457f7ce8ccf827af51a575ca0b4a6Or Gerlitzvoid udp_del_offload(struct udp_offload *prot); 112b582ef0990d457f7ce8ccf827af51a575ca0b4a6Or Gerlitz 113dfd56b8b38fff3586f36232db58e1e9f7885a605Eric Dumazet#if IS_ENABLED(CONFIG_IPV6) 114f307c6365648e919d7ac733f0b3a7e9ee3e31eb2Joe Perchesint inet6_add_protocol(const struct inet6_protocol *prot, unsigned char num); 115f307c6365648e919d7ac733f0b3a7e9ee3e31eb2Joe Perchesint inet6_del_protocol(const struct inet6_protocol *prot, unsigned char num); 116f307c6365648e919d7ac733f0b3a7e9ee3e31eb2Joe Perchesint inet6_register_protosw(struct inet_protosw *p); 117f307c6365648e919d7ac733f0b3a7e9ee3e31eb2Joe Perchesvoid inet6_unregister_protosw(struct inet_protosw *p); 1181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif 119f307c6365648e919d7ac733f0b3a7e9ee3e31eb2Joe Perchesint inet6_add_offload(const struct net_offload *prot, unsigned char num); 120f307c6365648e919d7ac733f0b3a7e9ee3e31eb2Joe Perchesint inet6_del_offload(const struct net_offload *prot, unsigned char num); 1211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif /* _PROTOCOL_H */ 123