1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#ifndef _PROTOCOL_H
25#define _PROTOCOL_H
26
27#include <linux/in6.h>
28#include <linux/skbuff.h>
29#if IS_ENABLED(CONFIG_IPV6)
30#include <linux/ipv6.h>
31#endif
32#include <linux/netdevice.h>
33
34
35
36
37
38#define MAX_INET_PROTOS 256
39
40
41struct net_protocol {
42 void (*early_demux)(struct sk_buff *skb);
43 int (*handler)(struct sk_buff *skb);
44 void (*err_handler)(struct sk_buff *skb, u32 info);
45 unsigned int no_policy:1,
46 netns_ok:1;
47};
48
49#if IS_ENABLED(CONFIG_IPV6)
50struct inet6_protocol {
51 void (*early_demux)(struct sk_buff *skb);
52
53 int (*handler)(struct sk_buff *skb);
54
55 void (*err_handler)(struct sk_buff *skb,
56 struct inet6_skb_parm *opt,
57 u8 type, u8 code, int offset,
58 __be32 info);
59 unsigned int flags;
60};
61
62#define INET6_PROTO_NOPOLICY 0x1
63#define INET6_PROTO_FINAL 0x2
64#endif
65
66struct net_offload {
67 struct offload_callbacks callbacks;
68 unsigned int flags;
69};
70
71#define INET6_PROTO_GSO_EXTHDR 0x1
72
73
74struct inet_protosw {
75 struct list_head list;
76
77
78 unsigned short type;
79 unsigned short protocol;
80
81 struct proto *prot;
82 const struct proto_ops *ops;
83
84 unsigned char flags;
85};
86#define INET_PROTOSW_REUSE 0x01
87#define INET_PROTOSW_PERMANENT 0x02
88#define INET_PROTOSW_ICSK 0x04
89
90extern const struct net_protocol __rcu *inet_protos[MAX_INET_PROTOS];
91extern const struct net_offload __rcu *inet_offloads[MAX_INET_PROTOS];
92extern const struct net_offload __rcu *inet6_offloads[MAX_INET_PROTOS];
93
94#if IS_ENABLED(CONFIG_IPV6)
95extern const struct inet6_protocol __rcu *inet6_protos[MAX_INET_PROTOS];
96#endif
97
98extern int inet_add_protocol(const struct net_protocol *prot, unsigned char num);
99extern int inet_del_protocol(const struct net_protocol *prot, unsigned char num);
100extern int inet_add_offload(const struct net_offload *prot, unsigned char num);
101extern int inet_del_offload(const struct net_offload *prot, unsigned char num);
102extern void inet_register_protosw(struct inet_protosw *p);
103extern void inet_unregister_protosw(struct inet_protosw *p);
104
105#if IS_ENABLED(CONFIG_IPV6)
106extern int inet6_add_protocol(const struct inet6_protocol *prot, unsigned char num);
107extern int inet6_del_protocol(const struct inet6_protocol *prot, unsigned char num);
108extern int inet6_register_protosw(struct inet_protosw *p);
109extern void inet6_unregister_protosw(struct inet_protosw *p);
110#endif
111extern int inet6_add_offload(const struct net_offload *prot, unsigned char num);
112extern int inet6_del_offload(const struct net_offload *prot, unsigned char num);
113
114#endif
115