aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
Diffstat (limited to 'include/net')
-rw-r--r--include/net/9p/9p.h12
-rw-r--r--include/net/ah.h9
-rw-r--r--include/net/ax25.h5
-rw-r--r--include/net/ax88796.h1
-rw-r--r--include/net/cfg80211.h11
-rw-r--r--include/net/dn_route.h3
-rw-r--r--include/net/esp.h14
-rw-r--r--include/net/fib_rules.h2
-rw-r--r--include/net/icmp.h8
-rw-r--r--include/net/ieee80211.h5
-rw-r--r--include/net/ieee80211_radiotap.h10
-rw-r--r--include/net/ieee80211softmac.h2
-rw-r--r--include/net/if_inet6.h1
-rw-r--r--include/net/inet_hashtables.h2
-rw-r--r--include/net/inet_timewait_sock.h1
-rw-r--r--include/net/ip.h3
-rw-r--r--include/net/ip6_fib.h4
-rw-r--r--include/net/ipcomp.h11
-rw-r--r--include/net/ipv6.h73
-rw-r--r--include/net/iucv/af_iucv.h28
-rw-r--r--include/net/iw_handler.h8
-rw-r--r--include/net/llc_conn.h2
-rw-r--r--include/net/mac80211.h1342
-rw-r--r--include/net/ndisc.h1
-rw-r--r--include/net/net_namespace.h123
-rw-r--r--include/net/netfilter/nf_conntrack.h3
-rw-r--r--include/net/netfilter/nf_conntrack_expect.h3
-rw-r--r--include/net/netfilter/nf_conntrack_helper.h2
-rw-r--r--include/net/netfilter/nf_conntrack_l3proto.h9
-rw-r--r--include/net/netfilter/nf_conntrack_l4proto.h17
-rw-r--r--include/net/netfilter/nf_nat_protocol.h8
-rw-r--r--include/net/netlink.h25
-rw-r--r--include/net/pkt_cls.h3
-rw-r--r--include/net/pkt_sched.h5
-rw-r--r--include/net/rose.h2
-rw-r--r--include/net/rtnetlink.h4
-rw-r--r--include/net/sch_generic.h14
-rw-r--r--include/net/sctp/auth.h128
-rw-r--r--include/net/sctp/command.h1
-rw-r--r--include/net/sctp/constants.h53
-rw-r--r--include/net/sctp/sctp.h6
-rw-r--r--include/net/sctp/sm.h2
-rw-r--r--include/net/sctp/structs.h87
-rw-r--r--include/net/sctp/ulpevent.h4
-rw-r--r--include/net/sctp/user.h90
-rw-r--r--include/net/snmp.h11
-rw-r--r--include/net/sock.h39
-rw-r--r--include/net/tc_act/tc_nat.h21
-rw-r--r--include/net/tcp.h90
-rw-r--r--include/net/tcp_ecn.h130
-rw-r--r--include/net/veth.h12
-rw-r--r--include/net/wext.h15
-rw-r--r--include/net/xfrm.h82
53 files changed, 1745 insertions, 802 deletions
diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h
index 88884d39f28f..7726ff41c3e6 100644
--- a/include/net/9p/9p.h
+++ b/include/net/9p/9p.h
@@ -412,6 +412,18 @@ int p9_idpool_check(int id, struct p9_idpool *p);
412 412
413int p9_error_init(void); 413int p9_error_init(void);
414int p9_errstr2errno(char *, int); 414int p9_errstr2errno(char *, int);
415
416#ifdef CONFIG_SYSCTL
415int __init p9_sysctl_register(void); 417int __init p9_sysctl_register(void);
416void __exit p9_sysctl_unregister(void); 418void __exit p9_sysctl_unregister(void);
419#else
420static inline int p9_sysctl_register(void)
421{
422 return 0;
423}
424static inline void p9_sysctl_unregister(void)
425{
426}
427#endif
428
417#endif /* NET_9P_H */ 429#endif /* NET_9P_H */
diff --git a/include/net/ah.h b/include/net/ah.h
index 8f257c159902..ae1c322f4242 100644
--- a/include/net/ah.h
+++ b/include/net/ah.h
@@ -9,8 +9,6 @@
9 9
10struct ah_data 10struct ah_data
11{ 11{
12 u8 *key;
13 int key_len;
14 u8 *work_icv; 12 u8 *work_icv;
15 int icv_full_len; 13 int icv_full_len;
16 int icv_trunc_len; 14 int icv_trunc_len;
@@ -40,4 +38,11 @@ out:
40 return err; 38 return err;
41} 39}
42 40
41struct ip_auth_hdr;
42
43static inline struct ip_auth_hdr *ip_auth_hdr(const struct sk_buff *skb)
44{
45 return (struct ip_auth_hdr *)skb_transport_header(skb);
46}
47
43#endif 48#endif
diff --git a/include/net/ax25.h b/include/net/ax25.h
index 99a4e364c74a..4e3cd93f81fc 100644
--- a/include/net/ax25.h
+++ b/include/net/ax25.h
@@ -363,8 +363,11 @@ extern int ax25_rx_iframe(ax25_cb *, struct sk_buff *);
363extern int ax25_kiss_rcv(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *); 363extern int ax25_kiss_rcv(struct sk_buff *, struct net_device *, struct packet_type *, struct net_device *);
364 364
365/* ax25_ip.c */ 365/* ax25_ip.c */
366extern int ax25_hard_header(struct sk_buff *, struct net_device *, unsigned short, void *, void *, unsigned int); 366extern int ax25_hard_header(struct sk_buff *, struct net_device *,
367 unsigned short, const void *,
368 const void *, unsigned int);
367extern int ax25_rebuild_header(struct sk_buff *); 369extern int ax25_rebuild_header(struct sk_buff *);
370extern const struct header_ops ax25_header_ops;
368 371
369/* ax25_out.c */ 372/* ax25_out.c */
370extern ax25_cb *ax25_send_frame(struct sk_buff *, int, ax25_address *, ax25_address *, ax25_digi *, struct net_device *); 373extern ax25_cb *ax25_send_frame(struct sk_buff *, int, ax25_address *, ax25_address *, ax25_digi *, struct net_device *);
diff --git a/include/net/ax88796.h b/include/net/ax88796.h
index ee786a043b3d..51329dae44e6 100644
--- a/include/net/ax88796.h
+++ b/include/net/ax88796.h
@@ -14,6 +14,7 @@
14 14
15#define AXFLG_HAS_EEPROM (1<<0) 15#define AXFLG_HAS_EEPROM (1<<0)
16#define AXFLG_MAC_FROMDEV (1<<1) /* device already has MAC */ 16#define AXFLG_MAC_FROMDEV (1<<1) /* device already has MAC */
17#define AXFLG_HAS_93CX6 (1<<2) /* use eeprom_93cx6 driver */
17 18
18struct ax_plat_data { 19struct ax_plat_data {
19 unsigned int flags; 20 unsigned int flags;
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 7edaef6b29d6..d30960e1755c 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -3,15 +3,15 @@
3 3
4#include <linux/netlink.h> 4#include <linux/netlink.h>
5#include <linux/skbuff.h> 5#include <linux/skbuff.h>
6#include <linux/nl80211.h>
6#include <net/genetlink.h> 7#include <net/genetlink.h>
7 8
8/* 9/*
9 * 802.11 configuration in-kernel interface 10 * 802.11 configuration in-kernel interface
10 * 11 *
11 * Copyright 2006 Johannes Berg <johannes@sipsolutions.net> 12 * Copyright 2006, 2007 Johannes Berg <johannes@sipsolutions.net>
12 */ 13 */
13 14
14
15/* Radiotap header iteration 15/* Radiotap header iteration
16 * implemented in net/wireless/radiotap.c 16 * implemented in net/wireless/radiotap.c
17 * docs in Documentation/networking/radiotap-headers.txt 17 * docs in Documentation/networking/radiotap-headers.txt
@@ -68,11 +68,16 @@ struct wiphy;
68 * @add_virtual_intf: create a new virtual interface with the given name 68 * @add_virtual_intf: create a new virtual interface with the given name
69 * 69 *
70 * @del_virtual_intf: remove the virtual interface determined by ifindex. 70 * @del_virtual_intf: remove the virtual interface determined by ifindex.
71 *
72 * @change_virtual_intf: change type of virtual interface
73 *
71 */ 74 */
72struct cfg80211_ops { 75struct cfg80211_ops {
73 int (*add_virtual_intf)(struct wiphy *wiphy, char *name, 76 int (*add_virtual_intf)(struct wiphy *wiphy, char *name,
74 unsigned int type); 77 enum nl80211_iftype type);
75 int (*del_virtual_intf)(struct wiphy *wiphy, int ifindex); 78 int (*del_virtual_intf)(struct wiphy *wiphy, int ifindex);
79 int (*change_virtual_intf)(struct wiphy *wiphy, int ifindex,
80 enum nl80211_iftype type);
76}; 81};
77 82
78#endif /* __NET_CFG80211_H */ 83#endif /* __NET_CFG80211_H */
diff --git a/include/net/dn_route.h b/include/net/dn_route.h
index c10e8e7e59a7..60c9f22d8694 100644
--- a/include/net/dn_route.h
+++ b/include/net/dn_route.h
@@ -100,8 +100,7 @@ static inline void dn_rt_finish_output(struct sk_buff *skb, char *dst, char *src
100 if ((dev->type != ARPHRD_ETHER) && (dev->type != ARPHRD_LOOPBACK)) 100 if ((dev->type != ARPHRD_ETHER) && (dev->type != ARPHRD_LOOPBACK))
101 dst = NULL; 101 dst = NULL;
102 102
103 if (!dev->hard_header || (dev->hard_header(skb, dev, ETH_P_DNA_RT, 103 if (dev_hard_header(skb, dev, ETH_P_DNA_RT, dst, src, skb->len) >= 0)
104 dst, src, skb->len) >= 0))
105 dn_rt_send(skb); 104 dn_rt_send(skb);
106 else 105 else
107 kfree_skb(skb); 106 kfree_skb(skb);
diff --git a/include/net/esp.h b/include/net/esp.h
index d05d8d2c78f4..c1bc529809da 100644
--- a/include/net/esp.h
+++ b/include/net/esp.h
@@ -13,8 +13,6 @@ struct esp_data
13 13
14 /* Confidentiality */ 14 /* Confidentiality */
15 struct { 15 struct {
16 u8 *key; /* Key */
17 int key_len; /* Key length */
18 int padlen; /* 0..255 */ 16 int padlen; /* 0..255 */
19 /* ivlen is offset from enc_data, where encrypted data start. 17 /* ivlen is offset from enc_data, where encrypted data start.
20 * It is logically different of crypto_tfm_alg_ivsize(tfm). 18 * It is logically different of crypto_tfm_alg_ivsize(tfm).
@@ -28,14 +26,9 @@ struct esp_data
28 26
29 /* Integrity. It is active when icv_full_len != 0 */ 27 /* Integrity. It is active when icv_full_len != 0 */
30 struct { 28 struct {
31 u8 *key; /* Key */
32 int key_len; /* Length of the key */
33 u8 *work_icv; 29 u8 *work_icv;
34 int icv_full_len; 30 int icv_full_len;
35 int icv_trunc_len; 31 int icv_trunc_len;
36 void (*icv)(struct esp_data*,
37 struct sk_buff *skb,
38 int offset, int len, u8 *icv);
39 struct crypto_hash *tfm; 32 struct crypto_hash *tfm;
40 } auth; 33 } auth;
41}; 34};
@@ -60,4 +53,11 @@ static inline int esp_mac_digest(struct esp_data *esp, struct sk_buff *skb,
60 return crypto_hash_final(&desc, esp->auth.work_icv); 53 return crypto_hash_final(&desc, esp->auth.work_icv);
61} 54}
62 55
56struct ip_esp_hdr;
57
58static inline struct ip_esp_hdr *ip_esp_hdr(const struct sk_buff *skb)
59{
60 return (struct ip_esp_hdr *)skb_transport_header(skb);
61}
62
63#endif 63#endif
diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h
index 83e41dd15ccd..017aebd90683 100644
--- a/include/net/fib_rules.h
+++ b/include/net/fib_rules.h
@@ -65,7 +65,7 @@ struct fib_rules_ops
65 65
66 int nlgroup; 66 int nlgroup;
67 const struct nla_policy *policy; 67 const struct nla_policy *policy;
68 struct list_head *rules_list; 68 struct list_head rules_list;
69 struct module *owner; 69 struct module *owner;
70}; 70};
71 71
diff --git a/include/net/icmp.h b/include/net/icmp.h
index dc09474efcf3..9f7ef3c8baef 100644
--- a/include/net/icmp.h
+++ b/include/net/icmp.h
@@ -30,9 +30,16 @@ struct icmp_err {
30 30
31extern struct icmp_err icmp_err_convert[]; 31extern struct icmp_err icmp_err_convert[];
32DECLARE_SNMP_STAT(struct icmp_mib, icmp_statistics); 32DECLARE_SNMP_STAT(struct icmp_mib, icmp_statistics);
33DECLARE_SNMP_STAT(struct icmpmsg_mib, icmpmsg_statistics);
33#define ICMP_INC_STATS(field) SNMP_INC_STATS(icmp_statistics, field) 34#define ICMP_INC_STATS(field) SNMP_INC_STATS(icmp_statistics, field)
34#define ICMP_INC_STATS_BH(field) SNMP_INC_STATS_BH(icmp_statistics, field) 35#define ICMP_INC_STATS_BH(field) SNMP_INC_STATS_BH(icmp_statistics, field)
35#define ICMP_INC_STATS_USER(field) SNMP_INC_STATS_USER(icmp_statistics, field) 36#define ICMP_INC_STATS_USER(field) SNMP_INC_STATS_USER(icmp_statistics, field)
37#define ICMPMSGOUT_INC_STATS(field) SNMP_INC_STATS(icmpmsg_statistics, field+256)
38#define ICMPMSGOUT_INC_STATS_BH(field) SNMP_INC_STATS_BH(icmpmsg_statistics, field+256)
39#define ICMPMSGOUT_INC_STATS_USER(field) SNMP_INC_STATS_USER(icmpmsg_statistics, field+256)
40#define ICMPMSGIN_INC_STATS(field) SNMP_INC_STATS(icmpmsg_statistics, field)
41#define ICMPMSGIN_INC_STATS_BH(field) SNMP_INC_STATS_BH(icmpmsg_statistics, field)
42#define ICMPMSGIN_INC_STATS_USER(field) SNMP_INC_STATS_USER(icmpmsg_statistics, field)
36 43
37struct dst_entry; 44struct dst_entry;
38struct net_proto_family; 45struct net_proto_family;
@@ -42,6 +49,7 @@ extern void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info);
42extern int icmp_rcv(struct sk_buff *skb); 49extern int icmp_rcv(struct sk_buff *skb);
43extern int icmp_ioctl(struct sock *sk, int cmd, unsigned long arg); 50extern int icmp_ioctl(struct sock *sk, int cmd, unsigned long arg);
44extern void icmp_init(struct net_proto_family *ops); 51extern void icmp_init(struct net_proto_family *ops);
52extern void icmp_out_count(unsigned char type);
45 53
46/* Move into dst.h ? */ 54/* Move into dst.h ? */
47extern int xrlim_allow(struct dst_entry *dst, int timeout); 55extern int xrlim_allow(struct dst_entry *dst, int timeout);
diff --git a/include/net/ieee80211.h b/include/net/ieee80211.h
index bbd85cd61ed5..164d13211165 100644
--- a/include/net/ieee80211.h
+++ b/include/net/ieee80211.h
@@ -119,11 +119,6 @@ do { if (ieee80211_debug_level & (level)) \
119#define IEEE80211_DEBUG(level, fmt, args...) do {} while (0) 119#define IEEE80211_DEBUG(level, fmt, args...) do {} while (0)
120#endif /* CONFIG_IEEE80211_DEBUG */ 120#endif /* CONFIG_IEEE80211_DEBUG */
121 121
122/* debug macros not dependent on CONFIG_IEEE80211_DEBUG */
123
124#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
125#define MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5]
126
127/* escape_essid() is intended to be used in debug (and possibly error) 122/* escape_essid() is intended to be used in debug (and possibly error)
128 * messages. It should never be used for passing essid to user space. */ 123 * messages. It should never be used for passing essid to user space. */
129const char *escape_essid(const char *essid, u8 essid_len); 124const char *escape_essid(const char *essid, u8 essid_len);
diff --git a/include/net/ieee80211_radiotap.h b/include/net/ieee80211_radiotap.h
index a0c2b41a24d7..dfd8bf66ce27 100644
--- a/include/net/ieee80211_radiotap.h
+++ b/include/net/ieee80211_radiotap.h
@@ -40,6 +40,7 @@
40 40
41#include <linux/if_ether.h> 41#include <linux/if_ether.h>
42#include <linux/kernel.h> 42#include <linux/kernel.h>
43#include <asm/unaligned.h>
43 44
44/* Radiotap header version (from official NetBSD feed) */ 45/* Radiotap header version (from official NetBSD feed) */
45#define IEEE80211RADIOTAP_VERSION "1.5" 46#define IEEE80211RADIOTAP_VERSION "1.5"
@@ -255,4 +256,13 @@ enum ieee80211_radiotap_type {
255 (((x) == 14) ? 2484 : ((x) * 5) + 2407) : \ 256 (((x) == 14) ? 2484 : ((x) * 5) + 2407) : \
256 ((x) + 1000) * 5) 257 ((x) + 1000) * 5)
257 258
259/* helpers */
260static inline int ieee80211_get_radiotap_len(unsigned char *data)
261{
262 struct ieee80211_radiotap_header *hdr =
263 (struct ieee80211_radiotap_header *)data;
264
265 return le16_to_cpu(get_unaligned(&hdr->it_len));
266}
267
258#endif /* IEEE80211_RADIOTAP_H */ 268#endif /* IEEE80211_RADIOTAP_H */
diff --git a/include/net/ieee80211softmac.h b/include/net/ieee80211softmac.h
index 89119277553d..1ef6282fdded 100644
--- a/include/net/ieee80211softmac.h
+++ b/include/net/ieee80211softmac.h
@@ -229,6 +229,8 @@ struct ieee80211softmac_device {
229 /* this lock protects this structure */ 229 /* this lock protects this structure */
230 spinlock_t lock; 230 spinlock_t lock;
231 231
232 struct workqueue_struct *wq;
233
232 u8 running; /* SoftMAC started? */ 234 u8 running; /* SoftMAC started? */
233 u8 scanning; 235 u8 scanning;
234 236
diff --git a/include/net/if_inet6.h b/include/net/if_inet6.h
index 3ec7d07346d6..448eccb20638 100644
--- a/include/net/if_inet6.h
+++ b/include/net/if_inet6.h
@@ -154,6 +154,7 @@ struct ipv6_devstat {
154 struct proc_dir_entry *proc_dir_entry; 154 struct proc_dir_entry *proc_dir_entry;
155 DEFINE_SNMP_STAT(struct ipstats_mib, ipv6); 155 DEFINE_SNMP_STAT(struct ipstats_mib, ipv6);
156 DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6); 156 DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6);
157 DEFINE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg);
157}; 158};
158 159
159struct inet6_dev 160struct inet6_dev
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h
index d27ee8c0da3f..8228b57eb18f 100644
--- a/include/net/inet_hashtables.h
+++ b/include/net/inet_hashtables.h
@@ -107,7 +107,7 @@ struct inet_hashinfo {
107 */ 107 */
108 struct inet_bind_hashbucket *bhash; 108 struct inet_bind_hashbucket *bhash;
109 109
110 int bhash_size; 110 unsigned int bhash_size;
111 unsigned int ehash_size; 111 unsigned int ehash_size;
112 112
113 /* All sockets in TCP_LISTEN state will be in here. This is the only 113 /* All sockets in TCP_LISTEN state will be in here. This is the only
diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h
index 47d52b2414db..abaff0597270 100644
--- a/include/net/inet_timewait_sock.h
+++ b/include/net/inet_timewait_sock.h
@@ -115,6 +115,7 @@ struct inet_timewait_sock {
115#define tw_refcnt __tw_common.skc_refcnt 115#define tw_refcnt __tw_common.skc_refcnt
116#define tw_hash __tw_common.skc_hash 116#define tw_hash __tw_common.skc_hash
117#define tw_prot __tw_common.skc_prot 117#define tw_prot __tw_common.skc_prot
118#define tw_net __tw_common.skc_net
118 volatile unsigned char tw_substate; 119 volatile unsigned char tw_substate;
119 /* 3 bits hole, try to pack */ 120 /* 3 bits hole, try to pack */
120 unsigned char tw_rcv_wscale; 121 unsigned char tw_rcv_wscale;
diff --git a/include/net/ip.h b/include/net/ip.h
index abf2820a1125..3af3ed9d320b 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -171,7 +171,8 @@ extern unsigned long snmp_fold_field(void *mib[], int offt);
171extern int snmp_mib_init(void *ptr[2], size_t mibsize, size_t mibalign); 171extern int snmp_mib_init(void *ptr[2], size_t mibsize, size_t mibalign);
172extern void snmp_mib_free(void *ptr[2]); 172extern void snmp_mib_free(void *ptr[2]);
173 173
174extern int sysctl_local_port_range[2]; 174extern void inet_get_local_port_range(int *low, int *high);
175
175extern int sysctl_ip_default_ttl; 176extern int sysctl_ip_default_ttl;
176extern int sysctl_ip_nonlocal_bind; 177extern int sysctl_ip_nonlocal_bind;
177 178
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index c48ea873f1e0..857821360bb6 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -105,6 +105,10 @@ struct rt6_info
105 struct rt6key rt6i_src; 105 struct rt6key rt6i_src;
106 106
107 u8 rt6i_protocol; 107 u8 rt6i_protocol;
108
109#ifdef CONFIG_XFRM
110 u32 rt6i_flow_cache_genid;
111#endif
108}; 112};
109 113
110static inline struct inet6_dev *ip6_dst_idev(struct dst_entry *dst) 114static inline struct inet6_dev *ip6_dst_idev(struct dst_entry *dst)
diff --git a/include/net/ipcomp.h b/include/net/ipcomp.h
index 87c1af3e5e82..330b74e813a9 100644
--- a/include/net/ipcomp.h
+++ b/include/net/ipcomp.h
@@ -1,14 +1,23 @@
1#ifndef _NET_IPCOMP_H 1#ifndef _NET_IPCOMP_H
2#define _NET_IPCOMP_H 2#define _NET_IPCOMP_H
3 3
4#include <linux/crypto.h>
5#include <linux/types.h> 4#include <linux/types.h>
6 5
7#define IPCOMP_SCRATCH_SIZE 65400 6#define IPCOMP_SCRATCH_SIZE 65400
8 7
8struct crypto_comp;
9
9struct ipcomp_data { 10struct ipcomp_data {
10 u16 threshold; 11 u16 threshold;
11 struct crypto_comp **tfms; 12 struct crypto_comp **tfms;
12}; 13};
13 14
15struct ip_comp_hdr;
16struct sk_buff;
17
18static inline struct ip_comp_hdr *ip_comp_hdr(const struct sk_buff *skb)
19{
20 return (struct ip_comp_hdr *)skb_transport_header(skb);
21}
22
14#endif 23#endif
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 9059e0ed7fe3..31b3f1b45a2b 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -112,45 +112,28 @@ struct frag_hdr {
112extern int sysctl_ipv6_bindv6only; 112extern int sysctl_ipv6_bindv6only;
113extern int sysctl_mld_max_msf; 113extern int sysctl_mld_max_msf;
114 114
115/* MIBs */ 115#define _DEVINC(statname, modifier, idev, field) \
116DECLARE_SNMP_STAT(struct ipstats_mib, ipv6_statistics); 116({ \
117#define IP6_INC_STATS(idev,field) ({ \
118 struct inet6_dev *_idev = (idev); \
119 if (likely(_idev != NULL)) \
120 SNMP_INC_STATS(_idev->stats.ipv6, field); \
121 SNMP_INC_STATS(ipv6_statistics, field); \
122})
123#define IP6_INC_STATS_BH(idev,field) ({ \
124 struct inet6_dev *_idev = (idev); \
125 if (likely(_idev != NULL)) \
126 SNMP_INC_STATS_BH(_idev->stats.ipv6, field); \
127 SNMP_INC_STATS_BH(ipv6_statistics, field); \
128})
129#define IP6_INC_STATS_USER(idev,field) ({ \
130 struct inet6_dev *_idev = (idev); \ 117 struct inet6_dev *_idev = (idev); \
131 if (likely(_idev != NULL)) \ 118 if (likely(_idev != NULL)) \
132 SNMP_INC_STATS_USER(_idev->stats.ipv6, field); \ 119 SNMP_INC_STATS##modifier((_idev)->stats.statname, (field)); \
133 SNMP_INC_STATS_USER(ipv6_statistics, field); \ 120 SNMP_INC_STATS##modifier(statname##_statistics, (field)); \
134}) 121})
122
123/* MIBs */
124DECLARE_SNMP_STAT(struct ipstats_mib, ipv6_statistics);
125
126#define IP6_INC_STATS(idev,field) _DEVINC(ipv6, , idev, field)
127#define IP6_INC_STATS_BH(idev,field) _DEVINC(ipv6, _BH, idev, field)
128#define IP6_INC_STATS_USER(idev,field) _DEVINC(ipv6, _USER, idev, field)
129
135DECLARE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics); 130DECLARE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics);
136#define ICMP6_INC_STATS(idev, field) ({ \ 131DECLARE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg_statistics);
137 struct inet6_dev *_idev = (idev); \ 132
138 if (likely(_idev != NULL)) \ 133#define ICMP6_INC_STATS(idev, field) _DEVINC(icmpv6, , idev, field)
139 SNMP_INC_STATS(idev->stats.icmpv6, field); \ 134#define ICMP6_INC_STATS_BH(idev, field) _DEVINC(icmpv6, _BH, idev, field)
140 SNMP_INC_STATS(icmpv6_statistics, field); \ 135#define ICMP6_INC_STATS_USER(idev, field) _DEVINC(icmpv6, _USER, idev, field)
141}) 136
142#define ICMP6_INC_STATS_BH(idev, field) ({ \
143 struct inet6_dev *_idev = (idev); \
144 if (likely(_idev != NULL)) \
145 SNMP_INC_STATS_BH((_idev)->stats.icmpv6, field); \
146 SNMP_INC_STATS_BH(icmpv6_statistics, field); \
147})
148#define ICMP6_INC_STATS_USER(idev, field) ({ \
149 struct inet6_dev *_idev = (idev); \
150 if (likely(_idev != NULL)) \
151 SNMP_INC_STATS_USER(_idev->stats.icmpv6, field); \
152 SNMP_INC_STATS_USER(icmpv6_statistics, field); \
153})
154#define ICMP6_INC_STATS_OFFSET_BH(idev, field, offset) ({ \ 137#define ICMP6_INC_STATS_OFFSET_BH(idev, field, offset) ({ \
155 struct inet6_dev *_idev = idev; \ 138 struct inet6_dev *_idev = idev; \
156 __typeof__(offset) _offset = (offset); \ 139 __typeof__(offset) _offset = (offset); \
@@ -158,6 +141,20 @@ DECLARE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics);
158 SNMP_INC_STATS_OFFSET_BH(_idev->stats.icmpv6, field, _offset); \ 141 SNMP_INC_STATS_OFFSET_BH(_idev->stats.icmpv6, field, _offset); \
159 SNMP_INC_STATS_OFFSET_BH(icmpv6_statistics, field, _offset); \ 142 SNMP_INC_STATS_OFFSET_BH(icmpv6_statistics, field, _offset); \
160}) 143})
144
145#define ICMP6MSGOUT_INC_STATS(idev, field) \
146 _DEVINC(icmpv6msg, , idev, field +256)
147#define ICMP6MSGOUT_INC_STATS_BH(idev, field) \
148 _DEVINC(icmpv6msg, _BH, idev, field +256)
149#define ICMP6MSGOUT_INC_STATS_USER(idev, field) \
150 _DEVINC(icmpv6msg, _USER, idev, field +256)
151#define ICMP6MSGIN_INC_STATS(idev, field) \
152 _DEVINC(icmpv6msg, , idev, field)
153#define ICMP6MSGIN_INC_STATS_BH(idev, field) \
154 _DEVINC(icmpv6msg, _BH, idev, field)
155#define ICMP6MSGIN_INC_STATS_USER(idev, field) \
156 _DEVINC(icmpv6msg, _USER, idev, field)
157
161DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6); 158DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6);
162DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6); 159DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6);
163#define UDP6_INC_STATS_BH(field, is_udplite) do { \ 160#define UDP6_INC_STATS_BH(field, is_udplite) do { \
@@ -377,6 +374,12 @@ static inline int ipv6_addr_any(const struct in6_addr *a)
377 a->s6_addr32[2] | a->s6_addr32[3] ) == 0); 374 a->s6_addr32[2] | a->s6_addr32[3] ) == 0);
378} 375}
379 376
377static inline int ipv6_addr_v4mapped(const struct in6_addr *a)
378{
379 return ((a->s6_addr32[0] | a->s6_addr32[1]) == 0 &&
380 a->s6_addr32[2] == htonl(0x0000ffff));
381}
382
380/* 383/*
381 * find the first different bit between two addresses 384 * find the first different bit between two addresses
382 * length of address must be a multiple of 32bits 385 * length of address must be a multiple of 32bits
diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
index b6c468cd7f5b..85f80eadfa35 100644
--- a/include/net/iucv/af_iucv.h
+++ b/include/net/iucv/af_iucv.h
@@ -50,6 +50,12 @@ struct sockaddr_iucv {
50 50
51 51
52/* Common socket structures and functions */ 52/* Common socket structures and functions */
53struct sock_msg_q {
54 struct iucv_path *path;
55 struct iucv_message msg;
56 struct list_head list;
57 spinlock_t lock;
58};
53 59
54#define iucv_sk(__sk) ((struct iucv_sock *) __sk) 60#define iucv_sk(__sk) ((struct iucv_sock *) __sk)
55 61
@@ -65,6 +71,7 @@ struct iucv_sock {
65 struct iucv_path *path; 71 struct iucv_path *path;
66 struct sk_buff_head send_skb_q; 72 struct sk_buff_head send_skb_q;
67 struct sk_buff_head backlog_skb_q; 73 struct sk_buff_head backlog_skb_q;
74 struct sock_msg_q message_q;
68 unsigned int send_tag; 75 unsigned int send_tag;
69}; 76};
70 77
@@ -74,29 +81,8 @@ struct iucv_sock_list {
74 atomic_t autobind_name; 81 atomic_t autobind_name;
75}; 82};
76 83
77static void iucv_sock_destruct(struct sock *sk);
78static void iucv_sock_cleanup_listen(struct sock *parent);
79static void iucv_sock_kill(struct sock *sk);
80static void iucv_sock_close(struct sock *sk);
81static int iucv_sock_create(struct socket *sock, int proto);
82static int iucv_sock_bind(struct socket *sock, struct sockaddr *addr,
83 int addr_len);
84static int iucv_sock_connect(struct socket *sock, struct sockaddr *addr,
85 int alen, int flags);
86static int iucv_sock_listen(struct socket *sock, int backlog);
87static int iucv_sock_accept(struct socket *sock, struct socket *newsock,
88 int flags);
89static int iucv_sock_getname(struct socket *sock, struct sockaddr *addr,
90 int *len, int peer);
91static int iucv_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
92 struct msghdr *msg, size_t len);
93static int iucv_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
94 struct msghdr *msg, size_t len, int flags);
95unsigned int iucv_sock_poll(struct file *file, struct socket *sock, 84unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
96 poll_table *wait); 85 poll_table *wait);
97static int iucv_sock_release(struct socket *sock);
98static int iucv_sock_shutdown(struct socket *sock, int how);
99
100void iucv_sock_link(struct iucv_sock_list *l, struct sock *s); 86void iucv_sock_link(struct iucv_sock_list *l, struct sock *s);
101void iucv_sock_unlink(struct iucv_sock_list *l, struct sock *s); 87void iucv_sock_unlink(struct iucv_sock_list *l, struct sock *s);
102int iucv_sock_wait_state(struct sock *sk, int state, int state2, 88int iucv_sock_wait_state(struct sock *sk, int state, int state2,
diff --git a/include/net/iw_handler.h b/include/net/iw_handler.h
index f23d07ca7c59..369d50e08b99 100644
--- a/include/net/iw_handler.h
+++ b/include/net/iw_handler.h
@@ -431,7 +431,13 @@ struct iw_public_data {
431 * Those may be called only within the kernel. 431 * Those may be called only within the kernel.
432 */ 432 */
433 433
434/* functions that may be called by driver modules */ 434/* First : function strictly used inside the kernel */
435
436/* Handle /proc/net/wireless, called in net/code/dev.c */
437extern int dev_get_wireless_info(char * buffer, char **start, off_t offset,
438 int length);
439
440/* Second : functions that may be called by driver modules */
435 441
436/* Send a single event to user space */ 442/* Send a single event to user space */
437extern void wireless_send_event(struct net_device * dev, 443extern void wireless_send_event(struct net_device * dev,
diff --git a/include/net/llc_conn.h b/include/net/llc_conn.h
index 00730d21b522..e2374e34989f 100644
--- a/include/net/llc_conn.h
+++ b/include/net/llc_conn.h
@@ -93,7 +93,7 @@ static __inline__ char llc_backlog_type(struct sk_buff *skb)
93 return skb->cb[sizeof(skb->cb) - 1]; 93 return skb->cb[sizeof(skb->cb) - 1];
94} 94}
95 95
96extern struct sock *llc_sk_alloc(int family, gfp_t priority, 96extern struct sock *llc_sk_alloc(struct net *net, int family, gfp_t priority,
97 struct proto *prot); 97 struct proto *prot);
98extern void llc_sk_free(struct sock *sk); 98extern void llc_sk_free(struct sock *sk);
99 99
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index c34fd9a6160a..5fcc4c104340 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -1,7 +1,9 @@
1/* 1/*
2 * Low-level hardware driver -- IEEE 802.11 driver (80211.o) interface 2 * mac80211 <-> driver interface
3 *
3 * Copyright 2002-2005, Devicescape Software, Inc. 4 * Copyright 2002-2005, Devicescape Software, Inc.
4 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> 5 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
6 * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
5 * 7 *
6 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as 9 * it under the terms of the GNU General Public License version 2 as
@@ -20,29 +22,51 @@
20#include <net/wireless.h> 22#include <net/wireless.h>
21#include <net/cfg80211.h> 23#include <net/cfg80211.h>
22 24
23/* Note! Only ieee80211_tx_status_irqsafe() and ieee80211_rx_irqsafe() can be 25/**
26 * DOC: Introduction
27 *
28 * mac80211 is the Linux stack for 802.11 hardware that implements
29 * only partial functionality in hard- or firmware. This document
30 * defines the interface between mac80211 and low-level hardware
31 * drivers.
32 */
33
34/**
35 * DOC: Calling mac80211 from interrupts
36 *
37 * Only ieee80211_tx_status_irqsafe() and ieee80211_rx_irqsafe() can be
24 * called in hardware interrupt context. The low-level driver must not call any 38 * called in hardware interrupt context. The low-level driver must not call any
25 * other functions in hardware interrupt context. If there is a need for such 39 * other functions in hardware interrupt context. If there is a need for such
26 * call, the low-level driver should first ACK the interrupt and perform the 40 * call, the low-level driver should first ACK the interrupt and perform the
27 * IEEE 802.11 code call after this, e.g., from a scheduled tasklet (in 41 * IEEE 802.11 code call after this, e.g. from a scheduled workqueue function.
28 * software interrupt context).
29 */ 42 */
30 43
31/* 44/**
32 * Frame format used when passing frame between low-level hardware drivers 45 * DOC: Warning
33 * and IEEE 802.11 driver the same as used in the wireless media, i.e., 46 *
34 * buffers start with IEEE 802.11 header and include the same octets that 47 * If you're reading this document and not the header file itself, it will
35 * are sent over air. 48 * be incomplete because not all documentation has been converted yet.
36 * 49 */
37 * If hardware uses IEEE 802.3 headers (and perform 802.3 <-> 802.11 50
38 * conversion in firmware), upper layer 802.11 code needs to be changed to 51/**
39 * support this. 52 * DOC: Frame format
40 * 53 *
41 * If the receive frame format is not the same as the real frame sent 54 * As a general rule, when frames are passed between mac80211 and the driver,
42 * on the wireless media (e.g., due to padding etc.), upper layer 802.11 code 55 * they start with the IEEE 802.11 header and include the same octets that are
43 * could be updated to provide support for such format assuming this would 56 * sent over the air except for the FCS which should be calculated by the
44 * optimize the performance, e.g., by removing need to re-allocation and 57 * hardware.
45 * copying of the data. 58 *
59 * There are, however, various exceptions to this rule for advanced features:
60 *
61 * The first exception is for hardware encryption and decryption offload
62 * where the IV/ICV may or may not be generated in hardware.
63 *
64 * Secondly, when the hardware handles fragmentation, the frame handed to
65 * the driver from mac80211 is the MSDU, not the MPDU.
66 *
67 * Finally, for received frames, the driver is able to indicate that it has
68 * filled a radiotap header and put that in front of the frame; if it does
69 * not do so then mac80211 may add this under certain circumstances.
46 */ 70 */
47 71
48#define IEEE80211_CHAN_W_SCAN 0x00000001 72#define IEEE80211_CHAN_W_SCAN 0x00000001
@@ -71,14 +95,13 @@ struct ieee80211_channel {
71#define IEEE80211_RATE_SUPPORTED 0x00000010 95#define IEEE80211_RATE_SUPPORTED 0x00000010
72#define IEEE80211_RATE_OFDM 0x00000020 96#define IEEE80211_RATE_OFDM 0x00000020
73#define IEEE80211_RATE_CCK 0x00000040 97#define IEEE80211_RATE_CCK 0x00000040
74#define IEEE80211_RATE_TURBO 0x00000080
75#define IEEE80211_RATE_MANDATORY 0x00000100 98#define IEEE80211_RATE_MANDATORY 0x00000100
76 99
77#define IEEE80211_RATE_CCK_2 (IEEE80211_RATE_CCK | IEEE80211_RATE_PREAMBLE2) 100#define IEEE80211_RATE_CCK_2 (IEEE80211_RATE_CCK | IEEE80211_RATE_PREAMBLE2)
78#define IEEE80211_RATE_MODULATION(f) \ 101#define IEEE80211_RATE_MODULATION(f) \
79 (f & (IEEE80211_RATE_CCK | IEEE80211_RATE_OFDM)) 102 (f & (IEEE80211_RATE_CCK | IEEE80211_RATE_OFDM))
80 103
81/* Low-level driver should set PREAMBLE2, OFDM, CCK, and TURBO flags. 104/* Low-level driver should set PREAMBLE2, OFDM and CCK flags.
82 * BASIC, SUPPORTED, ERP, and MANDATORY flags are set in 80211.o based on the 105 * BASIC, SUPPORTED, ERP, and MANDATORY flags are set in 80211.o based on the
83 * configuration. */ 106 * configuration. */
84struct ieee80211_rate { 107struct ieee80211_rate {
@@ -97,44 +120,96 @@ struct ieee80211_rate {
97 * optimizing channel utilization estimates */ 120 * optimizing channel utilization estimates */
98}; 121};
99 122
100/* 802.11g is backwards-compatible with 802.11b, so a wlan card can 123/**
101 * actually be both in 11b and 11g modes at the same time. */ 124 * enum ieee80211_phymode - PHY modes
102enum { 125 *
103 MODE_IEEE80211A, /* IEEE 802.11a */ 126 * @MODE_IEEE80211A: 5GHz as defined by 802.11a/802.11h
104 MODE_IEEE80211B, /* IEEE 802.11b only */ 127 * @MODE_IEEE80211B: 2.4 GHz as defined by 802.11b
105 MODE_ATHEROS_TURBO, /* Atheros Turbo mode (2x.11a at 5 GHz) */ 128 * @MODE_IEEE80211G: 2.4 GHz as defined by 802.11g (with OFDM),
106 MODE_IEEE80211G, /* IEEE 802.11g (and 802.11b compatibility) */ 129 * backwards compatible with 11b mode
107 MODE_ATHEROS_TURBOG, /* Atheros Turbo mode (2x.11g at 2.4 GHz) */ 130 * @NUM_IEEE80211_MODES: internal
131 */
132enum ieee80211_phymode {
133 MODE_IEEE80211A,
134 MODE_IEEE80211B,
135 MODE_IEEE80211G,
108 136
109 /* keep last */ 137 /* keep last */
110 NUM_IEEE80211_MODES 138 NUM_IEEE80211_MODES
111}; 139};
112 140
141/**
142 * struct ieee80211_hw_mode - PHY mode definition
143 *
144 * This structure describes the capabilities supported by the device
145 * in a single PHY mode.
146 *
147 * @mode: the PHY mode for this definition
148 * @num_channels: number of supported channels
149 * @channels: pointer to array of supported channels
150 * @num_rates: number of supported bitrates
151 * @rates: pointer to array of supported bitrates
152 * @list: internal
153 */
113struct ieee80211_hw_mode { 154struct ieee80211_hw_mode {
114 int mode; /* MODE_IEEE80211... */ 155 struct list_head list;
115 int num_channels; /* Number of channels (below) */ 156 struct ieee80211_channel *channels;
116 struct ieee80211_channel *channels; /* Array of supported channels */ 157 struct ieee80211_rate *rates;
117 int num_rates; /* Number of rates (below) */ 158 enum ieee80211_phymode mode;
118 struct ieee80211_rate *rates; /* Array of supported rates */ 159 int num_channels;
119 160 int num_rates;
120 struct list_head list; /* Internal, don't touch */
121}; 161};
122 162
163/**
164 * struct ieee80211_tx_queue_params - transmit queue configuration
165 *
166 * The information provided in this structure is required for QoS
167 * transmit queue configuration.
168 *
169 * @aifs: arbitration interface space [0..255, -1: use default]
170 * @cw_min: minimum contention window [will be a value of the form
171 * 2^n-1 in the range 1..1023; 0: use default]
172 * @cw_max: maximum contention window [like @cw_min]
173 * @burst_time: maximum burst time in units of 0.1ms, 0 meaning disabled
174 */
123struct ieee80211_tx_queue_params { 175struct ieee80211_tx_queue_params {
124 int aifs; /* 0 .. 255; -1 = use default */ 176 int aifs;
125 int cw_min; /* 2^n-1: 1, 3, 7, .. , 1023; 0 = use default */ 177 int cw_min;
126 int cw_max; /* 2^n-1: 1, 3, 7, .. , 1023; 0 = use default */ 178 int cw_max;
127 int burst_time; /* maximum burst time in 0.1 ms (i.e., 10 = 1 ms); 179 int burst_time;
128 * 0 = disabled */
129}; 180};
130 181
182/**
183 * struct ieee80211_tx_queue_stats_data - transmit queue statistics
184 *
185 * @len: number of packets in queue
186 * @limit: queue length limit
187 * @count: number of frames sent
188 */
131struct ieee80211_tx_queue_stats_data { 189struct ieee80211_tx_queue_stats_data {
132 unsigned int len; /* num packets in queue */ 190 unsigned int len;
133 unsigned int limit; /* queue len (soft) limit */ 191 unsigned int limit;
134 unsigned int count; /* total num frames sent */ 192 unsigned int count;
135}; 193};
136 194
137enum { 195/**
196 * enum ieee80211_tx_queue - transmit queue number
197 *
198 * These constants are used with some callbacks that take a
199 * queue number to set parameters for a queue.
200 *
201 * @IEEE80211_TX_QUEUE_DATA0: data queue 0
202 * @IEEE80211_TX_QUEUE_DATA1: data queue 1
203 * @IEEE80211_TX_QUEUE_DATA2: data queue 2
204 * @IEEE80211_TX_QUEUE_DATA3: data queue 3
205 * @IEEE80211_TX_QUEUE_DATA4: data queue 4
206 * @IEEE80211_TX_QUEUE_SVP: ??
207 * @NUM_TX_DATA_QUEUES: number of data queues
208 * @IEEE80211_TX_QUEUE_AFTER_BEACON: transmit queue for frames to be
209 * sent after a beacon
210 * @IEEE80211_TX_QUEUE_BEACON: transmit queue for beacon frames
211 */
212enum ieee80211_tx_queue {
138 IEEE80211_TX_QUEUE_DATA0, 213 IEEE80211_TX_QUEUE_DATA0,
139 IEEE80211_TX_QUEUE_DATA1, 214 IEEE80211_TX_QUEUE_DATA1,
140 IEEE80211_TX_QUEUE_DATA2, 215 IEEE80211_TX_QUEUE_DATA2,
@@ -165,7 +240,6 @@ struct ieee80211_low_level_stats {
165/* Transmit control fields. This data structure is passed to low-level driver 240/* Transmit control fields. This data structure is passed to low-level driver
166 * with each TX frame. The low-level driver is responsible for configuring 241 * with each TX frame. The low-level driver is responsible for configuring
167 * the hardware to use given values (depending on what is supported). */ 242 * the hardware to use given values (depending on what is supported). */
168#define HW_KEY_IDX_INVALID -1
169 243
170struct ieee80211_tx_control { 244struct ieee80211_tx_control {
171 int tx_rate; /* Transmit rate, given as the hw specific value for the 245 int tx_rate; /* Transmit rate, given as the hw specific value for the
@@ -191,22 +265,23 @@ struct ieee80211_tx_control {
191#define IEEE80211_TXCTL_REQUEUE (1<<7) 265#define IEEE80211_TXCTL_REQUEUE (1<<7)
192#define IEEE80211_TXCTL_FIRST_FRAGMENT (1<<8) /* this is a first fragment of 266#define IEEE80211_TXCTL_FIRST_FRAGMENT (1<<8) /* this is a first fragment of
193 * the frame */ 267 * the frame */
194#define IEEE80211_TXCTL_TKIP_NEW_PHASE1_KEY (1<<9) 268#define IEEE80211_TXCTL_LONG_RETRY_LIMIT (1<<10) /* this frame should be send
269 * using the through
270 * set_retry_limit configured
271 * long retry value */
195 u32 flags; /* tx control flags defined 272 u32 flags; /* tx control flags defined
196 * above */ 273 * above */
197 u8 retry_limit; /* 1 = only first attempt, 2 = one retry, .. */ 274 u8 key_idx; /* keyidx from hw->set_key(), undefined if
275 * IEEE80211_TXCTL_DO_NOT_ENCRYPT is set */
276 u8 retry_limit; /* 1 = only first attempt, 2 = one retry, ..
277 * This could be used when set_retry_limit
278 * is not implemented by the driver */
198 u8 power_level; /* per-packet transmit power level, in dBm */ 279 u8 power_level; /* per-packet transmit power level, in dBm */
199 u8 antenna_sel_tx; /* 0 = default/diversity, 1 = Ant0, 2 = Ant1 */ 280 u8 antenna_sel_tx; /* 0 = default/diversity, 1 = Ant0, 2 = Ant1 */
200 s8 key_idx; /* -1 = do not encrypt, >= 0 keyidx from
201 * hw->set_key() */
202 u8 icv_len; /* length of the ICV/MIC field in octets */ 281 u8 icv_len; /* length of the ICV/MIC field in octets */
203 u8 iv_len; /* length of the IV field in octets */ 282 u8 iv_len; /* length of the IV field in octets */
204 u8 tkip_key[16]; /* generated phase2/phase1 key for hw TKIP */
205 u8 queue; /* hardware queue to use for this frame; 283 u8 queue; /* hardware queue to use for this frame;
206 * 0 = highest, hw->queues-1 = lowest */ 284 * 0 = highest, hw->queues-1 = lowest */
207 u8 sw_retry_attempt; /* number of times hw has tried to
208 * transmit frame (not incl. hw retries) */
209
210 struct ieee80211_rate *rate; /* internal 80211.o rate */ 285 struct ieee80211_rate *rate; /* internal 80211.o rate */
211 struct ieee80211_rate *rts_rate; /* internal 80211.o rate 286 struct ieee80211_rate *rts_rate; /* internal 80211.o rate
212 * for RTS/CTS */ 287 * for RTS/CTS */
@@ -219,44 +294,124 @@ struct ieee80211_tx_control {
219 int ifindex; /* internal */ 294 int ifindex; /* internal */
220}; 295};
221 296
222/* Receive status. The low-level driver should provide this information 297
223 * (the subset supported by hardware) to the 802.11 code with each received 298/**
224 * frame. */ 299 * enum mac80211_rx_flags - receive flags
300 *
301 * These flags are used with the @flag member of &struct ieee80211_rx_status.
302 * @RX_FLAG_MMIC_ERROR: Michael MIC error was reported on this frame.
303 * Use together with %RX_FLAG_MMIC_STRIPPED.
304 * @RX_FLAG_DECRYPTED: This frame was decrypted in hardware.
305 * @RX_FLAG_RADIOTAP: This frame starts with a radiotap header.
306 * @RX_FLAG_MMIC_STRIPPED: the Michael MIC is stripped off this frame,
307 * verification has been done by the hardware.
308 * @RX_FLAG_IV_STRIPPED: The IV/ICV are stripped from this frame.
309 * If this flag is set, the stack cannot do any replay detection
310 * hence the driver or hardware will have to do that.
311 * @RX_FLAG_FAILED_FCS_CRC: Set this flag if the FCS check failed on
312 * the frame.
313 * @RX_FLAG_FAILED_PLCP_CRC: Set this flag if the PCLP check failed on
314 * the frame.
315 */
316enum mac80211_rx_flags {
317 RX_FLAG_MMIC_ERROR = 1<<0,
318 RX_FLAG_DECRYPTED = 1<<1,
319 RX_FLAG_RADIOTAP = 1<<2,
320 RX_FLAG_MMIC_STRIPPED = 1<<3,
321 RX_FLAG_IV_STRIPPED = 1<<4,
322 RX_FLAG_FAILED_FCS_CRC = 1<<5,
323 RX_FLAG_FAILED_PLCP_CRC = 1<<6,
324};
325
326/**
327 * struct ieee80211_rx_status - receive status
328 *
329 * The low-level driver should provide this information (the subset
330 * supported by hardware) to the 802.11 code with each received
331 * frame.
332 * @mactime: MAC timestamp as defined by 802.11
333 * @freq: frequency the radio was tuned to when receiving this frame, in MHz
334 * @channel: channel the radio was tuned to
335 * @phymode: active PHY mode
336 * @ssi: signal strength when receiving this frame
337 * @signal: used as 'qual' in statistics reporting
338 * @noise: PHY noise when receiving this frame
339 * @antenna: antenna used
340 * @rate: data rate
341 * @flag: %RX_FLAG_*
342 */
225struct ieee80211_rx_status { 343struct ieee80211_rx_status {
226 u64 mactime; 344 u64 mactime;
227 int freq; /* receive frequency in Mhz */ 345 int freq;
228 int channel; 346 int channel;
229 int phymode; 347 enum ieee80211_phymode phymode;
230 int ssi; 348 int ssi;
231 int signal; /* used as qual in statistics reporting */ 349 int signal;
232 int noise; 350 int noise;
233 int antenna; 351 int antenna;
234 int rate; 352 int rate;
235#define RX_FLAG_MMIC_ERROR (1<<0)
236#define RX_FLAG_DECRYPTED (1<<1)
237#define RX_FLAG_RADIOTAP (1<<2)
238 int flag; 353 int flag;
239}; 354};
240 355
241/* Transmit status. The low-level driver should provide this information 356/**
242 * (the subset supported by hardware) to the 802.11 code for each transmit 357 * enum ieee80211_tx_status_flags - transmit status flags
243 * frame. */ 358 *
359 * Status flags to indicate various transmit conditions.
360 *
361 * @IEEE80211_TX_STATUS_TX_FILTERED: The frame was not transmitted
362 * because the destination STA was in powersave mode.
363 *
364 * @IEEE80211_TX_STATUS_ACK: Frame was acknowledged
365 */
366enum ieee80211_tx_status_flags {
367 IEEE80211_TX_STATUS_TX_FILTERED = 1<<0,
368 IEEE80211_TX_STATUS_ACK = 1<<1,
369};
370
371/**
372 * struct ieee80211_tx_status - transmit status
373 *
374 * As much information as possible should be provided for each transmitted
375 * frame with ieee80211_tx_status().
376 *
377 * @control: a copy of the &struct ieee80211_tx_control passed to the driver
378 * in the tx() callback.
379 *
380 * @flags: transmit status flags, defined above
381 *
382 * @ack_signal: signal strength of the ACK frame
383 *
384 * @excessive_retries: set to 1 if the frame was retried many times
385 * but not acknowledged
386 *
387 * @retry_count: number of retries
388 *
389 * @queue_length: ?? REMOVE
390 * @queue_number: ?? REMOVE
391 */
244struct ieee80211_tx_status { 392struct ieee80211_tx_status {
245 /* copied ieee80211_tx_control structure */
246 struct ieee80211_tx_control control; 393 struct ieee80211_tx_control control;
247 394 u8 flags;
248#define IEEE80211_TX_STATUS_TX_FILTERED (1<<0) 395 bool excessive_retries;
249#define IEEE80211_TX_STATUS_ACK (1<<1) /* whether the TX frame was ACKed */ 396 u8 retry_count;
250 u32 flags; /* tx staus flags defined above */ 397 int ack_signal;
251 398 int queue_length;
252 int ack_signal; /* measured signal strength of the ACK frame */
253 int excessive_retries;
254 int retry_count;
255
256 int queue_length; /* information about TX queue */
257 int queue_number; 399 int queue_number;
258}; 400};
259 401
402/**
403 * enum ieee80211_conf_flags - configuration flags
404 *
405 * Flags to define PHY configuration options
406 *
407 * @IEEE80211_CONF_SHORT_SLOT_TIME: use 802.11g short slot time
408 * @IEEE80211_CONF_RADIOTAP: add radiotap header at receive time (if supported)
409 *
410 */
411enum ieee80211_conf_flags {
412 IEEE80211_CONF_SHORT_SLOT_TIME = 1<<0,
413 IEEE80211_CONF_RADIOTAP = 1<<1,
414};
260 415
261/** 416/**
262 * struct ieee80211_conf - configuration of the device 417 * struct ieee80211_conf - configuration of the device
@@ -264,57 +419,46 @@ struct ieee80211_tx_status {
264 * This struct indicates how the driver shall configure the hardware. 419 * This struct indicates how the driver shall configure the hardware.
265 * 420 *
266 * @radio_enabled: when zero, driver is required to switch off the radio. 421 * @radio_enabled: when zero, driver is required to switch off the radio.
422 * TODO make a flag
423 * @channel: IEEE 802.11 channel number
424 * @freq: frequency in MHz
425 * @channel_val: hardware specific channel value for the channel
426 * @phymode: PHY mode to activate (REMOVE)
427 * @chan: channel to switch to, pointer to the channel information
428 * @mode: pointer to mode definition
429 * @regulatory_domain: ??
430 * @beacon_int: beacon interval (TODO make interface config)
431 * @flags: configuration flags defined above
432 * @power_level: transmit power limit for current regulatory domain in dBm
433 * @antenna_max: maximum antenna gain
434 * @antenna_sel_tx: transmit antenna selection, 0: default/diversity,
435 * 1/2: antenna 0/1
436 * @antenna_sel_rx: receive antenna selection, like @antenna_sel_tx
267 */ 437 */
268struct ieee80211_conf { 438struct ieee80211_conf {
269 int channel; /* IEEE 802.11 channel number */ 439 int channel; /* IEEE 802.11 channel number */
270 int freq; /* MHz */ 440 int freq; /* MHz */
271 int channel_val; /* hw specific value for the channel */ 441 int channel_val; /* hw specific value for the channel */
272 442
273 int phymode; /* MODE_IEEE80211A, .. */ 443 enum ieee80211_phymode phymode;
274 struct ieee80211_channel *chan; 444 struct ieee80211_channel *chan;
275 struct ieee80211_hw_mode *mode; 445 struct ieee80211_hw_mode *mode;
276 unsigned int regulatory_domain; 446 unsigned int regulatory_domain;
277 int radio_enabled; 447 int radio_enabled;
278 448
279 int beacon_int; 449 int beacon_int;
280 450 u32 flags;
281#define IEEE80211_CONF_SHORT_SLOT_TIME (1<<0) /* use IEEE 802.11g Short Slot 451 u8 power_level;
282 * Time */ 452 u8 antenna_max;
283#define IEEE80211_CONF_SSID_HIDDEN (1<<1) /* do not broadcast the ssid */
284#define IEEE80211_CONF_RADIOTAP (1<<2) /* use radiotap if supported
285 check this bit at RX time */
286 u32 flags; /* configuration flags defined above */
287
288 u8 power_level; /* transmit power limit for current
289 * regulatory domain; in dBm */
290 u8 antenna_max; /* maximum antenna gain */
291 short tx_power_reduction; /* in 0.1 dBm */
292
293 /* 0 = default/diversity, 1 = Ant0, 2 = Ant1 */
294 u8 antenna_sel_tx; 453 u8 antenna_sel_tx;
295 u8 antenna_sel_rx; 454 u8 antenna_sel_rx;
296
297 int antenna_def;
298 int antenna_mode;
299
300 /* Following five fields are used for IEEE 802.11H */
301 unsigned int radar_detect;
302 unsigned int spect_mgmt;
303 /* All following fields are currently unused. */
304 unsigned int quiet_duration; /* duration of quiet period */
305 unsigned int quiet_offset; /* how far into the beacon is the quiet
306 * period */
307 unsigned int quiet_period;
308 u8 radar_firpwr_threshold;
309 u8 radar_rssi_threshold;
310 u8 pulse_height_threshold;
311 u8 pulse_rssi_threshold;
312 u8 pulse_inband_threshold;
313}; 455};
314 456
315/** 457/**
316 * enum ieee80211_if_types - types of 802.11 network interfaces 458 * enum ieee80211_if_types - types of 802.11 network interfaces
317 * 459 *
460 * @IEEE80211_IF_TYPE_INVALID: invalid interface type, not used
461 * by mac80211 itself
318 * @IEEE80211_IF_TYPE_AP: interface in AP mode. 462 * @IEEE80211_IF_TYPE_AP: interface in AP mode.
319 * @IEEE80211_IF_TYPE_MGMT: special interface for communication with hostap 463 * @IEEE80211_IF_TYPE_MGMT: special interface for communication with hostap
320 * daemon. Drivers should never see this type. 464 * daemon. Drivers should never see this type.
@@ -322,16 +466,17 @@ struct ieee80211_conf {
322 * @IEEE80211_IF_TYPE_IBSS: interface in IBSS (ad-hoc) mode. 466 * @IEEE80211_IF_TYPE_IBSS: interface in IBSS (ad-hoc) mode.
323 * @IEEE80211_IF_TYPE_MNTR: interface in monitor (rfmon) mode. 467 * @IEEE80211_IF_TYPE_MNTR: interface in monitor (rfmon) mode.
324 * @IEEE80211_IF_TYPE_WDS: interface in WDS mode. 468 * @IEEE80211_IF_TYPE_WDS: interface in WDS mode.
325 * @IEEE80211_IF_TYPE_VLAN: not used. 469 * @IEEE80211_IF_TYPE_VLAN: VLAN interface bound to an AP, drivers
470 * will never see this type.
326 */ 471 */
327enum ieee80211_if_types { 472enum ieee80211_if_types {
328 IEEE80211_IF_TYPE_AP = 0x00000000, 473 IEEE80211_IF_TYPE_INVALID,
329 IEEE80211_IF_TYPE_MGMT = 0x00000001, 474 IEEE80211_IF_TYPE_AP,
330 IEEE80211_IF_TYPE_STA = 0x00000002, 475 IEEE80211_IF_TYPE_STA,
331 IEEE80211_IF_TYPE_IBSS = 0x00000003, 476 IEEE80211_IF_TYPE_IBSS,
332 IEEE80211_IF_TYPE_MNTR = 0x00000004, 477 IEEE80211_IF_TYPE_MNTR,
333 IEEE80211_IF_TYPE_WDS = 0x5A580211, 478 IEEE80211_IF_TYPE_WDS,
334 IEEE80211_IF_TYPE_VLAN = 0x00080211, 479 IEEE80211_IF_TYPE_VLAN,
335}; 480};
336 481
337/** 482/**
@@ -347,7 +492,6 @@ enum ieee80211_if_types {
347 * @mac_addr: pointer to MAC address of the interface. This pointer is valid 492 * @mac_addr: pointer to MAC address of the interface. This pointer is valid
348 * until the interface is removed (i.e. it cannot be used after 493 * until the interface is removed (i.e. it cannot be used after
349 * remove_interface() callback was called for this interface). 494 * remove_interface() callback was called for this interface).
350 * This pointer will be %NULL for monitor interfaces, be careful.
351 * 495 *
352 * This structure is used in add_interface() and remove_interface() 496 * This structure is used in add_interface() and remove_interface()
353 * callbacks of &struct ieee80211_hw. 497 * callbacks of &struct ieee80211_hw.
@@ -360,7 +504,7 @@ enum ieee80211_if_types {
360 */ 504 */
361struct ieee80211_if_init_conf { 505struct ieee80211_if_init_conf {
362 int if_id; 506 int if_id;
363 int type; 507 enum ieee80211_if_types type;
364 void *mac_addr; 508 void *mac_addr;
365}; 509};
366 510
@@ -377,11 +521,6 @@ struct ieee80211_if_init_conf {
377 * config_interface() call, so copy the value somewhere if you need 521 * config_interface() call, so copy the value somewhere if you need
378 * it. 522 * it.
379 * @ssid_len: length of the @ssid field. 523 * @ssid_len: length of the @ssid field.
380 * @generic_elem: used (together with @generic_elem_len) by drivers for
381 * hardware that generate beacons independently. The pointer is valid
382 * only during the config_interface() call, so copy the value somewhere
383 * if you need it.
384 * @generic_elem_len: length of the generic element.
385 * @beacon: beacon template. Valid only if @host_gen_beacon_template in 524 * @beacon: beacon template. Valid only if @host_gen_beacon_template in
386 * &struct ieee80211_hw is set. The driver is responsible of freeing 525 * &struct ieee80211_hw is set. The driver is responsible of freeing
387 * the sk_buff. 526 * the sk_buff.
@@ -396,368 +535,571 @@ struct ieee80211_if_conf {
396 u8 *bssid; 535 u8 *bssid;
397 u8 *ssid; 536 u8 *ssid;
398 size_t ssid_len; 537 size_t ssid_len;
399 u8 *generic_elem;
400 size_t generic_elem_len;
401 struct sk_buff *beacon; 538 struct sk_buff *beacon;
402 struct ieee80211_tx_control *beacon_control; 539 struct ieee80211_tx_control *beacon_control;
403}; 540};
404 541
405typedef enum { ALG_NONE, ALG_WEP, ALG_TKIP, ALG_CCMP, ALG_NULL } 542/**
406ieee80211_key_alg; 543 * enum ieee80211_key_alg - key algorithm
544 * @ALG_WEP: WEP40 or WEP104
545 * @ALG_TKIP: TKIP
546 * @ALG_CCMP: CCMP (AES)
547 */
548enum ieee80211_key_alg {
549 ALG_WEP,
550 ALG_TKIP,
551 ALG_CCMP,
552};
407 553
408 554
409struct ieee80211_key_conf { 555/**
556 * enum ieee80211_key_flags - key flags
557 *
558 * These flags are used for communication about keys between the driver
559 * and mac80211, with the @flags parameter of &struct ieee80211_key_conf.
560 *
561 * @IEEE80211_KEY_FLAG_WMM_STA: Set by mac80211, this flag indicates
562 * that the STA this key will be used with could be using QoS.
563 * @IEEE80211_KEY_FLAG_GENERATE_IV: This flag should be set by the
564 * driver to indicate that it requires IV generation for this
565 * particular key.
566 * @IEEE80211_KEY_FLAG_GENERATE_MMIC: This flag should be set by
567 * the driver for a TKIP key if it requires Michael MIC
568 * generation in software.
569 */
570enum ieee80211_key_flags {
571 IEEE80211_KEY_FLAG_WMM_STA = 1<<0,
572 IEEE80211_KEY_FLAG_GENERATE_IV = 1<<1,
573 IEEE80211_KEY_FLAG_GENERATE_MMIC= 1<<2,
574};
410 575
411 int hw_key_idx; /* filled + used by low-level driver */ 576/**
412 ieee80211_key_alg alg; 577 * struct ieee80211_key_conf - key information
413 int keylen; 578 *
414 579 * This key information is given by mac80211 to the driver by
415#define IEEE80211_KEY_FORCE_SW_ENCRYPT (1<<0) /* to be cleared by low-level 580 * the set_key() callback in &struct ieee80211_ops.
416 driver */ 581 *
417#define IEEE80211_KEY_DEFAULT_TX_KEY (1<<1) /* This key is the new default TX 582 * @hw_key_idx: To be set by the driver, this is the key index the driver
418 key (used only for broadcast 583 * wants to be given when a frame is transmitted and needs to be
419 keys). */ 584 * encrypted in hardware.
420#define IEEE80211_KEY_DEFAULT_WEP_ONLY (1<<2) /* static WEP is the only 585 * @alg: The key algorithm.
421 configured security policy; 586 * @flags: key flags, see &enum ieee80211_key_flags.
422 this allows some low-level 587 * @keyidx: the key index (0-3)
423 drivers to determine when 588 * @keylen: key material length
424 hwaccel can be used */ 589 * @key: key material
425 u32 flags; /* key configuration flags defined above */ 590 */
426 591struct ieee80211_key_conf {
427 s8 keyidx; /* WEP key index */ 592 enum ieee80211_key_alg alg;
593 u8 hw_key_idx;
594 u8 flags;
595 s8 keyidx;
596 u8 keylen;
428 u8 key[0]; 597 u8 key[0];
429}; 598};
430 599
431#define IEEE80211_SEQ_COUNTER_RX 0 600#define IEEE80211_SEQ_COUNTER_RX 0
432#define IEEE80211_SEQ_COUNTER_TX 1 601#define IEEE80211_SEQ_COUNTER_TX 1
433 602
434typedef enum { 603/**
435 SET_KEY, DISABLE_KEY, REMOVE_ALL_KEYS, 604 * enum set_key_cmd - key command
436} set_key_cmd; 605 *
606 * Used with the set_key() callback in &struct ieee80211_ops, this
607 * indicates whether a key is being removed or added.
608 *
609 * @SET_KEY: a key is set
610 * @DISABLE_KEY: a key must be disabled
611 */
612enum set_key_cmd {
613 SET_KEY, DISABLE_KEY,
614};
437 615
438/* This is driver-visible part of the per-hw state the stack keeps. */ 616/**
439struct ieee80211_hw { 617 * enum sta_notify_cmd - sta notify command
440 /* points to the cfg80211 wiphy for this piece. Note 618 *
441 * that you must fill in the perm_addr and dev fields 619 * Used with the sta_notify() callback in &struct ieee80211_ops, this
442 * of this structure, use the macros provided below. */ 620 * indicates addition and removal of a station to station table
443 struct wiphy *wiphy; 621 *
622 * @STA_NOTIFY_ADD: a station was added to the station table
623 * @STA_NOTIFY_REMOVE: a station being removed from the station table
624 */
625enum sta_notify_cmd {
626 STA_NOTIFY_ADD, STA_NOTIFY_REMOVE
627};
444 628
445 /* assigned by mac80211, don't write */ 629/**
446 struct ieee80211_conf conf; 630 * enum ieee80211_hw_flags - hardware flags
631 *
632 * These flags are used to indicate hardware capabilities to
633 * the stack. Generally, flags here should have their meaning
634 * done in a way that the simplest hardware doesn't need setting
635 * any particular flags. There are some exceptions to this rule,
636 * however, so you are advised to review these flags carefully.
637 *
638 * @IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE:
639 * The device only needs to be supplied with a beacon template.
640 * If you need the host to generate each beacon then don't use
641 * this flag and call ieee80211_beacon_get() when you need the
642 * next beacon frame. Note that if you set this flag, you must
643 * implement the set_tim() callback for powersave mode to work
644 * properly.
645 * This flag is only relevant for access-point mode.
646 *
647 * @IEEE80211_HW_RX_INCLUDES_FCS:
648 * Indicates that received frames passed to the stack include
649 * the FCS at the end.
650 *
651 * @IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING:
652 * Some wireless LAN chipsets buffer broadcast/multicast frames
653 * for power saving stations in the hardware/firmware and others
654 * rely on the host system for such buffering. This option is used
655 * to configure the IEEE 802.11 upper layer to buffer broadcast and
656 * multicast frames when there are power saving stations so that
657 * the driver can fetch them with ieee80211_get_buffered_bc(). Note
658 * that not setting this flag works properly only when the
659 * %IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE is also not set because
660 * otherwise the stack will not know when the DTIM beacon was sent.
661 *
662 * @IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED:
663 * Channels are already configured to the default regulatory domain
664 * specified in the device's EEPROM
665 */
666enum ieee80211_hw_flags {
667 IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE = 1<<0,
668 IEEE80211_HW_RX_INCLUDES_FCS = 1<<1,
669 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING = 1<<2,
670 IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED = 1<<3,
671};
447 672
448 /* Single thread workqueue available for driver use 673/**
449 * Allocated by mac80211 on registration */ 674 * struct ieee80211_hw - hardware information and state
675 *
676 * This structure contains the configuration and hardware
677 * information for an 802.11 PHY.
678 *
679 * @wiphy: This points to the &struct wiphy allocated for this
680 * 802.11 PHY. You must fill in the @perm_addr and @dev
681 * members of this structure using SET_IEEE80211_DEV()
682 * and SET_IEEE80211_PERM_ADDR().
683 *
684 * @conf: &struct ieee80211_conf, device configuration, don't use.
685 *
686 * @workqueue: single threaded workqueue available for driver use,
687 * allocated by mac80211 on registration and flushed on
688 * unregistration.
689 *
690 * @priv: pointer to private area that was allocated for driver use
691 * along with this structure.
692 *
693 * @flags: hardware flags, see &enum ieee80211_hw_flags.
694 *
695 * @extra_tx_headroom: headroom to reserve in each transmit skb
696 * for use by the driver (e.g. for transmit headers.)
697 *
698 * @channel_change_time: time (in microseconds) it takes to change channels.
699 *
700 * @max_rssi: Maximum value for ssi in RX information, use
701 * negative numbers for dBm and 0 to indicate no support.
702 *
703 * @max_signal: like @max_rssi, but for the signal value.
704 *
705 * @max_noise: like @max_rssi, but for the noise value.
706 *
707 * @queues: number of available hardware transmit queues for
708 * data packets. WMM/QoS requires at least four.
709 */
710struct ieee80211_hw {
711 struct ieee80211_conf conf;
712 struct wiphy *wiphy;
450 struct workqueue_struct *workqueue; 713 struct workqueue_struct *workqueue;
451
452 /* Pointer to the private area that was
453 * allocated with this struct for you. */
454 void *priv; 714 void *priv;
455 715 u32 flags;
456 /* The rest is information about your hardware */
457
458 /* TODO: frame_type 802.11/802.3, sw_encryption requirements */
459
460 /* Some wireless LAN chipsets generate beacons in the hardware/firmware
461 * and others rely on host generated beacons. This option is used to
462 * configure the upper layer IEEE 802.11 module to generate beacons.
463 * The low-level driver can use ieee80211_beacon_get() to fetch the
464 * next beacon frame. */
465#define IEEE80211_HW_HOST_GEN_BEACON (1<<0)
466
467 /* The device needs to be supplied with a beacon template only. */
468#define IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE (1<<1)
469
470 /* Some devices handle decryption internally and do not
471 * indicate whether the frame was encrypted (unencrypted frames
472 * will be dropped by the hardware, unless specifically allowed
473 * through) */
474#define IEEE80211_HW_DEVICE_HIDES_WEP (1<<2)
475
476 /* Whether RX frames passed to ieee80211_rx() include FCS in the end */
477#define IEEE80211_HW_RX_INCLUDES_FCS (1<<3)
478
479 /* Some wireless LAN chipsets buffer broadcast/multicast frames for
480 * power saving stations in the hardware/firmware and others rely on
481 * the host system for such buffering. This option is used to
482 * configure the IEEE 802.11 upper layer to buffer broadcast/multicast
483 * frames when there are power saving stations so that low-level driver
484 * can fetch them with ieee80211_get_buffered_bc(). */
485#define IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING (1<<4)
486
487#define IEEE80211_HW_WEP_INCLUDE_IV (1<<5)
488
489 /* will data nullfunc frames get proper TX status callback */
490#define IEEE80211_HW_DATA_NULLFUNC_ACK (1<<6)
491
492 /* Force software encryption for TKIP packets if WMM is enabled. */
493#define IEEE80211_HW_NO_TKIP_WMM_HWACCEL (1<<7)
494
495 /* Some devices handle Michael MIC internally and do not include MIC in
496 * the received packets passed up. device_strips_mic must be set
497 * for such devices. The 'encryption' frame control bit is expected to
498 * be still set in the IEEE 802.11 header with this option unlike with
499 * the device_hides_wep configuration option.
500 */
501#define IEEE80211_HW_DEVICE_STRIPS_MIC (1<<8)
502
503 /* Device is capable of performing full monitor mode even during
504 * normal operation. */
505#define IEEE80211_HW_MONITOR_DURING_OPER (1<<9)
506
507 /* Device does not need BSSID filter set to broadcast in order to
508 * receive all probe responses while scanning */
509#define IEEE80211_HW_NO_PROBE_FILTERING (1<<10)
510
511 /* Channels are already configured to the default regulatory domain
512 * specified in the device's EEPROM */
513#define IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED (1<<11)
514
515 /* calculate Michael MIC for an MSDU when doing hwcrypto */
516#define IEEE80211_HW_TKIP_INCLUDE_MMIC (1<<12)
517 /* Do TKIP phase1 key mixing in stack to support cards only do
518 * phase2 key mixing when doing hwcrypto */
519#define IEEE80211_HW_TKIP_REQ_PHASE1_KEY (1<<13)
520 /* Do TKIP phase1 and phase2 key mixing in stack and send the generated
521 * per-packet RC4 key with each TX frame when doing hwcrypto */
522#define IEEE80211_HW_TKIP_REQ_PHASE2_KEY (1<<14)
523
524 u32 flags; /* hardware flags defined above */
525
526 /* Set to the size of a needed device specific skb headroom for TX skbs. */
527 unsigned int extra_tx_headroom; 716 unsigned int extra_tx_headroom;
528
529 /* This is the time in us to change channels
530 */
531 int channel_change_time; 717 int channel_change_time;
532 /* Maximum values for various statistics. 718 u8 queues;
533 * Leave at 0 to indicate no support. Use negative numbers for dBm. */
534 s8 max_rssi; 719 s8 max_rssi;
535 s8 max_signal; 720 s8 max_signal;
536 s8 max_noise; 721 s8 max_noise;
537
538 /* Number of available hardware TX queues for data packets.
539 * WMM requires at least four queues. */
540 int queues;
541}; 722};
542 723
724/**
725 * SET_IEEE80211_DEV - set device for 802.11 hardware
726 *
727 * @hw: the &struct ieee80211_hw to set the device for
728 * @dev: the &struct device of this 802.11 device
729 */
543static inline void SET_IEEE80211_DEV(struct ieee80211_hw *hw, struct device *dev) 730static inline void SET_IEEE80211_DEV(struct ieee80211_hw *hw, struct device *dev)
544{ 731{
545 set_wiphy_dev(hw->wiphy, dev); 732 set_wiphy_dev(hw->wiphy, dev);
546} 733}
547 734
735/**
736 * SET_IEEE80211_PERM_ADDR - set the permanenet MAC address for 802.11 hardware
737 *
738 * @hw: the &struct ieee80211_hw to set the MAC address for
739 * @addr: the address to set
740 */
548static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, u8 *addr) 741static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, u8 *addr)
549{ 742{
550 memcpy(hw->wiphy->perm_addr, addr, ETH_ALEN); 743 memcpy(hw->wiphy->perm_addr, addr, ETH_ALEN);
551} 744}
552 745
553/* Configuration block used by the low-level driver to tell the 802.11 code 746/**
554 * about supported hardware features and to pass function pointers to callback 747 * DOC: Hardware crypto acceleration
555 * functions. */ 748 *
749 * mac80211 is capable of taking advantage of many hardware
750 * acceleration designs for encryption and decryption operations.
751 *
752 * The set_key() callback in the &struct ieee80211_ops for a given
753 * device is called to enable hardware acceleration of encryption and
754 * decryption. The callback takes an @address parameter that will be
755 * the broadcast address for default keys, the other station's hardware
756 * address for individual keys or the zero address for keys that will
757 * be used only for transmission.
758 * Multiple transmission keys with the same key index may be used when
759 * VLANs are configured for an access point.
760 *
761 * The @local_address parameter will always be set to our own address,
762 * this is only relevant if you support multiple local addresses.
763 *
764 * When transmitting, the TX control data will use the @hw_key_idx
765 * selected by the driver by modifying the &struct ieee80211_key_conf
766 * pointed to by the @key parameter to the set_key() function.
767 *
768 * The set_key() call for the %SET_KEY command should return 0 if
769 * the key is now in use, -%EOPNOTSUPP or -%ENOSPC if it couldn't be
770 * added; if you return 0 then hw_key_idx must be assigned to the
771 * hardware key index, you are free to use the full u8 range.
772 *
773 * When the cmd is %DISABLE_KEY then it must succeed.
774 *
775 * Note that it is permissible to not decrypt a frame even if a key
776 * for it has been uploaded to hardware, the stack will not make any
777 * decision based on whether a key has been uploaded or not but rather
778 * based on the receive flags.
779 *
780 * The &struct ieee80211_key_conf structure pointed to by the @key
781 * parameter is guaranteed to be valid until another call to set_key()
782 * removes it, but it can only be used as a cookie to differentiate
783 * keys.
784 */
785
786/**
787 * DOC: Frame filtering
788 *
789 * mac80211 requires to see many management frames for proper
790 * operation, and users may want to see many more frames when
791 * in monitor mode. However, for best CPU usage and power consumption,
792 * having as few frames as possible percolate through the stack is
793 * desirable. Hence, the hardware should filter as much as possible.
794 *
795 * To achieve this, mac80211 uses filter flags (see below) to tell
796 * the driver's configure_filter() function which frames should be
797 * passed to mac80211 and which should be filtered out.
798 *
799 * The configure_filter() callback is invoked with the parameters
800 * @mc_count and @mc_list for the combined multicast address list
801 * of all virtual interfaces, @changed_flags telling which flags
802 * were changed and @total_flags with the new flag states.
803 *
804 * If your device has no multicast address filters your driver will
805 * need to check both the %FIF_ALLMULTI flag and the @mc_count
806 * parameter to see whether multicast frames should be accepted
807 * or dropped.
808 *
809 * All unsupported flags in @total_flags must be cleared, i.e. you
810 * should clear all bits except those you honoured.
811 */
812
813/**
814 * enum ieee80211_filter_flags - hardware filter flags
815 *
816 * These flags determine what the filter in hardware should be
817 * programmed to let through and what should not be passed to the
818 * stack. It is always safe to pass more frames than requested,
819 * but this has negative impact on power consumption.
820 *
821 * @FIF_PROMISC_IN_BSS: promiscuous mode within your BSS,
822 * think of the BSS as your network segment and then this corresponds
823 * to the regular ethernet device promiscuous mode.
824 *
825 * @FIF_ALLMULTI: pass all multicast frames, this is used if requested
826 * by the user or if the hardware is not capable of filtering by
827 * multicast address.
828 *
829 * @FIF_FCSFAIL: pass frames with failed FCS (but you need to set the
830 * %RX_FLAG_FAILED_FCS_CRC for them)
831 *
832 * @FIF_PLCPFAIL: pass frames with failed PLCP CRC (but you need to set
833 * the %RX_FLAG_FAILED_PLCP_CRC for them
834 *
835 * @FIF_BCN_PRBRESP_PROMISC: This flag is set during scanning to indicate
836 * to the hardware that it should not filter beacons or probe responses
837 * by BSSID. Filtering them can greatly reduce the amount of processing
838 * mac80211 needs to do and the amount of CPU wakeups, so you should
839 * honour this flag if possible.
840 *
841 * @FIF_CONTROL: pass control frames, if PROMISC_IN_BSS is not set then
842 * only those addressed to this station
843 *
844 * @FIF_OTHER_BSS: pass frames destined to other BSSes
845 */
846enum ieee80211_filter_flags {
847 FIF_PROMISC_IN_BSS = 1<<0,
848 FIF_ALLMULTI = 1<<1,
849 FIF_FCSFAIL = 1<<2,
850 FIF_PLCPFAIL = 1<<3,
851 FIF_BCN_PRBRESP_PROMISC = 1<<4,
852 FIF_CONTROL = 1<<5,
853 FIF_OTHER_BSS = 1<<6,
854};
855
856/**
857 * enum ieee80211_erp_change_flags - erp change flags
858 *
859 * These flags are used with the erp_ie_changed() callback in
860 * &struct ieee80211_ops to indicate which parameter(s) changed.
861 * @IEEE80211_ERP_CHANGE_PROTECTION: protection changed
862 * @IEEE80211_ERP_CHANGE_PREAMBLE: barker preamble mode changed
863 */
864enum ieee80211_erp_change_flags {
865 IEEE80211_ERP_CHANGE_PROTECTION = 1<<0,
866 IEEE80211_ERP_CHANGE_PREAMBLE = 1<<1,
867};
868
869
870/**
871 * struct ieee80211_ops - callbacks from mac80211 to the driver
872 *
873 * This structure contains various callbacks that the driver may
874 * handle or, in some cases, must handle, for example to configure
875 * the hardware to a new channel or to transmit a frame.
876 *
877 * @tx: Handler that 802.11 module calls for each transmitted frame.
878 * skb contains the buffer starting from the IEEE 802.11 header.
879 * The low-level driver should send the frame out based on
880 * configuration in the TX control data. Must be implemented and
881 * atomic.
882 *
883 * @start: Called before the first netdevice attached to the hardware
884 * is enabled. This should turn on the hardware and must turn on
885 * frame reception (for possibly enabled monitor interfaces.)
886 * Returns negative error codes, these may be seen in userspace,
887 * or zero.
888 * When the device is started it should not have a MAC address
889 * to avoid acknowledging frames before a non-monitor device
890 * is added.
891 * Must be implemented.
892 *
893 * @stop: Called after last netdevice attached to the hardware
894 * is disabled. This should turn off the hardware (at least
895 * it must turn off frame reception.)
896 * May be called right after add_interface if that rejects
897 * an interface.
898 * Must be implemented.
899 *
900 * @add_interface: Called when a netdevice attached to the hardware is
901 * enabled. Because it is not called for monitor mode devices, @open
902 * and @stop must be implemented.
903 * The driver should perform any initialization it needs before
904 * the device can be enabled. The initial configuration for the
905 * interface is given in the conf parameter.
906 * The callback may refuse to add an interface by returning a
907 * negative error code (which will be seen in userspace.)
908 * Must be implemented.
909 *
910 * @remove_interface: Notifies a driver that an interface is going down.
911 * The @stop callback is called after this if it is the last interface
912 * and no monitor interfaces are present.
913 * When all interfaces are removed, the MAC address in the hardware
914 * must be cleared so the device no longer acknowledges packets,
915 * the mac_addr member of the conf structure is, however, set to the
916 * MAC address of the device going away.
917 * Hence, this callback must be implemented.
918 *
919 * @config: Handler for configuration requests. IEEE 802.11 code calls this
920 * function to change hardware configuration, e.g., channel.
921 *
922 * @config_interface: Handler for configuration requests related to interfaces
923 * (e.g. BSSID changes.)
924 *
925 * @configure_filter: Configure the device's RX filter.
926 * See the section "Frame filtering" for more information.
927 * This callback must be implemented and atomic.
928 *
929 * @set_tim: Set TIM bit. If the hardware/firmware takes care of beacon
930 * generation (that is, %IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE is set)
931 * mac80211 calls this function when a TIM bit must be set or cleared
932 * for a given AID. Must be atomic.
933 *
934 * @set_key: See the section "Hardware crypto acceleration"
935 * This callback can sleep, and is only called between add_interface
936 * and remove_interface calls, i.e. while the interface with the
937 * given local_address is enabled.
938 *
939 * @set_ieee8021x: Enable/disable IEEE 802.1X. This item requests wlan card
940 * to pass unencrypted EAPOL-Key frames even when encryption is
941 * configured. If the wlan card does not require such a configuration,
942 * this function pointer can be set to NULL.
943 *
944 * @set_port_auth: Set port authorization state (IEEE 802.1X PAE) to be
945 * authorized (@authorized=1) or unauthorized (=0). This function can be
946 * used if the wlan hardware or low-level driver implements PAE.
947 * mac80211 will filter frames based on authorization state in any case,
948 * so this function pointer can be NULL if low-level driver does not
949 * require event notification about port state changes.
950 *
951 * @hw_scan: Ask the hardware to service the scan request, no need to start
952 * the scan state machine in stack.
953 *
954 * @get_stats: return low-level statistics
955 *
956 * @set_privacy_invoked: For devices that generate their own beacons and probe
957 * response or association responses this updates the state of privacy_invoked
958 * returns 0 for success or an error number.
959 *
960 * @get_sequence_counter: For devices that have internal sequence counters this
961 * callback allows mac80211 to access the current value of a counter.
962 * This callback seems not well-defined, tell us if you need it.
963 *
964 * @set_rts_threshold: Configuration of RTS threshold (if device needs it)
965 *
966 * @set_frag_threshold: Configuration of fragmentation threshold. Assign this if
967 * the device does fragmentation by itself; if this method is assigned then
968 * the stack will not do fragmentation.
969 *
970 * @set_retry_limit: Configuration of retry limits (if device needs it)
971 *
972 * @sta_notify: Notifies low level driver about addition or removal
973 * of assocaited station or AP.
974 *
975 * @erp_ie_changed: Handle ERP IE change notifications. Must be atomic.
976 *
977 * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max),
978 * bursting) for a hardware TX queue. The @queue parameter uses the
979 * %IEEE80211_TX_QUEUE_* constants. Must be atomic.
980 *
981 * @get_tx_stats: Get statistics of the current TX queue status. This is used
982 * to get number of currently queued packets (queue length), maximum queue
983 * size (limit), and total number of packets sent using each TX queue
984 * (count). This information is used for WMM to find out which TX
985 * queues have room for more packets and by hostapd to provide
986 * statistics about the current queueing state to external programs.
987 *
988 * @get_tsf: Get the current TSF timer value from firmware/hardware. Currently,
989 * this is only used for IBSS mode debugging and, as such, is not a
990 * required function. Must be atomic.
991 *
992 * @reset_tsf: Reset the TSF timer and allow firmware/hardware to synchronize
993 * with other STAs in the IBSS. This is only used in IBSS mode. This
994 * function is optional if the firmware/hardware takes full care of
995 * TSF synchronization.
996 *
997 * @beacon_update: Setup beacon data for IBSS beacons. Unlike access point,
998 * IBSS uses a fixed beacon frame which is configured using this
999 * function.
1000 * If the driver returns success (0) from this callback, it owns
1001 * the skb. That means the driver is responsible to kfree_skb() it.
1002 * The control structure is not dynamically allocated. That means the
1003 * driver does not own the pointer and if it needs it somewhere
1004 * outside of the context of this function, it must copy it
1005 * somewhere else.
1006 * This handler is required only for IBSS mode.
1007 *
1008 * @tx_last_beacon: Determine whether the last IBSS beacon was sent by us.
1009 * This is needed only for IBSS mode and the result of this function is
1010 * used to determine whether to reply to Probe Requests.
1011 */
556struct ieee80211_ops { 1012struct ieee80211_ops {
557 /* Handler that 802.11 module calls for each transmitted frame.
558 * skb contains the buffer starting from the IEEE 802.11 header.
559 * The low-level driver should send the frame out based on
560 * configuration in the TX control data.
561 * Must be atomic. */
562 int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb, 1013 int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb,
563 struct ieee80211_tx_control *control); 1014 struct ieee80211_tx_control *control);
564 1015 int (*start)(struct ieee80211_hw *hw);
565 /* Handler for performing hardware reset. */ 1016 void (*stop)(struct ieee80211_hw *hw);
566 int (*reset)(struct ieee80211_hw *hw);
567
568 /* Handler that is called when any netdevice attached to the hardware
569 * device is set UP for the first time. This can be used, e.g., to
570 * enable interrupts and beacon sending. */
571 int (*open)(struct ieee80211_hw *hw);
572
573 /* Handler that is called when the last netdevice attached to the
574 * hardware device is set DOWN. This can be used, e.g., to disable
575 * interrupts and beacon sending. */
576 int (*stop)(struct ieee80211_hw *hw);
577
578 /* Handler for asking a driver if a new interface can be added (or,
579 * more exactly, set UP). If the handler returns zero, the interface
580 * is added. Driver should perform any initialization it needs prior
581 * to returning zero. By returning non-zero addition of the interface
582 * is inhibited. Unless monitor_during_oper is set, it is guaranteed
583 * that monitor interfaces and normal interfaces are mutually
584 * exclusive. If assigned, the open() handler is called after
585 * add_interface() if this is the first device added. The
586 * add_interface() callback has to be assigned because it is the only
587 * way to obtain the requested MAC address for any interface.
588 */
589 int (*add_interface)(struct ieee80211_hw *hw, 1017 int (*add_interface)(struct ieee80211_hw *hw,
590 struct ieee80211_if_init_conf *conf); 1018 struct ieee80211_if_init_conf *conf);
591
592 /* Notify a driver that an interface is going down. The stop() handler
593 * is called prior to this if this is a last interface. */
594 void (*remove_interface)(struct ieee80211_hw *hw, 1019 void (*remove_interface)(struct ieee80211_hw *hw,
595 struct ieee80211_if_init_conf *conf); 1020 struct ieee80211_if_init_conf *conf);
596
597 /* Handler for configuration requests. IEEE 802.11 code calls this
598 * function to change hardware configuration, e.g., channel. */
599 int (*config)(struct ieee80211_hw *hw, struct ieee80211_conf *conf); 1021 int (*config)(struct ieee80211_hw *hw, struct ieee80211_conf *conf);
600
601 /* Handler for configuration requests related to interfaces (e.g.
602 * BSSID). */
603 int (*config_interface)(struct ieee80211_hw *hw, 1022 int (*config_interface)(struct ieee80211_hw *hw,
604 int if_id, struct ieee80211_if_conf *conf); 1023 int if_id, struct ieee80211_if_conf *conf);
605 1024 void (*configure_filter)(struct ieee80211_hw *hw,
606 /* ieee80211 drivers do not have access to the &struct net_device 1025 unsigned int changed_flags,
607 * that is (are) connected with their device. Hence (and because 1026 unsigned int *total_flags,
608 * we need to combine the multicast lists and flags for multiple 1027 int mc_count, struct dev_addr_list *mc_list);
609 * virtual interfaces), they cannot assign set_multicast_list.
610 * The parameters here replace dev->flags and dev->mc_count,
611 * dev->mc_list is replaced by calling ieee80211_get_mc_list_item.
612 * Must be atomic. */
613 void (*set_multicast_list)(struct ieee80211_hw *hw,
614 unsigned short flags, int mc_count);
615
616 /* Set TIM bit handler. If the hardware/firmware takes care of beacon
617 * generation, IEEE 802.11 code uses this function to tell the
618 * low-level to set (or clear if set==0) TIM bit for the given aid. If
619 * host system is used to generate beacons, this handler is not used
620 * and low-level driver should set it to NULL.
621 * Must be atomic. */
622 int (*set_tim)(struct ieee80211_hw *hw, int aid, int set); 1028 int (*set_tim)(struct ieee80211_hw *hw, int aid, int set);
623 1029 int (*set_key)(struct ieee80211_hw *hw, enum set_key_cmd cmd,
624 /* Set encryption key. IEEE 802.11 module calls this function to set 1030 const u8 *local_address, const u8 *address,
625 * encryption keys. addr is ff:ff:ff:ff:ff:ff for default keys and 1031 struct ieee80211_key_conf *key);
626 * station hwaddr for individual keys. aid of the station is given
627 * to help low-level driver in selecting which key->hw_key_idx to use
628 * for this key. TX control data will use the hw_key_idx selected by
629 * the low-level driver.
630 * Must be atomic. */
631 int (*set_key)(struct ieee80211_hw *hw, set_key_cmd cmd,
632 u8 *addr, struct ieee80211_key_conf *key, int aid);
633
634 /* Set TX key index for default/broadcast keys. This is needed in cases
635 * where wlan card is doing full WEP/TKIP encapsulation (wep_include_iv
636 * is not set), in other cases, this function pointer can be set to
637 * NULL since the IEEE 802. 11 module takes care of selecting the key
638 * index for each TX frame. */
639 int (*set_key_idx)(struct ieee80211_hw *hw, int idx);
640
641 /* Enable/disable IEEE 802.1X. This item requests wlan card to pass
642 * unencrypted EAPOL-Key frames even when encryption is configured.
643 * If the wlan card does not require such a configuration, this
644 * function pointer can be set to NULL. */
645 int (*set_ieee8021x)(struct ieee80211_hw *hw, int use_ieee8021x); 1032 int (*set_ieee8021x)(struct ieee80211_hw *hw, int use_ieee8021x);
646
647 /* Set port authorization state (IEEE 802.1X PAE) to be authorized
648 * (authorized=1) or unauthorized (authorized=0). This function can be
649 * used if the wlan hardware or low-level driver implements PAE.
650 * 80211.o module will anyway filter frames based on authorization
651 * state, so this function pointer can be NULL if low-level driver does
652 * not require event notification about port state changes.
653 * Currently unused. */
654 int (*set_port_auth)(struct ieee80211_hw *hw, u8 *addr, 1033 int (*set_port_auth)(struct ieee80211_hw *hw, u8 *addr,
655 int authorized); 1034 int authorized);
656
657 /* Ask the hardware to service the scan request, no need to start
658 * the scan state machine in stack. */
659 int (*hw_scan)(struct ieee80211_hw *hw, u8 *ssid, size_t len); 1035 int (*hw_scan)(struct ieee80211_hw *hw, u8 *ssid, size_t len);
660
661 /* return low-level statistics */
662 int (*get_stats)(struct ieee80211_hw *hw, 1036 int (*get_stats)(struct ieee80211_hw *hw,
663 struct ieee80211_low_level_stats *stats); 1037 struct ieee80211_low_level_stats *stats);
664
665 /* For devices that generate their own beacons and probe response
666 * or association responses this updates the state of privacy_invoked
667 * returns 0 for success or an error number */
668 int (*set_privacy_invoked)(struct ieee80211_hw *hw, 1038 int (*set_privacy_invoked)(struct ieee80211_hw *hw,
669 int privacy_invoked); 1039 int privacy_invoked);
670
671 /* For devices that have internal sequence counters, allow 802.11
672 * code to access the current value of a counter */
673 int (*get_sequence_counter)(struct ieee80211_hw *hw, 1040 int (*get_sequence_counter)(struct ieee80211_hw *hw,
674 u8* addr, u8 keyidx, u8 txrx, 1041 u8* addr, u8 keyidx, u8 txrx,
675 u32* iv32, u16* iv16); 1042 u32* iv32, u16* iv16);
676
677 /* Configuration of RTS threshold (if device needs it) */
678 int (*set_rts_threshold)(struct ieee80211_hw *hw, u32 value); 1043 int (*set_rts_threshold)(struct ieee80211_hw *hw, u32 value);
679
680 /* Configuration of fragmentation threshold.
681 * Assign this if the device does fragmentation by itself,
682 * if this method is assigned then the stack will not do
683 * fragmentation. */
684 int (*set_frag_threshold)(struct ieee80211_hw *hw, u32 value); 1044 int (*set_frag_threshold)(struct ieee80211_hw *hw, u32 value);
685
686 /* Configuration of retry limits (if device needs it) */
687 int (*set_retry_limit)(struct ieee80211_hw *hw, 1045 int (*set_retry_limit)(struct ieee80211_hw *hw,
688 u32 short_retry, u32 long_retr); 1046 u32 short_retry, u32 long_retr);
689 1047 void (*sta_notify)(struct ieee80211_hw *hw, int if_id,
690 /* Number of STAs in STA table notification (NULL = disabled). 1048 enum sta_notify_cmd, const u8 *addr);
691 * Must be atomic. */ 1049 void (*erp_ie_changed)(struct ieee80211_hw *hw, u8 changes,
692 void (*sta_table_notification)(struct ieee80211_hw *hw, 1050 int cts_protection, int preamble);
693 int num_sta);
694
695 /* Configure TX queue parameters (EDCF (aifs, cw_min, cw_max),
696 * bursting) for a hardware TX queue.
697 * queue = IEEE80211_TX_QUEUE_*.
698 * Must be atomic. */
699 int (*conf_tx)(struct ieee80211_hw *hw, int queue, 1051 int (*conf_tx)(struct ieee80211_hw *hw, int queue,
700 const struct ieee80211_tx_queue_params *params); 1052 const struct ieee80211_tx_queue_params *params);
701
702 /* Get statistics of the current TX queue status. This is used to get
703 * number of currently queued packets (queue length), maximum queue
704 * size (limit), and total number of packets sent using each TX queue
705 * (count).
706 * Currently unused. */
707 int (*get_tx_stats)(struct ieee80211_hw *hw, 1053 int (*get_tx_stats)(struct ieee80211_hw *hw,
708 struct ieee80211_tx_queue_stats *stats); 1054 struct ieee80211_tx_queue_stats *stats);
709
710 /* Get the current TSF timer value from firmware/hardware. Currently,
711 * this is only used for IBSS mode debugging and, as such, is not a
712 * required function.
713 * Must be atomic. */
714 u64 (*get_tsf)(struct ieee80211_hw *hw); 1055 u64 (*get_tsf)(struct ieee80211_hw *hw);
715
716 /* Reset the TSF timer and allow firmware/hardware to synchronize with
717 * other STAs in the IBSS. This is only used in IBSS mode. This
718 * function is optional if the firmware/hardware takes full care of
719 * TSF synchronization. */
720 void (*reset_tsf)(struct ieee80211_hw *hw); 1056 void (*reset_tsf)(struct ieee80211_hw *hw);
721
722 /* Setup beacon data for IBSS beacons. Unlike access point (Master),
723 * IBSS uses a fixed beacon frame which is configured using this
724 * function. This handler is required only for IBSS mode. */
725 int (*beacon_update)(struct ieee80211_hw *hw, 1057 int (*beacon_update)(struct ieee80211_hw *hw,
726 struct sk_buff *skb, 1058 struct sk_buff *skb,
727 struct ieee80211_tx_control *control); 1059 struct ieee80211_tx_control *control);
728
729 /* Determine whether the last IBSS beacon was sent by us. This is
730 * needed only for IBSS mode and the result of this function is used to
731 * determine whether to reply to Probe Requests. */
732 int (*tx_last_beacon)(struct ieee80211_hw *hw); 1060 int (*tx_last_beacon)(struct ieee80211_hw *hw);
733}; 1061};
734 1062
735/* Allocate a new hardware device. This must be called once for each 1063/**
736 * hardware device. The returned pointer must be used to refer to this 1064 * ieee80211_alloc_hw - Allocate a new hardware device
737 * device when calling other functions. 802.11 code allocates a private data 1065 *
738 * area for the low-level driver. The size of this area is given as 1066 * This must be called once for each hardware device. The returned pointer
739 * priv_data_len. 1067 * must be used to refer to this device when calling other functions.
1068 * mac80211 allocates a private data area for the driver pointed to by
1069 * @priv in &struct ieee80211_hw, the size of this area is given as
1070 * @priv_data_len.
1071 *
1072 * @priv_data_len: length of private data
1073 * @ops: callbacks for this device
740 */ 1074 */
741struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, 1075struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
742 const struct ieee80211_ops *ops); 1076 const struct ieee80211_ops *ops);
743 1077
744/* Register hardware device to the IEEE 802.11 code and kernel. Low-level 1078/**
745 * drivers must call this function before using any other IEEE 802.11 1079 * ieee80211_register_hw - Register hardware device
746 * function except ieee80211_register_hwmode. */ 1080 *
1081 * You must call this function before any other functions
1082 * except ieee80211_register_hwmode.
1083 *
1084 * @hw: the device to register as returned by ieee80211_alloc_hw()
1085 */
747int ieee80211_register_hw(struct ieee80211_hw *hw); 1086int ieee80211_register_hw(struct ieee80211_hw *hw);
748 1087
749/* driver can use this and ieee80211_get_rx_led_name to get the
750 * name of the registered LEDs after ieee80211_register_hw
751 * was called.
752 * This is useful to set the default trigger on the LED class
753 * device that your driver should export for each LED the device
754 * has, that way the default behaviour will be as expected but
755 * the user can still change it/turn off the LED etc.
756 */
757#ifdef CONFIG_MAC80211_LEDS 1088#ifdef CONFIG_MAC80211_LEDS
758extern char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw); 1089extern char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw);
759extern char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw); 1090extern char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw);
1091extern char *__ieee80211_get_assoc_led_name(struct ieee80211_hw *hw);
760#endif 1092#endif
1093/**
1094 * ieee80211_get_tx_led_name - get name of TX LED
1095 *
1096 * mac80211 creates a transmit LED trigger for each wireless hardware
1097 * that can be used to drive LEDs if your driver registers a LED device.
1098 * This function returns the name (or %NULL if not configured for LEDs)
1099 * of the trigger so you can automatically link the LED device.
1100 *
1101 * @hw: the hardware to get the LED trigger name for
1102 */
761static inline char *ieee80211_get_tx_led_name(struct ieee80211_hw *hw) 1103static inline char *ieee80211_get_tx_led_name(struct ieee80211_hw *hw)
762{ 1104{
763#ifdef CONFIG_MAC80211_LEDS 1105#ifdef CONFIG_MAC80211_LEDS
@@ -767,6 +1109,16 @@ static inline char *ieee80211_get_tx_led_name(struct ieee80211_hw *hw)
767#endif 1109#endif
768} 1110}
769 1111
1112/**
1113 * ieee80211_get_rx_led_name - get name of RX LED
1114 *
1115 * mac80211 creates a receive LED trigger for each wireless hardware
1116 * that can be used to drive LEDs if your driver registers a LED device.
1117 * This function returns the name (or %NULL if not configured for LEDs)
1118 * of the trigger so you can automatically link the LED device.
1119 *
1120 * @hw: the hardware to get the LED trigger name for
1121 */
770static inline char *ieee80211_get_rx_led_name(struct ieee80211_hw *hw) 1122static inline char *ieee80211_get_rx_led_name(struct ieee80211_hw *hw)
771{ 1123{
772#ifdef CONFIG_MAC80211_LEDS 1124#ifdef CONFIG_MAC80211_LEDS
@@ -776,33 +1128,94 @@ static inline char *ieee80211_get_rx_led_name(struct ieee80211_hw *hw)
776#endif 1128#endif
777} 1129}
778 1130
1131static inline char *ieee80211_get_assoc_led_name(struct ieee80211_hw *hw)
1132{
1133#ifdef CONFIG_MAC80211_LEDS
1134 return __ieee80211_get_assoc_led_name(hw);
1135#else
1136 return NULL;
1137#endif
1138}
1139
1140
779/* Register a new hardware PHYMODE capability to the stack. */ 1141/* Register a new hardware PHYMODE capability to the stack. */
780int ieee80211_register_hwmode(struct ieee80211_hw *hw, 1142int ieee80211_register_hwmode(struct ieee80211_hw *hw,
781 struct ieee80211_hw_mode *mode); 1143 struct ieee80211_hw_mode *mode);
782 1144
783/* Unregister a hardware device. This function instructs 802.11 code to free 1145/**
784 * allocated resources and unregister netdevices from the kernel. */ 1146 * ieee80211_unregister_hw - Unregister a hardware device
1147 *
1148 * This function instructs mac80211 to free allocated resources
1149 * and unregister netdevices from the networking subsystem.
1150 *
1151 * @hw: the hardware to unregister
1152 */
785void ieee80211_unregister_hw(struct ieee80211_hw *hw); 1153void ieee80211_unregister_hw(struct ieee80211_hw *hw);
786 1154
787/* Free everything that was allocated including private data of a driver. */ 1155/**
1156 * ieee80211_free_hw - free hardware descriptor
1157 *
1158 * This function frees everything that was allocated, including the
1159 * private data for the driver. You must call ieee80211_unregister_hw()
1160 * before calling this function
1161 *
1162 * @hw: the hardware to free
1163 */
788void ieee80211_free_hw(struct ieee80211_hw *hw); 1164void ieee80211_free_hw(struct ieee80211_hw *hw);
789 1165
790/* Receive frame callback function. The low-level driver uses this function to 1166/* trick to avoid symbol clashes with the ieee80211 subsystem */
791 * send received frames to the IEEE 802.11 code. Receive buffer (skb) must
792 * start with IEEE 802.11 header. */
793void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb, 1167void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
794 struct ieee80211_rx_status *status); 1168 struct ieee80211_rx_status *status);
1169
1170/**
1171 * ieee80211_rx - receive frame
1172 *
1173 * Use this function to hand received frames to mac80211. The receive
1174 * buffer in @skb must start with an IEEE 802.11 header or a radiotap
1175 * header if %RX_FLAG_RADIOTAP is set in the @status flags.
1176 *
1177 * This function may not be called in IRQ context.
1178 *
1179 * @hw: the hardware this frame came in on
1180 * @skb: the buffer to receive, owned by mac80211 after this call
1181 * @status: status of this frame; the status pointer need not be valid
1182 * after this function returns
1183 */
1184static inline void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
1185 struct ieee80211_rx_status *status)
1186{
1187 __ieee80211_rx(hw, skb, status);
1188}
1189
1190/**
1191 * ieee80211_rx_irqsafe - receive frame
1192 *
1193 * Like ieee80211_rx() but can be called in IRQ context
1194 * (internally defers to a workqueue.)
1195 *
1196 * @hw: the hardware this frame came in on
1197 * @skb: the buffer to receive, owned by mac80211 after this call
1198 * @status: status of this frame; the status pointer need not be valid
1199 * after this function returns and is not freed by mac80211,
1200 * it is recommended that it points to a stack area
1201 */
795void ieee80211_rx_irqsafe(struct ieee80211_hw *hw, 1202void ieee80211_rx_irqsafe(struct ieee80211_hw *hw,
796 struct sk_buff *skb, 1203 struct sk_buff *skb,
797 struct ieee80211_rx_status *status); 1204 struct ieee80211_rx_status *status);
798 1205
799/* Transmit status callback function. The low-level driver must call this 1206/**
800 * function to report transmit status for all the TX frames that had 1207 * ieee80211_tx_status - transmit status callback
801 * req_tx_status set in the transmit control fields. In addition, this should 1208 *
802 * be called at least for all unicast frames to provide information for TX rate 1209 * Call this function for all transmitted frames after they have been
803 * control algorithm. In order to maintain all statistics, this function is 1210 * transmitted. It is permissible to not call this function for
804 * recommended to be called after each frame, including multicast/broadcast, is 1211 * multicast frames but this can affect statistics.
805 * sent. */ 1212 *
1213 * @hw: the hardware the frame was transmitted by
1214 * @skb: the frame that was transmitted, owned by mac80211 after this call
1215 * @status: status information for this frame; the status pointer need not
1216 * be valid after this function returns and is not freed by mac80211,
1217 * it is recommended that it points to a stack area
1218 */
806void ieee80211_tx_status(struct ieee80211_hw *hw, 1219void ieee80211_tx_status(struct ieee80211_hw *hw,
807 struct sk_buff *skb, 1220 struct sk_buff *skb,
808 struct ieee80211_tx_status *status); 1221 struct ieee80211_tx_status *status);
@@ -830,6 +1243,7 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
830/** 1243/**
831 * ieee80211_rts_get - RTS frame generation function 1244 * ieee80211_rts_get - RTS frame generation function
832 * @hw: pointer obtained from ieee80211_alloc_hw(). 1245 * @hw: pointer obtained from ieee80211_alloc_hw().
1246 * @if_id: interface ID from &struct ieee80211_if_init_conf.
833 * @frame: pointer to the frame that is going to be protected by the RTS. 1247 * @frame: pointer to the frame that is going to be protected by the RTS.
834 * @frame_len: the frame length (in octets). 1248 * @frame_len: the frame length (in octets).
835 * @frame_txctl: &struct ieee80211_tx_control of the frame. 1249 * @frame_txctl: &struct ieee80211_tx_control of the frame.
@@ -840,7 +1254,7 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
840 * the next RTS frame from the 802.11 code. The low-level is responsible 1254 * the next RTS frame from the 802.11 code. The low-level is responsible
841 * for calling this function before and RTS frame is needed. 1255 * for calling this function before and RTS frame is needed.
842 */ 1256 */
843void ieee80211_rts_get(struct ieee80211_hw *hw, 1257void ieee80211_rts_get(struct ieee80211_hw *hw, int if_id,
844 const void *frame, size_t frame_len, 1258 const void *frame, size_t frame_len,
845 const struct ieee80211_tx_control *frame_txctl, 1259 const struct ieee80211_tx_control *frame_txctl,
846 struct ieee80211_rts *rts); 1260 struct ieee80211_rts *rts);
@@ -848,6 +1262,7 @@ void ieee80211_rts_get(struct ieee80211_hw *hw,
848/** 1262/**
849 * ieee80211_rts_duration - Get the duration field for an RTS frame 1263 * ieee80211_rts_duration - Get the duration field for an RTS frame
850 * @hw: pointer obtained from ieee80211_alloc_hw(). 1264 * @hw: pointer obtained from ieee80211_alloc_hw().
1265 * @if_id: interface ID from &struct ieee80211_if_init_conf.
851 * @frame_len: the length of the frame that is going to be protected by the RTS. 1266 * @frame_len: the length of the frame that is going to be protected by the RTS.
852 * @frame_txctl: &struct ieee80211_tx_control of the frame. 1267 * @frame_txctl: &struct ieee80211_tx_control of the frame.
853 * 1268 *
@@ -855,13 +1270,14 @@ void ieee80211_rts_get(struct ieee80211_hw *hw,
855 * the duration field, the low-level driver uses this function to receive 1270 * the duration field, the low-level driver uses this function to receive
856 * the duration field value in little-endian byteorder. 1271 * the duration field value in little-endian byteorder.
857 */ 1272 */
858__le16 ieee80211_rts_duration(struct ieee80211_hw *hw, 1273__le16 ieee80211_rts_duration(struct ieee80211_hw *hw, int if_id,
859 size_t frame_len, 1274 size_t frame_len,
860 const struct ieee80211_tx_control *frame_txctl); 1275 const struct ieee80211_tx_control *frame_txctl);
861 1276
862/** 1277/**
863 * ieee80211_ctstoself_get - CTS-to-self frame generation function 1278 * ieee80211_ctstoself_get - CTS-to-self frame generation function
864 * @hw: pointer obtained from ieee80211_alloc_hw(). 1279 * @hw: pointer obtained from ieee80211_alloc_hw().
1280 * @if_id: interface ID from &struct ieee80211_if_init_conf.
865 * @frame: pointer to the frame that is going to be protected by the CTS-to-self. 1281 * @frame: pointer to the frame that is going to be protected by the CTS-to-self.
866 * @frame_len: the frame length (in octets). 1282 * @frame_len: the frame length (in octets).
867 * @frame_txctl: &struct ieee80211_tx_control of the frame. 1283 * @frame_txctl: &struct ieee80211_tx_control of the frame.
@@ -872,7 +1288,7 @@ __le16 ieee80211_rts_duration(struct ieee80211_hw *hw,
872 * the next CTS-to-self frame from the 802.11 code. The low-level is responsible 1288 * the next CTS-to-self frame from the 802.11 code. The low-level is responsible
873 * for calling this function before and CTS-to-self frame is needed. 1289 * for calling this function before and CTS-to-self frame is needed.
874 */ 1290 */
875void ieee80211_ctstoself_get(struct ieee80211_hw *hw, 1291void ieee80211_ctstoself_get(struct ieee80211_hw *hw, int if_id,
876 const void *frame, size_t frame_len, 1292 const void *frame, size_t frame_len,
877 const struct ieee80211_tx_control *frame_txctl, 1293 const struct ieee80211_tx_control *frame_txctl,
878 struct ieee80211_cts *cts); 1294 struct ieee80211_cts *cts);
@@ -880,6 +1296,7 @@ void ieee80211_ctstoself_get(struct ieee80211_hw *hw,
880/** 1296/**
881 * ieee80211_ctstoself_duration - Get the duration field for a CTS-to-self frame 1297 * ieee80211_ctstoself_duration - Get the duration field for a CTS-to-self frame
882 * @hw: pointer obtained from ieee80211_alloc_hw(). 1298 * @hw: pointer obtained from ieee80211_alloc_hw().
1299 * @if_id: interface ID from &struct ieee80211_if_init_conf.
883 * @frame_len: the length of the frame that is going to be protected by the CTS-to-self. 1300 * @frame_len: the length of the frame that is going to be protected by the CTS-to-self.
884 * @frame_txctl: &struct ieee80211_tx_control of the frame. 1301 * @frame_txctl: &struct ieee80211_tx_control of the frame.
885 * 1302 *
@@ -887,20 +1304,21 @@ void ieee80211_ctstoself_get(struct ieee80211_hw *hw,
887 * the duration field, the low-level driver uses this function to receive 1304 * the duration field, the low-level driver uses this function to receive
888 * the duration field value in little-endian byteorder. 1305 * the duration field value in little-endian byteorder.
889 */ 1306 */
890__le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, 1307__le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, int if_id,
891 size_t frame_len, 1308 size_t frame_len,
892 const struct ieee80211_tx_control *frame_txctl); 1309 const struct ieee80211_tx_control *frame_txctl);
893 1310
894/** 1311/**
895 * ieee80211_generic_frame_duration - Calculate the duration field for a frame 1312 * ieee80211_generic_frame_duration - Calculate the duration field for a frame
896 * @hw: pointer obtained from ieee80211_alloc_hw(). 1313 * @hw: pointer obtained from ieee80211_alloc_hw().
1314 * @if_id: interface ID from &struct ieee80211_if_init_conf.
897 * @frame_len: the length of the frame. 1315 * @frame_len: the length of the frame.
898 * @rate: the rate (in 100kbps) at which the frame is going to be transmitted. 1316 * @rate: the rate (in 100kbps) at which the frame is going to be transmitted.
899 * 1317 *
900 * Calculate the duration field of some generic frame, given its 1318 * Calculate the duration field of some generic frame, given its
901 * length and transmission rate (in 100kbps). 1319 * length and transmission rate (in 100kbps).
902 */ 1320 */
903__le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, 1321__le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, int if_id,
904 size_t frame_len, 1322 size_t frame_len,
905 int rate); 1323 int rate);
906 1324
@@ -929,14 +1347,26 @@ struct sk_buff *
929ieee80211_get_buffered_bc(struct ieee80211_hw *hw, int if_id, 1347ieee80211_get_buffered_bc(struct ieee80211_hw *hw, int if_id,
930 struct ieee80211_tx_control *control); 1348 struct ieee80211_tx_control *control);
931 1349
932/* Given an sk_buff with a raw 802.11 header at the data pointer this function 1350/**
1351 * ieee80211_get_hdrlen_from_skb - get header length from data
1352 *
1353 * Given an skb with a raw 802.11 header at the data pointer this function
933 * returns the 802.11 header length in bytes (not including encryption 1354 * returns the 802.11 header length in bytes (not including encryption
934 * headers). If the data in the sk_buff is too short to contain a valid 802.11 1355 * headers). If the data in the sk_buff is too short to contain a valid 802.11
935 * header the function returns 0. 1356 * header the function returns 0.
1357 *
1358 * @skb: the frame
936 */ 1359 */
937int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb); 1360int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb);
938 1361
939/* Like ieee80211_get_hdrlen_from_skb() but takes a FC in CPU order. */ 1362/**
1363 * ieee80211_get_hdrlen - get header length from frame control
1364 *
1365 * This function returns the 802.11 header length in bytes (not including
1366 * encryption headers.)
1367 *
1368 * @fc: the frame control field (in CPU endianness)
1369 */
940int ieee80211_get_hdrlen(u16 fc); 1370int ieee80211_get_hdrlen(u16 fc);
941 1371
942/** 1372/**
@@ -982,66 +1412,14 @@ void ieee80211_stop_queues(struct ieee80211_hw *hw);
982void ieee80211_wake_queues(struct ieee80211_hw *hw); 1412void ieee80211_wake_queues(struct ieee80211_hw *hw);
983 1413
984/** 1414/**
985 * ieee80211_get_mc_list_item - iteration over items in multicast list 1415 * ieee80211_scan_completed - completed hardware scan
986 * @hw: pointer as obtained from ieee80211_alloc_hw(). 1416 *
987 * @prev: value returned by previous call to ieee80211_get_mc_list_item() or 1417 * When hardware scan offload is used (i.e. the hw_scan() callback is
988 * NULL to start a new iteration. 1418 * assigned) this function needs to be called by the driver to notify
989 * @ptr: pointer to buffer of void * type for internal usage of 1419 * mac80211 that the scan finished.
990 * ieee80211_get_mc_list_item(). 1420 *
991 * 1421 * @hw: the hardware that finished the scan
992 * Iterates over items in multicast list of given device. To get the first
993 * item, pass NULL in @prev and in *@ptr. In subsequent calls, pass the
994 * value returned by previous call in @prev. Don't alter *@ptr during
995 * iteration. When there are no more items, NULL is returned.
996 */ 1422 */
997struct dev_mc_list *
998ieee80211_get_mc_list_item(struct ieee80211_hw *hw,
999 struct dev_mc_list *prev,
1000 void **ptr);
1001
1002/* called by driver to notify scan status completed */
1003void ieee80211_scan_completed(struct ieee80211_hw *hw); 1423void ieee80211_scan_completed(struct ieee80211_hw *hw);
1004 1424
1005/* Function to indicate Radar Detection. The low level driver must call this
1006 * function to indicate the presence of radar in the current channel.
1007 * Additionally the radar type also could be sent */
1008int ieee80211_radar_status(struct ieee80211_hw *hw, int channel,
1009 int radar, int radar_type);
1010
1011/* return a pointer to the source address (SA) */
1012static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr)
1013{
1014 u8 *raw = (u8 *) hdr;
1015 u8 tofrom = (*(raw+1)) & 3; /* get the TODS and FROMDS bits */
1016
1017 switch (tofrom) {
1018 case 2:
1019 return hdr->addr3;
1020 case 3:
1021 return hdr->addr4;
1022 }
1023 return hdr->addr2;
1024}
1025
1026/* return a pointer to the destination address (DA) */
1027static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr)
1028{
1029 u8 *raw = (u8 *) hdr;
1030 u8 to_ds = (*(raw+1)) & 1; /* get the TODS bit */
1031
1032 if (to_ds)
1033 return hdr->addr3;
1034 return hdr->addr1;
1035}
1036
1037static inline int ieee80211_get_morefrag(struct ieee80211_hdr *hdr)
1038{
1039 return (le16_to_cpu(hdr->frame_control) &
1040 IEEE80211_FCTL_MOREFRAGS) != 0;
1041}
1042
1043#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
1044#define MAC_ARG(x) ((u8*)(x))[0], ((u8*)(x))[1], ((u8*)(x))[2], \
1045 ((u8*)(x))[3], ((u8*)(x))[4], ((u8*)(x))[5]
1046
1047#endif /* MAC80211_H */ 1425#endif /* MAC80211_H */
diff --git a/include/net/ndisc.h b/include/net/ndisc.h
index 475b10c575b3..6684f7efbeeb 100644
--- a/include/net/ndisc.h
+++ b/include/net/ndisc.h
@@ -24,6 +24,7 @@ enum {
24 ND_OPT_MTU = 5, /* RFC2461 */ 24 ND_OPT_MTU = 5, /* RFC2461 */
25 __ND_OPT_ARRAY_MAX, 25 __ND_OPT_ARRAY_MAX,
26 ND_OPT_ROUTE_INFO = 24, /* RFC4191 */ 26 ND_OPT_ROUTE_INFO = 24, /* RFC4191 */
27 ND_OPT_RDNSS = 25, /* RFC5006 */
27 __ND_OPT_MAX 28 __ND_OPT_MAX
28}; 29};
29 30
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
new file mode 100644
index 000000000000..93aa87d32804
--- /dev/null
+++ b/include/net/net_namespace.h
@@ -0,0 +1,123 @@
1/*
2 * Operations on the network namespace
3 */
4#ifndef __NET_NET_NAMESPACE_H
5#define __NET_NET_NAMESPACE_H
6
7#include <asm/atomic.h>
8#include <linux/workqueue.h>
9#include <linux/list.h>
10
11struct proc_dir_entry;
12struct net_device;
13struct net {
14 atomic_t count; /* To decided when the network
15 * namespace should be freed.
16 */
17 atomic_t use_count; /* To track references we
18 * destroy on demand
19 */
20 struct list_head list; /* list of network namespaces */
21 struct work_struct work; /* work struct for freeing */
22
23 struct proc_dir_entry *proc_net;
24 struct proc_dir_entry *proc_net_stat;
25 struct proc_dir_entry *proc_net_root;
26
27 struct net_device *loopback_dev; /* The loopback */
28
29 struct list_head dev_base_head;
30 struct hlist_head *dev_name_head;
31 struct hlist_head *dev_index_head;
32};
33
34#ifdef CONFIG_NET
35/* Init's network namespace */
36extern struct net init_net;
37#define INIT_NET_NS(net_ns) .net_ns = &init_net,
38#else
39#define INIT_NET_NS(net_ns)
40#endif
41
42extern struct list_head net_namespace_list;
43
44#ifdef CONFIG_NET
45extern struct net *copy_net_ns(unsigned long flags, struct net *net_ns);
46#else
47static inline struct net *copy_net_ns(unsigned long flags, struct net *net_ns)
48{
49 /* There is nothing to copy so this is a noop */
50 return net_ns;
51}
52#endif
53
54extern void __put_net(struct net *net);
55
56static inline struct net *get_net(struct net *net)
57{
58#ifdef CONFIG_NET
59 atomic_inc(&net->count);
60#endif
61 return net;
62}
63
64static inline struct net *maybe_get_net(struct net *net)
65{
66 /* Used when we know struct net exists but we
67 * aren't guaranteed a previous reference count
68 * exists. If the reference count is zero this
69 * function fails and returns NULL.
70 */
71 if (!atomic_inc_not_zero(&net->count))
72 net = NULL;
73 return net;
74}
75
76static inline void put_net(struct net *net)
77{
78#ifdef CONFIG_NET
79 if (atomic_dec_and_test(&net->count))
80 __put_net(net);
81#endif
82}
83
84static inline struct net *hold_net(struct net *net)
85{
86#ifdef CONFIG_NET
87 atomic_inc(&net->use_count);
88#endif
89 return net;
90}
91
92static inline void release_net(struct net *net)
93{
94#ifdef CONFIG_NET
95 atomic_dec(&net->use_count);
96#endif
97}
98
99#define for_each_net(VAR) \
100 list_for_each_entry(VAR, &net_namespace_list, list)
101
102#ifdef CONFIG_NET_NS
103#define __net_init
104#define __net_exit
105#define __net_initdata
106#else
107#define __net_init __init
108#define __net_exit __exit_refok
109#define __net_initdata __initdata
110#endif
111
112struct pernet_operations {
113 struct list_head list;
114 int (*init)(struct net *net);
115 void (*exit)(struct net *net);
116};
117
118extern int register_pernet_subsys(struct pernet_operations *);
119extern void unregister_pernet_subsys(struct pernet_operations *);
120extern int register_pernet_device(struct pernet_operations *);
121extern void unregister_pernet_device(struct pernet_operations *);
122
123#endif /* __NET_NET_NAMESPACE_H */
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index 810020ec345d..90fb66d99d0c 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -116,9 +116,6 @@ struct nf_conn
116 struct ip_conntrack_counter counters[IP_CT_DIR_MAX]; 116 struct ip_conntrack_counter counters[IP_CT_DIR_MAX];
117#endif 117#endif
118 118
119 /* Unique ID that identifies this conntrack*/
120 unsigned int id;
121
122#if defined(CONFIG_NF_CONNTRACK_MARK) 119#if defined(CONFIG_NF_CONNTRACK_MARK)
123 u_int32_t mark; 120 u_int32_t mark;
124#endif 121#endif
diff --git a/include/net/netfilter/nf_conntrack_expect.h b/include/net/netfilter/nf_conntrack_expect.h
index cae1a0dce365..b47c04f12dbe 100644
--- a/include/net/netfilter/nf_conntrack_expect.h
+++ b/include/net/netfilter/nf_conntrack_expect.h
@@ -38,9 +38,6 @@ struct nf_conntrack_expect
38 /* Usage count. */ 38 /* Usage count. */
39 atomic_t use; 39 atomic_t use;
40 40
41 /* Unique ID */
42 unsigned int id;
43
44 /* Flags */ 41 /* Flags */
45 unsigned int flags; 42 unsigned int flags;
46 43
diff --git a/include/net/netfilter/nf_conntrack_helper.h b/include/net/netfilter/nf_conntrack_helper.h
index d04f99964d94..0dcc4c828ce9 100644
--- a/include/net/netfilter/nf_conntrack_helper.h
+++ b/include/net/netfilter/nf_conntrack_helper.h
@@ -36,7 +36,7 @@ struct nf_conntrack_helper
36 36
37 void (*destroy)(struct nf_conn *ct); 37 void (*destroy)(struct nf_conn *ct);
38 38
39 int (*to_nfattr)(struct sk_buff *skb, const struct nf_conn *ct); 39 int (*to_nlattr)(struct sk_buff *skb, const struct nf_conn *ct);
40}; 40};
41 41
42extern struct nf_conntrack_helper * 42extern struct nf_conntrack_helper *
diff --git a/include/net/netfilter/nf_conntrack_l3proto.h b/include/net/netfilter/nf_conntrack_l3proto.h
index 3c58a2c4df28..15888fc7b72d 100644
--- a/include/net/netfilter/nf_conntrack_l3proto.h
+++ b/include/net/netfilter/nf_conntrack_l3proto.h
@@ -11,11 +11,11 @@
11 11
12#ifndef _NF_CONNTRACK_L3PROTO_H 12#ifndef _NF_CONNTRACK_L3PROTO_H
13#define _NF_CONNTRACK_L3PROTO_H 13#define _NF_CONNTRACK_L3PROTO_H
14#include <linux/netlink.h>
15#include <net/netlink.h>
14#include <linux/seq_file.h> 16#include <linux/seq_file.h>
15#include <net/netfilter/nf_conntrack.h> 17#include <net/netfilter/nf_conntrack.h>
16 18
17struct nfattr;
18
19struct nf_conntrack_l3proto 19struct nf_conntrack_l3proto
20{ 20{
21 /* L3 Protocol Family number. ex) PF_INET */ 21 /* L3 Protocol Family number. ex) PF_INET */
@@ -64,11 +64,12 @@ struct nf_conntrack_l3proto
64 int (*get_l4proto)(const struct sk_buff *skb, unsigned int nhoff, 64 int (*get_l4proto)(const struct sk_buff *skb, unsigned int nhoff,
65 unsigned int *dataoff, u_int8_t *protonum); 65 unsigned int *dataoff, u_int8_t *protonum);
66 66
67 int (*tuple_to_nfattr)(struct sk_buff *skb, 67 int (*tuple_to_nlattr)(struct sk_buff *skb,
68 const struct nf_conntrack_tuple *t); 68 const struct nf_conntrack_tuple *t);
69 69
70 int (*nfattr_to_tuple)(struct nfattr *tb[], 70 int (*nlattr_to_tuple)(struct nlattr *tb[],
71 struct nf_conntrack_tuple *t); 71 struct nf_conntrack_tuple *t);
72 const struct nla_policy *nla_policy;
72 73
73#ifdef CONFIG_SYSCTL 74#ifdef CONFIG_SYSCTL
74 struct ctl_table_header *ctl_table_header; 75 struct ctl_table_header *ctl_table_header;
diff --git a/include/net/netfilter/nf_conntrack_l4proto.h b/include/net/netfilter/nf_conntrack_l4proto.h
index f46cb930414c..fb50c217ba0a 100644
--- a/include/net/netfilter/nf_conntrack_l4proto.h
+++ b/include/net/netfilter/nf_conntrack_l4proto.h
@@ -9,10 +9,11 @@
9 9
10#ifndef _NF_CONNTRACK_L4PROTO_H 10#ifndef _NF_CONNTRACK_L4PROTO_H
11#define _NF_CONNTRACK_L4PROTO_H 11#define _NF_CONNTRACK_L4PROTO_H
12#include <linux/netlink.h>
13#include <net/netlink.h>
12#include <net/netfilter/nf_conntrack.h> 14#include <net/netfilter/nf_conntrack.h>
13 15
14struct seq_file; 16struct seq_file;
15struct nfattr;
16 17
17struct nf_conntrack_l4proto 18struct nf_conntrack_l4proto
18{ 19{
@@ -65,16 +66,17 @@ struct nf_conntrack_l4proto
65 int pf, unsigned int hooknum); 66 int pf, unsigned int hooknum);
66 67
67 /* convert protoinfo to nfnetink attributes */ 68 /* convert protoinfo to nfnetink attributes */
68 int (*to_nfattr)(struct sk_buff *skb, struct nfattr *nfa, 69 int (*to_nlattr)(struct sk_buff *skb, struct nlattr *nla,
69 const struct nf_conn *ct); 70 const struct nf_conn *ct);
70 71
71 /* convert nfnetlink attributes to protoinfo */ 72 /* convert nfnetlink attributes to protoinfo */
72 int (*from_nfattr)(struct nfattr *tb[], struct nf_conn *ct); 73 int (*from_nlattr)(struct nlattr *tb[], struct nf_conn *ct);
73 74
74 int (*tuple_to_nfattr)(struct sk_buff *skb, 75 int (*tuple_to_nlattr)(struct sk_buff *skb,
75 const struct nf_conntrack_tuple *t); 76 const struct nf_conntrack_tuple *t);
76 int (*nfattr_to_tuple)(struct nfattr *tb[], 77 int (*nlattr_to_tuple)(struct nlattr *tb[],
77 struct nf_conntrack_tuple *t); 78 struct nf_conntrack_tuple *t);
79 const struct nla_policy *nla_policy;
78 80
79#ifdef CONFIG_SYSCTL 81#ifdef CONFIG_SYSCTL
80 struct ctl_table_header **ctl_table_header; 82 struct ctl_table_header **ctl_table_header;
@@ -111,10 +113,11 @@ extern int nf_conntrack_l4proto_register(struct nf_conntrack_l4proto *proto);
111extern void nf_conntrack_l4proto_unregister(struct nf_conntrack_l4proto *proto); 113extern void nf_conntrack_l4proto_unregister(struct nf_conntrack_l4proto *proto);
112 114
113/* Generic netlink helpers */ 115/* Generic netlink helpers */
114extern int nf_ct_port_tuple_to_nfattr(struct sk_buff *skb, 116extern int nf_ct_port_tuple_to_nlattr(struct sk_buff *skb,
115 const struct nf_conntrack_tuple *tuple); 117 const struct nf_conntrack_tuple *tuple);
116extern int nf_ct_port_nfattr_to_tuple(struct nfattr *tb[], 118extern int nf_ct_port_nlattr_to_tuple(struct nlattr *tb[],
117 struct nf_conntrack_tuple *t); 119 struct nf_conntrack_tuple *t);
120extern const struct nla_policy nf_ct_port_nla_policy[];
118 121
119/* Log invalid packets */ 122/* Log invalid packets */
120extern unsigned int nf_ct_log_invalid; 123extern unsigned int nf_ct_log_invalid;
diff --git a/include/net/netfilter/nf_nat_protocol.h b/include/net/netfilter/nf_nat_protocol.h
index a9ec5ef61468..14c7b2d7263c 100644
--- a/include/net/netfilter/nf_nat_protocol.h
+++ b/include/net/netfilter/nf_nat_protocol.h
@@ -38,10 +38,10 @@ struct nf_nat_protocol
38 enum nf_nat_manip_type maniptype, 38 enum nf_nat_manip_type maniptype,
39 const struct nf_conn *ct); 39 const struct nf_conn *ct);
40 40
41 int (*range_to_nfattr)(struct sk_buff *skb, 41 int (*range_to_nlattr)(struct sk_buff *skb,
42 const struct nf_nat_range *range); 42 const struct nf_nat_range *range);
43 43
44 int (*nfattr_to_range)(struct nfattr *tb[], 44 int (*nlattr_to_range)(struct nlattr *tb[],
45 struct nf_nat_range *range); 45 struct nf_nat_range *range);
46}; 46};
47 47
@@ -62,9 +62,9 @@ extern int init_protocols(void) __init;
62extern void cleanup_protocols(void); 62extern void cleanup_protocols(void);
63extern struct nf_nat_protocol *find_nat_proto(u_int16_t protonum); 63extern struct nf_nat_protocol *find_nat_proto(u_int16_t protonum);
64 64
65extern int nf_nat_port_range_to_nfattr(struct sk_buff *skb, 65extern int nf_nat_port_range_to_nlattr(struct sk_buff *skb,
66 const struct nf_nat_range *range); 66 const struct nf_nat_range *range);
67extern int nf_nat_port_nfattr_to_range(struct nfattr *tb[], 67extern int nf_nat_port_nlattr_to_range(struct nlattr *tb[],
68 struct nf_nat_range *range); 68 struct nf_nat_range *range);
69 69
70#endif /*_NF_NAT_PROTO_H*/ 70#endif /*_NF_NAT_PROTO_H*/
diff --git a/include/net/netlink.h b/include/net/netlink.h
index d7b824be5422..9298218c07f9 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -84,7 +84,7 @@
84 * nla_next(nla)-----------------------------' 84 * nla_next(nla)-----------------------------'
85 * 85 *
86 * Data Structures: 86 * Data Structures:
87 * struct nlattr netlink attribtue header 87 * struct nlattr netlink attribute header
88 * 88 *
89 * Attribute Construction: 89 * Attribute Construction:
90 * nla_reserve(skb, type, len) reserve room for an attribute 90 * nla_reserve(skb, type, len) reserve room for an attribute
@@ -220,9 +220,9 @@ struct nl_info {
220 u32 pid; 220 u32 pid;
221}; 221};
222 222
223extern void netlink_run_queue(struct sock *sk, unsigned int *qlen, 223extern int netlink_rcv_skb(struct sk_buff *skb,
224 int (*cb)(struct sk_buff *, 224 int (*cb)(struct sk_buff *,
225 struct nlmsghdr *)); 225 struct nlmsghdr *));
226extern int nlmsg_notify(struct sock *sk, struct sk_buff *skb, 226extern int nlmsg_notify(struct sock *sk, struct sk_buff *skb,
227 u32 pid, unsigned int group, int report, 227 u32 pid, unsigned int group, int report,
228 gfp_t flags); 228 gfp_t flags);
@@ -667,6 +667,15 @@ static inline int nla_padlen(int payload)
667} 667}
668 668
669/** 669/**
670 * nla_type - attribute type
671 * @nla: netlink attribute
672 */
673static inline int nla_type(const struct nlattr *nla)
674{
675 return nla->nla_type & NLA_TYPE_MASK;
676}
677
678/**
670 * nla_data - head of payload 679 * nla_data - head of payload
671 * @nla: netlink attribute 680 * @nla: netlink attribute
672 */ 681 */
@@ -697,7 +706,7 @@ static inline int nla_ok(const struct nlattr *nla, int remaining)
697} 706}
698 707
699/** 708/**
700 * nla_next - next netlink attribte in attribute stream 709 * nla_next - next netlink attribute in attribute stream
701 * @nla: netlink attribute 710 * @nla: netlink attribute
702 * @remaining: number of bytes remaining in attribute stream 711 * @remaining: number of bytes remaining in attribute stream
703 * 712 *
@@ -773,7 +782,7 @@ static inline int __nla_parse_nested_compat(struct nlattr *tb[], int maxtype,
773({ data = nla_len(nla) >= len ? nla_data(nla) : NULL; \ 782({ data = nla_len(nla) >= len ? nla_data(nla) : NULL; \
774 __nla_parse_nested_compat(tb, maxtype, nla, policy, len); }) 783 __nla_parse_nested_compat(tb, maxtype, nla, policy, len); })
775/** 784/**
776 * nla_put_u8 - Add a u16 netlink attribute to a socket buffer 785 * nla_put_u8 - Add a u8 netlink attribute to a socket buffer
777 * @skb: socket buffer to add attribute to 786 * @skb: socket buffer to add attribute to
778 * @attrtype: attribute type 787 * @attrtype: attribute type
779 * @value: numeric value 788 * @value: numeric value
@@ -989,7 +998,7 @@ static inline struct nlattr *nla_nest_start(struct sk_buff *skb, int attrtype)
989 998
990/** 999/**
991 * nla_nest_end - Finalize nesting of attributes 1000 * nla_nest_end - Finalize nesting of attributes
992 * @skb: socket buffer the attribtues are stored in 1001 * @skb: socket buffer the attributes are stored in
993 * @start: container attribute 1002 * @start: container attribute
994 * 1003 *
995 * Corrects the container attribute header to include the all 1004 * Corrects the container attribute header to include the all
@@ -1032,7 +1041,7 @@ static inline struct nlattr *nla_nest_compat_start(struct sk_buff *skb,
1032 1041
1033/** 1042/**
1034 * nla_nest_compat_end - Finalize nesting of compat attributes 1043 * nla_nest_compat_end - Finalize nesting of compat attributes
1035 * @skb: socket buffer the attribtues are stored in 1044 * @skb: socket buffer the attributes are stored in
1036 * @start: container attribute 1045 * @start: container attribute
1037 * 1046 *
1038 * Corrects the container attribute header to include the all 1047 * Corrects the container attribute header to include the all
diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h
index 7968b1d66369..f285de69c615 100644
--- a/include/net/pkt_cls.h
+++ b/include/net/pkt_cls.h
@@ -2,6 +2,7 @@
2#define __NET_PKT_CLS_H 2#define __NET_PKT_CLS_H
3 3
4#include <linux/pkt_cls.h> 4#include <linux/pkt_cls.h>
5#include <net/net_namespace.h>
5#include <net/sch_generic.h> 6#include <net/sch_generic.h>
6#include <net/act_api.h> 7#include <net/act_api.h>
7 8
@@ -351,7 +352,7 @@ tcf_match_indev(struct sk_buff *skb, char *indev)
351 if (indev[0]) { 352 if (indev[0]) {
352 if (!skb->iif) 353 if (!skb->iif)
353 return 0; 354 return 0;
354 dev = __dev_get_by_index(skb->iif); 355 dev = __dev_get_by_index(&init_net, skb->iif);
355 if (!dev || strcmp(indev, dev->name)) 356 if (!dev || strcmp(indev, dev->name))
356 return 0; 357 return 0;
357 } 358 }
diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h
index 9e22526e80e7..ab61809a9616 100644
--- a/include/net/pkt_sched.h
+++ b/include/net/pkt_sched.h
@@ -97,10 +97,9 @@ extern int tc_classify(struct sk_buff *skb, struct tcf_proto *tp,
97/* Calculate maximal size of packet seen by hard_start_xmit 97/* Calculate maximal size of packet seen by hard_start_xmit
98 routine of this device. 98 routine of this device.
99 */ 99 */
100static inline unsigned psched_mtu(struct net_device *dev) 100static inline unsigned psched_mtu(const struct net_device *dev)
101{ 101{
102 unsigned mtu = dev->mtu; 102 return dev->mtu + dev->hard_header_len;
103 return dev->hard_header ? mtu + dev->hard_header_len : mtu;
104} 103}
105 104
106#endif 105#endif
diff --git a/include/net/rose.h b/include/net/rose.h
index a4047d3cf5dd..e5bb084d8754 100644
--- a/include/net/rose.h
+++ b/include/net/rose.h
@@ -188,7 +188,7 @@ extern void rose_kick(struct sock *);
188extern void rose_enquiry_response(struct sock *); 188extern void rose_enquiry_response(struct sock *);
189 189
190/* rose_route.c */ 190/* rose_route.c */
191extern struct rose_neigh rose_loopback_neigh; 191extern struct rose_neigh *rose_loopback_neigh;
192extern const struct file_operations rose_neigh_fops; 192extern const struct file_operations rose_neigh_fops;
193extern const struct file_operations rose_nodes_fops; 193extern const struct file_operations rose_nodes_fops;
194extern const struct file_operations rose_routes_fops; 194extern const struct file_operations rose_routes_fops;
diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
index 3861c05cdf0f..793863e09c69 100644
--- a/include/net/rtnetlink.h
+++ b/include/net/rtnetlink.h
@@ -78,6 +78,10 @@ extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
78extern int rtnl_link_register(struct rtnl_link_ops *ops); 78extern int rtnl_link_register(struct rtnl_link_ops *ops);
79extern void rtnl_link_unregister(struct rtnl_link_ops *ops); 79extern void rtnl_link_unregister(struct rtnl_link_ops *ops);
80 80
81extern struct net_device *rtnl_create_link(struct net *net, char *ifname,
82 const struct rtnl_link_ops *ops, struct nlattr *tb[]);
83extern const struct nla_policy ifla_policy[IFLA_MAX+1];
84
81#define MODULE_ALIAS_RTNL_LINK(kind) MODULE_ALIAS("rtnl-link-" kind) 85#define MODULE_ALIAS_RTNL_LINK(kind) MODULE_ALIAS("rtnl-link-" kind)
82 86
83#endif 87#endif
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 8a67f24cbe02..a02ec9e5fea5 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -302,4 +302,18 @@ drop:
302 return NET_XMIT_DROP; 302 return NET_XMIT_DROP;
303} 303}
304 304
305/* Length to Time (L2T) lookup in a qdisc_rate_table, to determine how
306 long it will take to send a packet given its size.
307 */
308static inline u32 qdisc_l2t(struct qdisc_rate_table* rtab, unsigned int pktlen)
309{
310 int slot = pktlen + rtab->rate.cell_align + rtab->rate.overhead;
311 if (slot < 0)
312 slot = 0;
313 slot >>= rtab->rate.cell_log;
314 if (slot > 255)
315 return (rtab->data[255]*(slot >> 8) + rtab->data[slot & 0xFF]);
316 return rtab->data[slot];
317}
318
305#endif 319#endif
diff --git a/include/net/sctp/auth.h b/include/net/sctp/auth.h
new file mode 100644
index 000000000000..4945954a16af
--- /dev/null
+++ b/include/net/sctp/auth.h
@@ -0,0 +1,128 @@
1/* SCTP kernel reference Implementation
2 * (C) Copyright 2007 Hewlett-Packard Development Company, L.P.
3 *
4 * This file is part of the SCTP kernel reference Implementation
5 *
6 * The SCTP reference implementation is free software;
7 * you can redistribute it and/or modify it under the terms of
8 * the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * The SCTP reference implementation is distributed in the hope that it
13 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
14 * ************************
15 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with GNU CC; see the file COPYING. If not, write to
20 * the Free Software Foundation, 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
22 *
23 * Please send any bug reports or fixes you make to the
24 * email address(es):
25 * lksctp developers <lksctp-developers@lists.sourceforge.net>
26 *
27 * Or submit a bug report through the following website:
28 * http://www.sf.net/projects/lksctp
29 *
30 * Written or modified by:
31 * Vlad Yasevich <vladislav.yasevich@hp.com>
32 *
33 * Any bugs reported given to us we will try to fix... any fixes shared will
34 * be incorporated into the next SCTP release.
35 */
36
37#ifndef __sctp_auth_h__
38#define __sctp_auth_h__
39
40#include <linux/list.h>
41#include <linux/crypto.h>
42
43struct sctp_endpoint;
44struct sctp_association;
45struct sctp_authkey;
46struct sctp_hmacalgo;
47
48/*
49 * Define a generic struct that will hold all the info
50 * necessary for an HMAC transform
51 */
52struct sctp_hmac {
53 __u16 hmac_id; /* one of the above ids */
54 char *hmac_name; /* name for loading */
55 __u16 hmac_len; /* length of the signature */
56};
57
58/* This is generic structure that containst authentication bytes used
59 * as keying material. It's a what is referred to as byte-vector all
60 * over SCTP-AUTH
61 */
62struct sctp_auth_bytes {
63 atomic_t refcnt;
64 __u32 len;
65 __u8 data[];
66};
67
68/* Definition for a shared key, weather endpoint or association */
69struct sctp_shared_key {
70 struct list_head key_list;
71 __u16 key_id;
72 struct sctp_auth_bytes *key;
73};
74
75#define key_for_each(__key, __list_head) \
76 list_for_each_entry(__key, __list_head, key_list)
77
78#define key_for_each_safe(__key, __tmp, __list_head) \
79 list_for_each_entry_safe(__key, __tmp, __list_head, key_list)
80
81static inline void sctp_auth_key_hold(struct sctp_auth_bytes *key)
82{
83 if (!key)
84 return;
85
86 atomic_inc(&key->refcnt);
87}
88
89void sctp_auth_key_put(struct sctp_auth_bytes *key);
90struct sctp_shared_key *sctp_auth_shkey_create(__u16 key_id, gfp_t gfp);
91void sctp_auth_shkey_free(struct sctp_shared_key *sh_key);
92void sctp_auth_destroy_keys(struct list_head *keys);
93int sctp_auth_asoc_init_active_key(struct sctp_association *asoc, gfp_t gfp);
94struct sctp_shared_key *sctp_auth_get_shkey(
95 const struct sctp_association *asoc,
96 __u16 key_id);
97int sctp_auth_asoc_copy_shkeys(const struct sctp_endpoint *ep,
98 struct sctp_association *asoc,
99 gfp_t gfp);
100int sctp_auth_init_hmacs(struct sctp_endpoint *ep, gfp_t gfp);
101void sctp_auth_destroy_hmacs(struct crypto_hash *auth_hmacs[]);
102struct sctp_hmac *sctp_auth_get_hmac(__u16 hmac_id);
103struct sctp_hmac *sctp_auth_asoc_get_hmac(const struct sctp_association *asoc);
104void sctp_auth_asoc_set_default_hmac(struct sctp_association *asoc,
105 struct sctp_hmac_algo_param *hmacs);
106int sctp_auth_asoc_verify_hmac_id(const struct sctp_association *asoc,
107 __u16 hmac_id);
108int sctp_auth_send_cid(sctp_cid_t chunk, const struct sctp_association *asoc);
109int sctp_auth_recv_cid(sctp_cid_t chunk, const struct sctp_association *asoc);
110void sctp_auth_calculate_hmac(const struct sctp_association *asoc,
111 struct sk_buff *skb,
112 struct sctp_auth_chunk *auth, gfp_t gfp);
113
114/* API Helpers */
115int sctp_auth_ep_add_chunkid(struct sctp_endpoint *ep, __u8 chunk_id);
116int sctp_auth_ep_set_hmacs(struct sctp_endpoint *ep,
117 struct sctp_hmacalgo *hmacs);
118int sctp_auth_set_key(struct sctp_endpoint *ep,
119 struct sctp_association *asoc,
120 struct sctp_authkey *auth_key);
121int sctp_auth_set_active_key(struct sctp_endpoint *ep,
122 struct sctp_association *asoc,
123 __u16 key_id);
124int sctp_auth_del_key_id(struct sctp_endpoint *ep,
125 struct sctp_association *asoc,
126 __u16 key_id);
127
128#endif
diff --git a/include/net/sctp/command.h b/include/net/sctp/command.h
index f56c8d695a82..b8733364557f 100644
--- a/include/net/sctp/command.h
+++ b/include/net/sctp/command.h
@@ -102,6 +102,7 @@ typedef enum {
102 SCTP_CMD_SET_SK_ERR, /* Set sk_err */ 102 SCTP_CMD_SET_SK_ERR, /* Set sk_err */
103 SCTP_CMD_ASSOC_CHANGE, /* generate and send assoc_change event */ 103 SCTP_CMD_ASSOC_CHANGE, /* generate and send assoc_change event */
104 SCTP_CMD_ADAPTATION_IND, /* generate and send adaptation event */ 104 SCTP_CMD_ADAPTATION_IND, /* generate and send adaptation event */
105 SCTP_CMD_ASSOC_SHKEY, /* generate the association shared keys */
105 SCTP_CMD_LAST 106 SCTP_CMD_LAST
106} sctp_verb_t; 107} sctp_verb_t;
107 108
diff --git a/include/net/sctp/constants.h b/include/net/sctp/constants.h
index bb37724495a5..da8354e8e33c 100644
--- a/include/net/sctp/constants.h
+++ b/include/net/sctp/constants.h
@@ -64,12 +64,18 @@ enum { SCTP_DEFAULT_INSTREAMS = SCTP_MAX_STREAM };
64#define SCTP_CID_MAX SCTP_CID_ASCONF_ACK 64#define SCTP_CID_MAX SCTP_CID_ASCONF_ACK
65 65
66#define SCTP_NUM_BASE_CHUNK_TYPES (SCTP_CID_BASE_MAX + 1) 66#define SCTP_NUM_BASE_CHUNK_TYPES (SCTP_CID_BASE_MAX + 1)
67#define SCTP_NUM_CHUNK_TYPES (SCTP_NUM_BASE_CHUNKTYPES + 2)
68 67
69#define SCTP_NUM_ADDIP_CHUNK_TYPES 2 68#define SCTP_NUM_ADDIP_CHUNK_TYPES 2
70 69
71#define SCTP_NUM_PRSCTP_CHUNK_TYPES 1 70#define SCTP_NUM_PRSCTP_CHUNK_TYPES 1
72 71
72#define SCTP_NUM_AUTH_CHUNK_TYPES 1
73
74#define SCTP_NUM_CHUNK_TYPES (SCTP_NUM_BASE_CHUNK_TYPES + \
75 SCTP_NUM_ADDIP_CHUNK_TYPES +\
76 SCTP_NUM_PRSCTP_CHUNK_TYPES +\
77 SCTP_NUM_AUTH_CHUNK_TYPES)
78
73/* These are the different flavours of event. */ 79/* These are the different flavours of event. */
74typedef enum { 80typedef enum {
75 81
@@ -177,7 +183,9 @@ typedef enum {
177 SCTP_IERROR_NO_DATA, 183 SCTP_IERROR_NO_DATA,
178 SCTP_IERROR_BAD_STREAM, 184 SCTP_IERROR_BAD_STREAM,
179 SCTP_IERROR_BAD_PORTS, 185 SCTP_IERROR_BAD_PORTS,
180 186 SCTP_IERROR_AUTH_BAD_HMAC,
187 SCTP_IERROR_AUTH_BAD_KEYID,
188 SCTP_IERROR_PROTO_VIOLATION,
181} sctp_ierror_t; 189} sctp_ierror_t;
182 190
183 191
@@ -409,4 +417,45 @@ typedef enum {
409 SCTP_LOWER_CWND_INACTIVE, 417 SCTP_LOWER_CWND_INACTIVE,
410} sctp_lower_cwnd_t; 418} sctp_lower_cwnd_t;
411 419
420
421/* SCTP-AUTH Necessary constants */
422
423/* SCTP-AUTH, Section 3.3
424 *
425 * The following Table 2 shows the currently defined values for HMAC
426 * identifiers.
427 *
428 * +-----------------+--------------------------+
429 * | HMAC Identifier | Message Digest Algorithm |
430 * +-----------------+--------------------------+
431 * | 0 | Reserved |
432 * | 1 | SHA-1 defined in [8] |
433 * | 2 | Reserved |
434 * | 3 | SHA-256 defined in [8] |
435 * +-----------------+--------------------------+
436 */
437enum {
438 SCTP_AUTH_HMAC_ID_RESERVED_0,
439 SCTP_AUTH_HMAC_ID_SHA1,
440 SCTP_AUTH_HMAC_ID_RESERVED_2,
441 SCTP_AUTH_HMAC_ID_SHA256
442};
443
444#define SCTP_AUTH_HMAC_ID_MAX SCTP_AUTH_HMAC_ID_SHA256
445#define SCTP_AUTH_NUM_HMACS (SCTP_AUTH_HMAC_ID_SHA256 + 1)
446#define SCTP_SHA1_SIG_SIZE 20
447#define SCTP_SHA256_SIG_SIZE 32
448
449/* SCTP-AUTH, Section 3.2
450 * The chunk types for INIT, INIT-ACK, SHUTDOWN-COMPLETE and AUTH chunks
451 * MUST NOT be listed in the CHUNKS parameter
452 */
453#define SCTP_NUM_NOAUTH_CHUNKS 4
454#define SCTP_AUTH_MAX_CHUNKS (SCTP_NUM_CHUNK_TYPES - SCTP_NUM_NOAUTH_CHUNKS)
455
456/* SCTP-AUTH Section 6.1
457 * The RANDOM parameter MUST contain a 32 byte random number.
458 */
459#define SCTP_AUTH_RANDOM_LENGTH 32
460
412#endif /* __sctp_constants_h__ */ 461#endif /* __sctp_constants_h__ */
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index c9cc00c85782..119f5a1ed499 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -341,6 +341,7 @@ extern atomic_t sctp_dbg_objcnt_bind_bucket;
341extern atomic_t sctp_dbg_objcnt_addr; 341extern atomic_t sctp_dbg_objcnt_addr;
342extern atomic_t sctp_dbg_objcnt_ssnmap; 342extern atomic_t sctp_dbg_objcnt_ssnmap;
343extern atomic_t sctp_dbg_objcnt_datamsg; 343extern atomic_t sctp_dbg_objcnt_datamsg;
344extern atomic_t sctp_dbg_objcnt_keys;
344 345
345/* Macros to atomically increment/decrement objcnt counters. */ 346/* Macros to atomically increment/decrement objcnt counters. */
346#define SCTP_DBG_OBJCNT_INC(name) \ 347#define SCTP_DBG_OBJCNT_INC(name) \
@@ -469,6 +470,11 @@ static inline void sctp_skb_set_owner_r(struct sk_buff *skb, struct sock *sk)
469 skb->sk = sk; 470 skb->sk = sk;
470 skb->destructor = sctp_sock_rfree; 471 skb->destructor = sctp_sock_rfree;
471 atomic_add(event->rmem_len, &sk->sk_rmem_alloc); 472 atomic_add(event->rmem_len, &sk->sk_rmem_alloc);
473 /*
474 * This mimics the behavior of
475 * sk_stream_set_owner_r
476 */
477 sk->sk_forward_alloc -= event->rmem_len;
472} 478}
473 479
474/* Tests if the list has one and only one entry. */ 480/* Tests if the list has one and only one entry. */
diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
index e8e3a64eb322..bf2f5ed69c15 100644
--- a/include/net/sctp/sm.h
+++ b/include/net/sctp/sm.h
@@ -143,6 +143,7 @@ sctp_state_fn_t sctp_sf_do_asconf_ack;
143sctp_state_fn_t sctp_sf_do_9_2_reshutack; 143sctp_state_fn_t sctp_sf_do_9_2_reshutack;
144sctp_state_fn_t sctp_sf_eat_fwd_tsn; 144sctp_state_fn_t sctp_sf_eat_fwd_tsn;
145sctp_state_fn_t sctp_sf_eat_fwd_tsn_fast; 145sctp_state_fn_t sctp_sf_eat_fwd_tsn_fast;
146sctp_state_fn_t sctp_sf_eat_auth;
146 147
147/* Prototypes for primitive event state functions. */ 148/* Prototypes for primitive event state functions. */
148sctp_state_fn_t sctp_sf_do_prm_asoc; 149sctp_state_fn_t sctp_sf_do_prm_asoc;
@@ -256,6 +257,7 @@ int sctp_process_asconf_ack(struct sctp_association *asoc,
256struct sctp_chunk *sctp_make_fwdtsn(const struct sctp_association *asoc, 257struct sctp_chunk *sctp_make_fwdtsn(const struct sctp_association *asoc,
257 __u32 new_cum_tsn, size_t nstreams, 258 __u32 new_cum_tsn, size_t nstreams,
258 struct sctp_fwdtsn_skip *skiplist); 259 struct sctp_fwdtsn_skip *skiplist);
260struct sctp_chunk *sctp_make_auth(const struct sctp_association *asoc);
259 261
260void sctp_chunk_assign_tsn(struct sctp_chunk *); 262void sctp_chunk_assign_tsn(struct sctp_chunk *);
261void sctp_chunk_assign_ssn(struct sctp_chunk *); 263void sctp_chunk_assign_ssn(struct sctp_chunk *);
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index baff49dfcdbd..ef892e00c833 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -64,6 +64,7 @@
64#include <linux/skbuff.h> /* We need sk_buff_head. */ 64#include <linux/skbuff.h> /* We need sk_buff_head. */
65#include <linux/workqueue.h> /* We need tq_struct. */ 65#include <linux/workqueue.h> /* We need tq_struct. */
66#include <linux/sctp.h> /* We need sctp* header structs. */ 66#include <linux/sctp.h> /* We need sctp* header structs. */
67#include <net/sctp/auth.h> /* We need auth specific structs */
67 68
68/* A convenience structure for handling sockaddr structures. 69/* A convenience structure for handling sockaddr structures.
69 * We should wean ourselves off this. 70 * We should wean ourselves off this.
@@ -196,8 +197,6 @@ extern struct sctp_globals {
196 197
197 /* This is the sctp port control hash. */ 198 /* This is the sctp port control hash. */
198 int port_hashsize; 199 int port_hashsize;
199 int port_rover;
200 spinlock_t port_alloc_lock; /* Protects port_rover. */
201 struct sctp_bind_hashbucket *port_hashtable; 200 struct sctp_bind_hashbucket *port_hashtable;
202 201
203 /* This is the global local address list. 202 /* This is the global local address list.
@@ -216,6 +215,9 @@ extern struct sctp_globals {
216 215
217 /* Flag to indicate if PR-SCTP is enabled. */ 216 /* Flag to indicate if PR-SCTP is enabled. */
218 int prsctp_enable; 217 int prsctp_enable;
218
219 /* Flag to idicate if SCTP-AUTH is enabled */
220 int auth_enable;
219} sctp_globals; 221} sctp_globals;
220 222
221#define sctp_rto_initial (sctp_globals.rto_initial) 223#define sctp_rto_initial (sctp_globals.rto_initial)
@@ -248,6 +250,7 @@ extern struct sctp_globals {
248#define sctp_local_addr_lock (sctp_globals.addr_list_lock) 250#define sctp_local_addr_lock (sctp_globals.addr_list_lock)
249#define sctp_addip_enable (sctp_globals.addip_enable) 251#define sctp_addip_enable (sctp_globals.addip_enable)
250#define sctp_prsctp_enable (sctp_globals.prsctp_enable) 252#define sctp_prsctp_enable (sctp_globals.prsctp_enable)
253#define sctp_auth_enable (sctp_globals.auth_enable)
251 254
252/* SCTP Socket type: UDP or TCP style. */ 255/* SCTP Socket type: UDP or TCP style. */
253typedef enum { 256typedef enum {
@@ -397,6 +400,9 @@ struct sctp_cookie {
397 400
398 __u32 adaptation_ind; 401 __u32 adaptation_ind;
399 402
403 __u8 auth_random[sizeof(sctp_paramhdr_t) + SCTP_AUTH_RANDOM_LENGTH];
404 __u8 auth_hmacs[SCTP_AUTH_NUM_HMACS + 2];
405 __u8 auth_chunks[sizeof(sctp_paramhdr_t) + SCTP_AUTH_MAX_CHUNKS];
400 406
401 /* This is a shim for my peer's INIT packet, followed by 407 /* This is a shim for my peer's INIT packet, followed by
402 * a copy of the raw address list of the association. 408 * a copy of the raw address list of the association.
@@ -440,6 +446,10 @@ union sctp_params {
440 struct sctp_ipv6addr_param *v6; 446 struct sctp_ipv6addr_param *v6;
441 union sctp_addr_param *addr; 447 union sctp_addr_param *addr;
442 struct sctp_adaptation_ind_param *aind; 448 struct sctp_adaptation_ind_param *aind;
449 struct sctp_supported_ext_param *ext;
450 struct sctp_random_param *random;
451 struct sctp_chunks_param *chunks;
452 struct sctp_hmac_algo_param *hmac_algo;
443}; 453};
444 454
445/* RFC 2960. Section 3.3.5 Heartbeat. 455/* RFC 2960. Section 3.3.5 Heartbeat.
@@ -678,6 +688,7 @@ struct sctp_chunk {
678 struct sctp_errhdr *err_hdr; 688 struct sctp_errhdr *err_hdr;
679 struct sctp_addiphdr *addip_hdr; 689 struct sctp_addiphdr *addip_hdr;
680 struct sctp_fwdtsn_hdr *fwdtsn_hdr; 690 struct sctp_fwdtsn_hdr *fwdtsn_hdr;
691 struct sctp_authhdr *auth_hdr;
681 } subh; 692 } subh;
682 693
683 __u8 *chunk_end; 694 __u8 *chunk_end;
@@ -711,6 +722,13 @@ struct sctp_chunk {
711 */ 722 */
712 struct sctp_transport *transport; 723 struct sctp_transport *transport;
713 724
725 /* SCTP-AUTH: For the special case inbound processing of COOKIE-ECHO
726 * we need save a pointer to the AUTH chunk, since the SCTP-AUTH
727 * spec violates the principle premis that all chunks are processed
728 * in order.
729 */
730 struct sk_buff *auth_chunk;
731
714 __u8 rtt_in_progress; /* Is this chunk used for RTT calculation? */ 732 __u8 rtt_in_progress; /* Is this chunk used for RTT calculation? */
715 __u8 resent; /* Has this chunk ever been retransmitted. */ 733 __u8 resent; /* Has this chunk ever been retransmitted. */
716 __u8 has_tsn; /* Does this chunk have a TSN yet? */ 734 __u8 has_tsn; /* Does this chunk have a TSN yet? */
@@ -723,6 +741,7 @@ struct sctp_chunk {
723 __s8 fast_retransmit; /* Is this chunk fast retransmitted? */ 741 __s8 fast_retransmit; /* Is this chunk fast retransmitted? */
724 __u8 tsn_missing_report; /* Data chunk missing counter. */ 742 __u8 tsn_missing_report; /* Data chunk missing counter. */
725 __u8 data_accepted; /* At least 1 chunk in this packet accepted */ 743 __u8 data_accepted; /* At least 1 chunk in this packet accepted */
744 __u8 auth; /* IN: was auth'ed | OUT: needs auth */
726}; 745};
727 746
728void sctp_chunk_hold(struct sctp_chunk *); 747void sctp_chunk_hold(struct sctp_chunk *);
@@ -731,7 +750,6 @@ int sctp_user_addto_chunk(struct sctp_chunk *chunk, int off, int len,
731 struct iovec *data); 750 struct iovec *data);
732void sctp_chunk_free(struct sctp_chunk *); 751void sctp_chunk_free(struct sctp_chunk *);
733void *sctp_addto_chunk(struct sctp_chunk *, int len, const void *data); 752void *sctp_addto_chunk(struct sctp_chunk *, int len, const void *data);
734void *sctp_addto_param(struct sctp_chunk *, int len, const void *data);
735struct sctp_chunk *sctp_chunkify(struct sk_buff *, 753struct sctp_chunk *sctp_chunkify(struct sk_buff *,
736 const struct sctp_association *, 754 const struct sctp_association *,
737 struct sock *); 755 struct sock *);
@@ -773,16 +791,25 @@ struct sctp_packet {
773 */ 791 */
774 struct sctp_transport *transport; 792 struct sctp_transport *transport;
775 793
794 /* pointer to the auth chunk for this packet */
795 struct sctp_chunk *auth;
796
776 /* This packet contains a COOKIE-ECHO chunk. */ 797 /* This packet contains a COOKIE-ECHO chunk. */
777 char has_cookie_echo; 798 __u8 has_cookie_echo;
799
800 /* This packet contains a SACK chunk. */
801 __u8 has_sack;
802
803 /* This packet contains an AUTH chunk */
804 __u8 has_auth;
778 805
779 /* This packet containsa SACK chunk. */ 806 /* This packet contains at least 1 DATA chunk */
780 char has_sack; 807 __u8 has_data;
781 808
782 /* SCTP cannot fragment this packet. So let ip fragment it. */ 809 /* SCTP cannot fragment this packet. So let ip fragment it. */
783 char ipfragok; 810 __u8 ipfragok;
784 811
785 int malloced; 812 __u8 malloced;
786}; 813};
787 814
788struct sctp_packet *sctp_packet_init(struct sctp_packet *, 815struct sctp_packet *sctp_packet_init(struct sctp_packet *,
@@ -1045,6 +1072,7 @@ void sctp_inq_init(struct sctp_inq *);
1045void sctp_inq_free(struct sctp_inq *); 1072void sctp_inq_free(struct sctp_inq *);
1046void sctp_inq_push(struct sctp_inq *, struct sctp_chunk *packet); 1073void sctp_inq_push(struct sctp_inq *, struct sctp_chunk *packet);
1047struct sctp_chunk *sctp_inq_pop(struct sctp_inq *); 1074struct sctp_chunk *sctp_inq_pop(struct sctp_inq *);
1075struct sctp_chunkhdr *sctp_inq_peek(struct sctp_inq *);
1048void sctp_inq_set_th_handler(struct sctp_inq *, work_func_t); 1076void sctp_inq_set_th_handler(struct sctp_inq *, work_func_t);
1049 1077
1050/* This is the structure we use to hold outbound chunks. You push 1078/* This is the structure we use to hold outbound chunks. You push
@@ -1291,6 +1319,21 @@ struct sctp_endpoint {
1291 1319
1292 /* rcvbuf acct. policy. */ 1320 /* rcvbuf acct. policy. */
1293 __u32 rcvbuf_policy; 1321 __u32 rcvbuf_policy;
1322
1323 /* SCTP AUTH: array of the HMACs that will be allocated
1324 * we need this per association so that we don't serialize
1325 */
1326 struct crypto_hash **auth_hmacs;
1327
1328 /* SCTP-AUTH: hmacs for the endpoint encoded into parameter */
1329 struct sctp_hmac_algo_param *auth_hmacs_list;
1330
1331 /* SCTP-AUTH: chunks to authenticate encoded into parameter */
1332 struct sctp_chunks_param *auth_chunk_list;
1333
1334 /* SCTP-AUTH: endpoint shared keys */
1335 struct list_head endpoint_shared_keys;
1336 __u16 active_key_id;
1294}; 1337};
1295 1338
1296/* Recover the outter endpoint structure. */ 1339/* Recover the outter endpoint structure. */
@@ -1497,6 +1540,8 @@ struct sctp_association {
1497 __u8 hostname_address;/* Peer understands DNS addresses? */ 1540 __u8 hostname_address;/* Peer understands DNS addresses? */
1498 __u8 asconf_capable; /* Does peer support ADDIP? */ 1541 __u8 asconf_capable; /* Does peer support ADDIP? */
1499 __u8 prsctp_capable; /* Can peer do PR-SCTP? */ 1542 __u8 prsctp_capable; /* Can peer do PR-SCTP? */
1543 __u8 auth_capable; /* Is peer doing SCTP-AUTH? */
1544 __u8 addip_capable; /* Can peer do ADD-IP */
1500 1545
1501 __u32 adaptation_ind; /* Adaptation Code point. */ 1546 __u32 adaptation_ind; /* Adaptation Code point. */
1502 1547
@@ -1514,6 +1559,14 @@ struct sctp_association {
1514 * Initial TSN Value minus 1 1559 * Initial TSN Value minus 1
1515 */ 1560 */
1516 __u32 addip_serial; 1561 __u32 addip_serial;
1562
1563 /* SCTP-AUTH: We need to know pears random number, hmac list
1564 * and authenticated chunk list. All that is part of the
1565 * cookie and these are just pointers to those locations
1566 */
1567 sctp_random_param_t *peer_random;
1568 sctp_chunks_param_t *peer_chunks;
1569 sctp_hmac_algo_param_t *peer_hmacs;
1517 } peer; 1570 } peer;
1518 1571
1519 /* State : A state variable indicating what state the 1572 /* State : A state variable indicating what state the
@@ -1797,6 +1850,24 @@ struct sctp_association {
1797 */ 1850 */
1798 __u32 addip_serial; 1851 __u32 addip_serial;
1799 1852
1853 /* SCTP AUTH: list of the endpoint shared keys. These
1854 * keys are provided out of band by the user applicaton
1855 * and can't change during the lifetime of the association
1856 */
1857 struct list_head endpoint_shared_keys;
1858
1859 /* SCTP AUTH:
1860 * The current generated assocaition shared key (secret)
1861 */
1862 struct sctp_auth_bytes *asoc_shared_key;
1863
1864 /* SCTP AUTH: hmac id of the first peer requested algorithm
1865 * that we support.
1866 */
1867 __u16 default_hmac_id;
1868
1869 __u16 active_key_id;
1870
1800 /* Need to send an ECNE Chunk? */ 1871 /* Need to send an ECNE Chunk? */
1801 char need_ecne; 1872 char need_ecne;
1802 1873
diff --git a/include/net/sctp/ulpevent.h b/include/net/sctp/ulpevent.h
index de88ed5b0ba6..922a151eb93c 100644
--- a/include/net/sctp/ulpevent.h
+++ b/include/net/sctp/ulpevent.h
@@ -128,6 +128,10 @@ struct sctp_ulpevent *sctp_ulpevent_make_rcvmsg(struct sctp_association *asoc,
128 struct sctp_chunk *chunk, 128 struct sctp_chunk *chunk,
129 gfp_t gfp); 129 gfp_t gfp);
130 130
131struct sctp_ulpevent *sctp_ulpevent_make_authkey(
132 const struct sctp_association *asoc, __u16 key_id,
133 __u32 indication, gfp_t gfp);
134
131void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event, 135void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event,
132 struct msghdr *); 136 struct msghdr *);
133__u16 sctp_ulpevent_get_notification_type(const struct sctp_ulpevent *event); 137__u16 sctp_ulpevent_get_notification_type(const struct sctp_ulpevent *event);
diff --git a/include/net/sctp/user.h b/include/net/sctp/user.h
index 6d2b57758cca..00848b641f59 100644
--- a/include/net/sctp/user.h
+++ b/include/net/sctp/user.h
@@ -103,6 +103,21 @@ enum sctp_optname {
103#define SCTP_PARTIAL_DELIVERY_POINT SCTP_PARTIAL_DELIVERY_POINT 103#define SCTP_PARTIAL_DELIVERY_POINT SCTP_PARTIAL_DELIVERY_POINT
104 SCTP_MAX_BURST, /* Set/Get max burst */ 104 SCTP_MAX_BURST, /* Set/Get max burst */
105#define SCTP_MAX_BURST SCTP_MAX_BURST 105#define SCTP_MAX_BURST SCTP_MAX_BURST
106 SCTP_AUTH_CHUNK, /* Set only: add a chunk type to authenticat */
107#define SCTP_AUTH_CHUNK SCTP_AUTH_CHUNK
108 SCTP_HMAC_IDENT,
109#define SCTP_HMAC_IDENT SCTP_HMAC_IDENT
110 SCTP_AUTH_KEY,
111#define SCTP_AUTH_KEY SCTP_AUTH_KEY
112 SCTP_AUTH_ACTIVE_KEY,
113#define SCTP_AUTH_ACTIVE_KEY SCTP_AUTH_ACTIVE_KEY
114 SCTP_AUTH_DELETE_KEY,
115#define SCTP_AUTH_DELETE_KEY SCTP_AUTH_DELETE_KEY
116 SCTP_PEER_AUTH_CHUNKS, /* Read only */
117#define SCTP_PEER_AUTH_CHUNKS SCTP_PEER_AUTH_CHUNKS
118 SCTP_LOCAL_AUTH_CHUNKS, /* Read only */
119#define SCTP_LOCAL_AUTH_CHUNKS SCTP_LOCAL_AUTH_CHUNKS
120
106 121
107 /* Internal Socket Options. Some of the sctp library functions are 122 /* Internal Socket Options. Some of the sctp library functions are
108 * implemented using these socket options. 123 * implemented using these socket options.
@@ -370,6 +385,19 @@ struct sctp_pdapi_event {
370 385
371enum { SCTP_PARTIAL_DELIVERY_ABORTED=0, }; 386enum { SCTP_PARTIAL_DELIVERY_ABORTED=0, };
372 387
388struct sctp_authkey_event {
389 __u16 auth_type;
390 __u16 auth_flags;
391 __u32 auth_length;
392 __u16 auth_keynumber;
393 __u16 auth_altkeynumber;
394 __u32 auth_indication;
395 sctp_assoc_t auth_assoc_id;
396};
397
398enum { SCTP_AUTH_NEWKEY = 0, };
399
400
373/* 401/*
374 * Described in Section 7.3 402 * Described in Section 7.3
375 * Ancillary Data and Notification Interest Options 403 * Ancillary Data and Notification Interest Options
@@ -405,6 +433,7 @@ union sctp_notification {
405 struct sctp_shutdown_event sn_shutdown_event; 433 struct sctp_shutdown_event sn_shutdown_event;
406 struct sctp_adaptation_event sn_adaptation_event; 434 struct sctp_adaptation_event sn_adaptation_event;
407 struct sctp_pdapi_event sn_pdapi_event; 435 struct sctp_pdapi_event sn_pdapi_event;
436 struct sctp_authkey_event sn_authkey_event;
408}; 437};
409 438
410/* Section 5.3.1 439/* Section 5.3.1
@@ -421,6 +450,7 @@ enum sctp_sn_type {
421 SCTP_SHUTDOWN_EVENT, 450 SCTP_SHUTDOWN_EVENT,
422 SCTP_PARTIAL_DELIVERY_EVENT, 451 SCTP_PARTIAL_DELIVERY_EVENT,
423 SCTP_ADAPTATION_INDICATION, 452 SCTP_ADAPTATION_INDICATION,
453 SCTP_AUTHENTICATION_EVENT,
424}; 454};
425 455
426/* Notification error codes used to fill up the error fields in some 456/* Notification error codes used to fill up the error fields in some
@@ -539,6 +569,54 @@ struct sctp_paddrparams {
539 __u32 spp_flags; 569 __u32 spp_flags;
540} __attribute__((packed, aligned(4))); 570} __attribute__((packed, aligned(4)));
541 571
572/*
573 * 7.1.18. Add a chunk that must be authenticated (SCTP_AUTH_CHUNK)
574 *
575 * This set option adds a chunk type that the user is requesting to be
576 * received only in an authenticated way. Changes to the list of chunks
577 * will only effect future associations on the socket.
578 */
579struct sctp_authchunk {
580 __u8 sauth_chunk;
581};
582
583/*
584 * 7.1.19. Get or set the list of supported HMAC Identifiers (SCTP_HMAC_IDENT)
585 *
586 * This option gets or sets the list of HMAC algorithms that the local
587 * endpoint requires the peer to use.
588*/
589struct sctp_hmacalgo {
590 __u16 shmac_num_idents;
591 __u16 shmac_idents[];
592};
593
594/*
595 * 7.1.20. Set a shared key (SCTP_AUTH_KEY)
596 *
597 * This option will set a shared secret key which is used to build an
598 * association shared key.
599 */
600struct sctp_authkey {
601 sctp_assoc_t sca_assoc_id;
602 __u16 sca_keynumber;
603 __u16 sca_keylen;
604 __u8 sca_key[];
605};
606
607/*
608 * 7.1.21. Get or set the active shared key (SCTP_AUTH_ACTIVE_KEY)
609 *
610 * This option will get or set the active shared key to be used to build
611 * the association shared key.
612 */
613
614struct sctp_authkeyid {
615 sctp_assoc_t scact_assoc_id;
616 __u16 scact_keynumber;
617};
618
619
542/* 7.1.23. Delayed Ack Timer (SCTP_DELAYED_ACK_TIME) 620/* 7.1.23. Delayed Ack Timer (SCTP_DELAYED_ACK_TIME)
543 * 621 *
544 * This options will get or set the delayed ack timer. The time is set 622 * This options will get or set the delayed ack timer. The time is set
@@ -608,6 +686,18 @@ struct sctp_status {
608}; 686};
609 687
610/* 688/*
689 * 7.2.3. Get the list of chunks the peer requires to be authenticated
690 * (SCTP_PEER_AUTH_CHUNKS)
691 *
692 * This option gets a list of chunks for a specified association that
693 * the peer requires to be received authenticated only.
694 */
695struct sctp_authchunks {
696 sctp_assoc_t gauth_assoc_id;
697 uint8_t gauth_chunks[];
698};
699
700/*
611 * 8.3, 8.5 get all peer/local addresses in an association. 701 * 8.3, 8.5 get all peer/local addresses in an association.
612 * This parameter struct is used by SCTP_GET_PEER_ADDRS and 702 * This parameter struct is used by SCTP_GET_PEER_ADDRS and
613 * SCTP_GET_LOCAL_ADDRS socket options used internally to implement 703 * SCTP_GET_LOCAL_ADDRS socket options used internally to implement
diff --git a/include/net/snmp.h b/include/net/snmp.h
index 464970e39ec0..ea206bff0dc4 100644
--- a/include/net/snmp.h
+++ b/include/net/snmp.h
@@ -82,12 +82,23 @@ struct icmp_mib {
82 unsigned long mibs[ICMP_MIB_MAX]; 82 unsigned long mibs[ICMP_MIB_MAX];
83} __SNMP_MIB_ALIGN__; 83} __SNMP_MIB_ALIGN__;
84 84
85#define ICMPMSG_MIB_MAX __ICMPMSG_MIB_MAX
86struct icmpmsg_mib {
87 unsigned long mibs[ICMPMSG_MIB_MAX];
88} __SNMP_MIB_ALIGN__;
89
85/* ICMP6 (IPv6-ICMP) */ 90/* ICMP6 (IPv6-ICMP) */
86#define ICMP6_MIB_MAX __ICMP6_MIB_MAX 91#define ICMP6_MIB_MAX __ICMP6_MIB_MAX
87struct icmpv6_mib { 92struct icmpv6_mib {
88 unsigned long mibs[ICMP6_MIB_MAX]; 93 unsigned long mibs[ICMP6_MIB_MAX];
89} __SNMP_MIB_ALIGN__; 94} __SNMP_MIB_ALIGN__;
90 95
96#define ICMP6MSG_MIB_MAX __ICMP6MSG_MIB_MAX
97struct icmpv6msg_mib {
98 unsigned long mibs[ICMP6MSG_MIB_MAX];
99} __SNMP_MIB_ALIGN__;
100
101
91/* TCP */ 102/* TCP */
92#define TCP_MIB_MAX __TCP_MIB_MAX 103#define TCP_MIB_MAX __TCP_MIB_MAX
93struct tcp_mib { 104struct tcp_mib {
diff --git a/include/net/sock.h b/include/net/sock.h
index dfeb8b13024f..453c79d0915b 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -40,6 +40,7 @@
40#ifndef _SOCK_H 40#ifndef _SOCK_H
41#define _SOCK_H 41#define _SOCK_H
42 42
43#include <linux/kernel.h>
43#include <linux/list.h> 44#include <linux/list.h>
44#include <linux/timer.h> 45#include <linux/timer.h>
45#include <linux/cache.h> 46#include <linux/cache.h>
@@ -55,6 +56,7 @@
55#include <asm/atomic.h> 56#include <asm/atomic.h>
56#include <net/dst.h> 57#include <net/dst.h>
57#include <net/checksum.h> 58#include <net/checksum.h>
59#include <net/net_namespace.h>
58 60
59/* 61/*
60 * This structure really needs to be cleaned up. 62 * This structure really needs to be cleaned up.
@@ -75,10 +77,9 @@
75 * between user contexts and software interrupt processing, whereas the 77 * between user contexts and software interrupt processing, whereas the
76 * mini-semaphore synchronizes multiple users amongst themselves. 78 * mini-semaphore synchronizes multiple users amongst themselves.
77 */ 79 */
78struct sock_iocb;
79typedef struct { 80typedef struct {
80 spinlock_t slock; 81 spinlock_t slock;
81 struct sock_iocb *owner; 82 int owned;
82 wait_queue_head_t wq; 83 wait_queue_head_t wq;
83 /* 84 /*
84 * We express the mutex-alike socket_lock semantics 85 * We express the mutex-alike socket_lock semantics
@@ -105,6 +106,7 @@ struct proto;
105 * @skc_refcnt: reference count 106 * @skc_refcnt: reference count
106 * @skc_hash: hash value used with various protocol lookup tables 107 * @skc_hash: hash value used with various protocol lookup tables
107 * @skc_prot: protocol handlers inside a network family 108 * @skc_prot: protocol handlers inside a network family
109 * @skc_net: reference to the network namespace of this socket
108 * 110 *
109 * This is the minimal network layer representation of sockets, the header 111 * This is the minimal network layer representation of sockets, the header
110 * for struct sock and struct inet_timewait_sock. 112 * for struct sock and struct inet_timewait_sock.
@@ -119,6 +121,7 @@ struct sock_common {
119 atomic_t skc_refcnt; 121 atomic_t skc_refcnt;
120 unsigned int skc_hash; 122 unsigned int skc_hash;
121 struct proto *skc_prot; 123 struct proto *skc_prot;
124 struct net *skc_net;
122}; 125};
123 126
124/** 127/**
@@ -195,6 +198,7 @@ struct sock {
195#define sk_refcnt __sk_common.skc_refcnt 198#define sk_refcnt __sk_common.skc_refcnt
196#define sk_hash __sk_common.skc_hash 199#define sk_hash __sk_common.skc_hash
197#define sk_prot __sk_common.skc_prot 200#define sk_prot __sk_common.skc_prot
201#define sk_net __sk_common.skc_net
198 unsigned char sk_shutdown : 2, 202 unsigned char sk_shutdown : 2,
199 sk_no_check : 2, 203 sk_no_check : 2,
200 sk_userlocks : 4; 204 sk_userlocks : 4;
@@ -481,17 +485,17 @@ static inline void sk_add_backlog(struct sock *sk, struct sk_buff *skb)
481 skb->next = NULL; 485 skb->next = NULL;
482} 486}
483 487
484#define sk_wait_event(__sk, __timeo, __condition) \ 488#define sk_wait_event(__sk, __timeo, __condition) \
485({ int rc; \ 489 ({ int __rc; \
486 release_sock(__sk); \ 490 release_sock(__sk); \
487 rc = __condition; \ 491 __rc = __condition; \
488 if (!rc) { \ 492 if (!__rc) { \
489 *(__timeo) = schedule_timeout(*(__timeo)); \ 493 *(__timeo) = schedule_timeout(*(__timeo)); \
490 } \ 494 } \
491 lock_sock(__sk); \ 495 lock_sock(__sk); \
492 rc = __condition; \ 496 __rc = __condition; \
493 rc; \ 497 __rc; \
494}) 498 })
495 499
496extern int sk_stream_wait_connect(struct sock *sk, long *timeo_p); 500extern int sk_stream_wait_connect(struct sock *sk, long *timeo_p);
497extern int sk_stream_wait_memory(struct sock *sk, long *timeo_p); 501extern int sk_stream_wait_memory(struct sock *sk, long *timeo_p);
@@ -702,7 +706,7 @@ extern int sk_stream_mem_schedule(struct sock *sk, int size, int kind);
702 706
703static inline int sk_stream_pages(int amt) 707static inline int sk_stream_pages(int amt)
704{ 708{
705 return (amt + SK_STREAM_MEM_QUANTUM - 1) / SK_STREAM_MEM_QUANTUM; 709 return DIV_ROUND_UP(amt, SK_STREAM_MEM_QUANTUM);
706} 710}
707 711
708static inline void sk_stream_mem_reclaim(struct sock *sk) 712static inline void sk_stream_mem_reclaim(struct sock *sk)
@@ -736,7 +740,7 @@ static inline int sk_stream_wmem_schedule(struct sock *sk, int size)
736 * Since ~2.3.5 it is also exclusive sleep lock serializing 740 * Since ~2.3.5 it is also exclusive sleep lock serializing
737 * accesses from user process context. 741 * accesses from user process context.
738 */ 742 */
739#define sock_owned_by_user(sk) ((sk)->sk_lock.owner) 743#define sock_owned_by_user(sk) ((sk)->sk_lock.owned)
740 744
741/* 745/*
742 * Macro so as to not evaluate some arguments when 746 * Macro so as to not evaluate some arguments when
@@ -747,7 +751,7 @@ static inline int sk_stream_wmem_schedule(struct sock *sk, int size)
747 */ 751 */
748#define sock_lock_init_class_and_name(sk, sname, skey, name, key) \ 752#define sock_lock_init_class_and_name(sk, sname, skey, name, key) \
749do { \ 753do { \
750 sk->sk_lock.owner = NULL; \ 754 sk->sk_lock.owned = 0; \
751 init_waitqueue_head(&sk->sk_lock.wq); \ 755 init_waitqueue_head(&sk->sk_lock.wq); \
752 spin_lock_init(&(sk)->sk_lock.slock); \ 756 spin_lock_init(&(sk)->sk_lock.slock); \
753 debug_check_no_locks_freed((void *)&(sk)->sk_lock, \ 757 debug_check_no_locks_freed((void *)&(sk)->sk_lock, \
@@ -773,7 +777,7 @@ extern void FASTCALL(release_sock(struct sock *sk));
773 SINGLE_DEPTH_NESTING) 777 SINGLE_DEPTH_NESTING)
774#define bh_unlock_sock(__sk) spin_unlock(&((__sk)->sk_lock.slock)) 778#define bh_unlock_sock(__sk) spin_unlock(&((__sk)->sk_lock.slock))
775 779
776extern struct sock *sk_alloc(int family, 780extern struct sock *sk_alloc(struct net *net, int family,
777 gfp_t priority, 781 gfp_t priority,
778 struct proto *prot, int zero_it); 782 struct proto *prot, int zero_it);
779extern void sk_free(struct sock *sk); 783extern void sk_free(struct sock *sk);
@@ -1002,6 +1006,7 @@ static inline void sock_copy(struct sock *nsk, const struct sock *osk)
1002#endif 1006#endif
1003 1007
1004 memcpy(nsk, osk, osk->sk_prot->obj_size); 1008 memcpy(nsk, osk, osk->sk_prot->obj_size);
1009 get_net(nsk->sk_net);
1005#ifdef CONFIG_SECURITY_NETWORK 1010#ifdef CONFIG_SECURITY_NETWORK
1006 nsk->sk_security = sptr; 1011 nsk->sk_security = sptr;
1007 security_sk_clone(osk, nsk); 1012 security_sk_clone(osk, nsk);
diff --git a/include/net/tc_act/tc_nat.h b/include/net/tc_act/tc_nat.h
new file mode 100644
index 000000000000..4a691f34d703
--- /dev/null
+++ b/include/net/tc_act/tc_nat.h
@@ -0,0 +1,21 @@
1#ifndef __NET_TC_NAT_H
2#define __NET_TC_NAT_H
3
4#include <linux/types.h>
5#include <net/act_api.h>
6
7struct tcf_nat {
8 struct tcf_common common;
9
10 __be32 old_addr;
11 __be32 new_addr;
12 __be32 mask;
13 u32 flags;
14};
15
16static inline struct tcf_nat *to_tcf_nat(struct tcf_common *pc)
17{
18 return container_of(pc, struct tcf_nat, common);
19}
20
21#endif /* __NET_TC_NAT_H */
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 54053de0bdd7..92049e681258 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -39,6 +39,7 @@
39#include <net/snmp.h> 39#include <net/snmp.h>
40#include <net/ip.h> 40#include <net/ip.h>
41#include <net/tcp_states.h> 41#include <net/tcp_states.h>
42#include <net/inet_ecn.h>
42 43
43#include <linux/seq_file.h> 44#include <linux/seq_file.h>
44 45
@@ -330,6 +331,17 @@ static inline void tcp_clear_options(struct tcp_options_received *rx_opt)
330 rx_opt->tstamp_ok = rx_opt->sack_ok = rx_opt->wscale_ok = rx_opt->snd_wscale = 0; 331 rx_opt->tstamp_ok = rx_opt->sack_ok = rx_opt->wscale_ok = rx_opt->snd_wscale = 0;
331} 332}
332 333
334#define TCP_ECN_OK 1
335#define TCP_ECN_QUEUE_CWR 2
336#define TCP_ECN_DEMAND_CWR 4
337
338static __inline__ void
339TCP_ECN_create_request(struct request_sock *req, struct tcphdr *th)
340{
341 if (sysctl_tcp_ecn && th->ece && th->cwr)
342 inet_rsk(req)->ecn_ok = 1;
343}
344
333enum tcp_tw_status 345enum tcp_tw_status
334{ 346{
335 TCP_TW_SUCCESS = 0, 347 TCP_TW_SUCCESS = 0,
@@ -573,8 +585,6 @@ struct tcp_skb_cb {
573 585
574#define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0])) 586#define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
575 587
576#include <net/tcp_ecn.h>
577
578/* Due to TSO, an SKB can be composed of multiple actual 588/* Due to TSO, an SKB can be composed of multiple actual
579 * packets. To keep these tracked properly, we use this. 589 * packets. To keep these tracked properly, we use this.
580 */ 590 */
@@ -589,32 +599,19 @@ static inline int tcp_skb_mss(const struct sk_buff *skb)
589 return skb_shinfo(skb)->gso_size; 599 return skb_shinfo(skb)->gso_size;
590} 600}
591 601
592static inline void tcp_dec_pcount_approx(__u32 *count, 602static inline void tcp_dec_pcount_approx_int(__u32 *count, const int decr)
593 const struct sk_buff *skb)
594{ 603{
595 if (*count) { 604 if (*count) {
596 *count -= tcp_skb_pcount(skb); 605 *count -= decr;
597 if ((int)*count < 0) 606 if ((int)*count < 0)
598 *count = 0; 607 *count = 0;
599 } 608 }
600} 609}
601 610
602static inline void tcp_packets_out_inc(struct sock *sk, 611static inline void tcp_dec_pcount_approx(__u32 *count,
603 const struct sk_buff *skb) 612 const struct sk_buff *skb)
604{
605 struct tcp_sock *tp = tcp_sk(sk);
606 int orig = tp->packets_out;
607
608 tp->packets_out += tcp_skb_pcount(skb);
609 if (!orig)
610 inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS,
611 inet_csk(sk)->icsk_rto, TCP_RTO_MAX);
612}
613
614static inline void tcp_packets_out_dec(struct tcp_sock *tp,
615 const struct sk_buff *skb)
616{ 613{
617 tp->packets_out -= tcp_skb_pcount(skb); 614 tcp_dec_pcount_approx_int(count, tcp_skb_pcount(skb));
618} 615}
619 616
620/* Events passed to congestion control interface */ 617/* Events passed to congestion control interface */
@@ -704,6 +701,39 @@ static inline void tcp_ca_event(struct sock *sk, const enum tcp_ca_event event)
704 icsk->icsk_ca_ops->cwnd_event(sk, event); 701 icsk->icsk_ca_ops->cwnd_event(sk, event);
705} 702}
706 703
704/* These functions determine how the current flow behaves in respect of SACK
705 * handling. SACK is negotiated with the peer, and therefore it can vary
706 * between different flows.
707 *
708 * tcp_is_sack - SACK enabled
709 * tcp_is_reno - No SACK
710 * tcp_is_fack - FACK enabled, implies SACK enabled
711 */
712static inline int tcp_is_sack(const struct tcp_sock *tp)
713{
714 return tp->rx_opt.sack_ok;
715}
716
717static inline int tcp_is_reno(const struct tcp_sock *tp)
718{
719 return !tcp_is_sack(tp);
720}
721
722static inline int tcp_is_fack(const struct tcp_sock *tp)
723{
724 return tp->rx_opt.sack_ok & 2;
725}
726
727static inline void tcp_enable_fack(struct tcp_sock *tp)
728{
729 tp->rx_opt.sack_ok |= 2;
730}
731
732static inline unsigned int tcp_left_out(const struct tcp_sock *tp)
733{
734 return tp->sacked_out + tp->lost_out;
735}
736
707/* This determines how many packets are "in the network" to the best 737/* This determines how many packets are "in the network" to the best
708 * of our knowledge. In many cases it is conservative, but where 738 * of our knowledge. In many cases it is conservative, but where
709 * detailed information is available from the receiver (via SACK 739 * detailed information is available from the receiver (via SACK
@@ -720,7 +750,7 @@ static inline void tcp_ca_event(struct sock *sk, const enum tcp_ca_event event)
720 */ 750 */
721static inline unsigned int tcp_packets_in_flight(const struct tcp_sock *tp) 751static inline unsigned int tcp_packets_in_flight(const struct tcp_sock *tp)
722{ 752{
723 return (tp->packets_out - tp->left_out + tp->retrans_out); 753 return tp->packets_out - tcp_left_out(tp) + tp->retrans_out;
724} 754}
725 755
726/* If cwnd > ssthresh, we may raise ssthresh to be half-way to cwnd. 756/* If cwnd > ssthresh, we may raise ssthresh to be half-way to cwnd.
@@ -738,12 +768,8 @@ static inline __u32 tcp_current_ssthresh(const struct sock *sk)
738 (tp->snd_cwnd >> 2))); 768 (tp->snd_cwnd >> 2)));
739} 769}
740 770
741static inline void tcp_sync_left_out(struct tcp_sock *tp) 771/* Use define here intentionally to get WARN_ON location shown at the caller */
742{ 772#define tcp_verify_left_out(tp) WARN_ON(tcp_left_out(tp) > tp->packets_out)
743 BUG_ON(tp->rx_opt.sack_ok &&
744 (tp->sacked_out + tp->lost_out > tp->packets_out));
745 tp->left_out = tp->sacked_out + tp->lost_out;
746}
747 773
748extern void tcp_enter_cwr(struct sock *sk, const int set_ssthresh); 774extern void tcp_enter_cwr(struct sock *sk, const int set_ssthresh);
749extern __u32 tcp_init_cwnd(struct tcp_sock *tp, struct dst_entry *dst); 775extern __u32 tcp_init_cwnd(struct tcp_sock *tp, struct dst_entry *dst);
@@ -1040,12 +1066,18 @@ static inline void tcp_mib_init(void)
1040 TCP_ADD_STATS_USER(TCP_MIB_MAXCONN, -1); 1066 TCP_ADD_STATS_USER(TCP_MIB_MAXCONN, -1);
1041} 1067}
1042 1068
1043/*from STCP */ 1069/* from STCP */
1044static inline void clear_all_retrans_hints(struct tcp_sock *tp){ 1070static inline void tcp_clear_retrans_hints_partial(struct tcp_sock *tp)
1071{
1045 tp->lost_skb_hint = NULL; 1072 tp->lost_skb_hint = NULL;
1046 tp->scoreboard_skb_hint = NULL; 1073 tp->scoreboard_skb_hint = NULL;
1047 tp->retransmit_skb_hint = NULL; 1074 tp->retransmit_skb_hint = NULL;
1048 tp->forward_skb_hint = NULL; 1075 tp->forward_skb_hint = NULL;
1076}
1077
1078static inline void tcp_clear_all_retrans_hints(struct tcp_sock *tp)
1079{
1080 tcp_clear_retrans_hints_partial(tp);
1049 tp->fastpath_skb_hint = NULL; 1081 tp->fastpath_skb_hint = NULL;
1050} 1082}
1051 1083
diff --git a/include/net/tcp_ecn.h b/include/net/tcp_ecn.h
deleted file mode 100644
index 89eb3e05116d..000000000000
--- a/include/net/tcp_ecn.h
+++ /dev/null
@@ -1,130 +0,0 @@
1#ifndef _NET_TCP_ECN_H_
2#define _NET_TCP_ECN_H_ 1
3
4#include <net/inet_ecn.h>
5#include <net/request_sock.h>
6
7#define TCP_HP_BITS (~(TCP_RESERVED_BITS|TCP_FLAG_PSH))
8
9#define TCP_ECN_OK 1
10#define TCP_ECN_QUEUE_CWR 2
11#define TCP_ECN_DEMAND_CWR 4
12
13static inline void TCP_ECN_queue_cwr(struct tcp_sock *tp)
14{
15 if (tp->ecn_flags&TCP_ECN_OK)
16 tp->ecn_flags |= TCP_ECN_QUEUE_CWR;
17}
18
19
20/* Output functions */
21
22static inline void TCP_ECN_send_synack(struct tcp_sock *tp,
23 struct sk_buff *skb)
24{
25 TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_CWR;
26 if (!(tp->ecn_flags&TCP_ECN_OK))
27 TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_ECE;
28}
29
30static inline void TCP_ECN_send_syn(struct sock *sk, struct sk_buff *skb)
31{
32 struct tcp_sock *tp = tcp_sk(sk);
33
34 tp->ecn_flags = 0;
35 if (sysctl_tcp_ecn) {
36 TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_ECE|TCPCB_FLAG_CWR;
37 tp->ecn_flags = TCP_ECN_OK;
38 }
39}
40
41static __inline__ void
42TCP_ECN_make_synack(struct request_sock *req, struct tcphdr *th)
43{
44 if (inet_rsk(req)->ecn_ok)
45 th->ece = 1;
46}
47
48static inline void TCP_ECN_send(struct sock *sk, struct sk_buff *skb,
49 int tcp_header_len)
50{
51 struct tcp_sock *tp = tcp_sk(sk);
52
53 if (tp->ecn_flags & TCP_ECN_OK) {
54 /* Not-retransmitted data segment: set ECT and inject CWR. */
55 if (skb->len != tcp_header_len &&
56 !before(TCP_SKB_CB(skb)->seq, tp->snd_nxt)) {
57 INET_ECN_xmit(sk);
58 if (tp->ecn_flags&TCP_ECN_QUEUE_CWR) {
59 tp->ecn_flags &= ~TCP_ECN_QUEUE_CWR;
60 tcp_hdr(skb)->cwr = 1;
61 skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_ECN;
62 }
63 } else {
64 /* ACK or retransmitted segment: clear ECT|CE */
65 INET_ECN_dontxmit(sk);
66 }
67 if (tp->ecn_flags & TCP_ECN_DEMAND_CWR)
68 tcp_hdr(skb)->ece = 1;
69 }
70}
71
72/* Input functions */
73
74static inline void TCP_ECN_accept_cwr(struct tcp_sock *tp, struct sk_buff *skb)
75{
76 if (tcp_hdr(skb)->cwr)
77 tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR;
78}
79
80static inline void TCP_ECN_withdraw_cwr(struct tcp_sock *tp)
81{
82 tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR;
83}
84
85static inline void TCP_ECN_check_ce(struct tcp_sock *tp, struct sk_buff *skb)
86{
87 if (tp->ecn_flags&TCP_ECN_OK) {
88 if (INET_ECN_is_ce(TCP_SKB_CB(skb)->flags))
89 tp->ecn_flags |= TCP_ECN_DEMAND_CWR;
90 /* Funny extension: if ECT is not set on a segment,
91 * it is surely retransmit. It is not in ECN RFC,
92 * but Linux follows this rule. */
93 else if (INET_ECN_is_not_ect((TCP_SKB_CB(skb)->flags)))
94 tcp_enter_quickack_mode((struct sock *)tp);
95 }
96}
97
98static inline void TCP_ECN_rcv_synack(struct tcp_sock *tp, struct tcphdr *th)
99{
100 if ((tp->ecn_flags&TCP_ECN_OK) && (!th->ece || th->cwr))
101 tp->ecn_flags &= ~TCP_ECN_OK;
102}
103
104static inline void TCP_ECN_rcv_syn(struct tcp_sock *tp, struct tcphdr *th)
105{
106 if ((tp->ecn_flags&TCP_ECN_OK) && (!th->ece || !th->cwr))
107 tp->ecn_flags &= ~TCP_ECN_OK;
108}
109
110static inline int TCP_ECN_rcv_ecn_echo(struct tcp_sock *tp, struct tcphdr *th)
111{
112 if (th->ece && !th->syn && (tp->ecn_flags&TCP_ECN_OK))
113 return 1;
114 return 0;
115}
116
117static inline void TCP_ECN_openreq_child(struct tcp_sock *tp,
118 struct request_sock *req)
119{
120 tp->ecn_flags = inet_rsk(req)->ecn_ok ? TCP_ECN_OK : 0;
121}
122
123static __inline__ void
124TCP_ECN_create_request(struct request_sock *req, struct tcphdr *th)
125{
126 if (sysctl_tcp_ecn && th->ece && th->cwr)
127 inet_rsk(req)->ecn_ok = 1;
128}
129
130#endif
diff --git a/include/net/veth.h b/include/net/veth.h
new file mode 100644
index 000000000000..3354c1eb424e
--- /dev/null
+++ b/include/net/veth.h
@@ -0,0 +1,12 @@
1#ifndef __NET_VETH_H_
2#define __NET_VETH_H_
3
4enum {
5 VETH_INFO_UNSPEC,
6 VETH_INFO_PEER,
7
8 __VETH_INFO_MAX
9#define VETH_INFO_MAX (__VETH_INFO_MAX - 1)
10};
11
12#endif
diff --git a/include/net/wext.h b/include/net/wext.h
index c02b8decf3af..80b31d826b7a 100644
--- a/include/net/wext.h
+++ b/include/net/wext.h
@@ -5,16 +5,23 @@
5 * wireless extensions interface to the core code 5 * wireless extensions interface to the core code
6 */ 6 */
7 7
8struct net;
9
8#ifdef CONFIG_WIRELESS_EXT 10#ifdef CONFIG_WIRELESS_EXT
9extern int wext_proc_init(void); 11extern int wext_proc_init(struct net *net);
10extern int wext_handle_ioctl(struct ifreq *ifr, unsigned int cmd, 12extern void wext_proc_exit(struct net *net);
13extern int wext_handle_ioctl(struct net *net, struct ifreq *ifr, unsigned int cmd,
11 void __user *arg); 14 void __user *arg);
12#else 15#else
13static inline int wext_proc_init(void) 16static inline int wext_proc_init(struct net *net)
14{ 17{
15 return 0; 18 return 0;
16} 19}
17static inline int wext_handle_ioctl(struct ifreq *ifr, unsigned int cmd, 20static inline void wext_proc_exit(struct net *net)
21{
22 return;
23}
24static inline int wext_handle_ioctl(struct net *net, struct ifreq *ifr, unsigned int cmd,
18 void __user *arg) 25 void __user *arg)
19{ 26{
20 return -EINVAL; 27 return -EINVAL;
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index a5f80bfbaaa4..77be396ca633 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -2,7 +2,6 @@
2#define _NET_XFRM_H 2#define _NET_XFRM_H
3 3
4#include <linux/compiler.h> 4#include <linux/compiler.h>
5#include <linux/in.h>
6#include <linux/xfrm.h> 5#include <linux/xfrm.h>
7#include <linux/spinlock.h> 6#include <linux/spinlock.h>
8#include <linux/list.h> 7#include <linux/list.h>
@@ -12,9 +11,11 @@
12#include <linux/ipsec.h> 11#include <linux/ipsec.h>
13#include <linux/in6.h> 12#include <linux/in6.h>
14#include <linux/mutex.h> 13#include <linux/mutex.h>
14#include <linux/audit.h>
15 15
16#include <net/sock.h> 16#include <net/sock.h>
17#include <net/dst.h> 17#include <net/dst.h>
18#include <net/ip.h>
18#include <net/route.h> 19#include <net/route.h>
19#include <net/ipv6.h> 20#include <net/ipv6.h>
20#include <net/ip6_fib.h> 21#include <net/ip6_fib.h>
@@ -278,6 +279,7 @@ struct xfrm_type
278 __u8 proto; 279 __u8 proto;
279 __u8 flags; 280 __u8 flags;
280#define XFRM_TYPE_NON_FRAGMENT 1 281#define XFRM_TYPE_NON_FRAGMENT 1
282#define XFRM_TYPE_REPLAY_PROT 2
281 283
282 int (*init_state)(struct xfrm_state *x); 284 int (*init_state)(struct xfrm_state *x);
283 void (*destructor)(struct xfrm_state *); 285 void (*destructor)(struct xfrm_state *);
@@ -298,6 +300,18 @@ extern void xfrm_put_type(struct xfrm_type *type);
298 300
299struct xfrm_mode { 301struct xfrm_mode {
300 int (*input)(struct xfrm_state *x, struct sk_buff *skb); 302 int (*input)(struct xfrm_state *x, struct sk_buff *skb);
303
304 /*
305 * Add encapsulation header.
306 *
307 * On exit, the transport header will be set to the start of the
308 * encapsulation header to be filled in by x->type->output and
309 * the mac header will be set to the nextheader (protocol for
310 * IPv4) field of the extension header directly preceding the
311 * encapsulation header, or in its absence, that of the top IP
312 * header. The value of the network header will always point
313 * to the top IP header while skb->data will point to the payload.
314 */
301 int (*output)(struct xfrm_state *x,struct sk_buff *skb); 315 int (*output)(struct xfrm_state *x,struct sk_buff *skb);
302 316
303 struct module *owner; 317 struct module *owner;
@@ -418,18 +432,66 @@ extern int xfrm_unregister_km(struct xfrm_mgr *km);
418 432
419extern unsigned int xfrm_policy_count[XFRM_POLICY_MAX*2]; 433extern unsigned int xfrm_policy_count[XFRM_POLICY_MAX*2];
420 434
435/*
436 * This structure is used for the duration where packets are being
437 * transformed by IPsec. As soon as the packet leaves IPsec the
438 * area beyond the generic IP part may be overwritten.
439 */
440struct xfrm_skb_cb {
441 union {
442 struct inet_skb_parm h4;
443 struct inet6_skb_parm h6;
444 } header;
445
446 /* Sequence number for replay protection. */
447 u64 seq;
448};
449
450#define XFRM_SKB_CB(__skb) ((struct xfrm_skb_cb *)&((__skb)->cb[0]))
451
421/* Audit Information */ 452/* Audit Information */
422struct xfrm_audit 453struct xfrm_audit
423{ 454{
424 uid_t loginuid; 455 u32 loginuid;
425 u32 secid; 456 u32 secid;
426}; 457};
427 458
428#ifdef CONFIG_AUDITSYSCALL 459#ifdef CONFIG_AUDITSYSCALL
429extern void xfrm_audit_log(uid_t auid, u32 secid, int type, int result, 460static inline struct audit_buffer *xfrm_audit_start(u32 auid, u32 sid)
430 struct xfrm_policy *xp, struct xfrm_state *x); 461{
462 struct audit_buffer *audit_buf = NULL;
463 char *secctx;
464 u32 secctx_len;
465
466 audit_buf = audit_log_start(current->audit_context, GFP_ATOMIC,
467 AUDIT_MAC_IPSEC_EVENT);
468 if (audit_buf == NULL)
469 return NULL;
470
471 audit_log_format(audit_buf, "auid=%u", auid);
472
473 if (sid != 0 &&
474 security_secid_to_secctx(sid, &secctx, &secctx_len) == 0) {
475 audit_log_format(audit_buf, " subj=%s", secctx);
476 security_release_secctx(secctx, secctx_len);
477 } else
478 audit_log_task_context(audit_buf);
479 return audit_buf;
480}
481
482extern void xfrm_audit_policy_add(struct xfrm_policy *xp, int result,
483 u32 auid, u32 sid);
484extern void xfrm_audit_policy_delete(struct xfrm_policy *xp, int result,
485 u32 auid, u32 sid);
486extern void xfrm_audit_state_add(struct xfrm_state *x, int result,
487 u32 auid, u32 sid);
488extern void xfrm_audit_state_delete(struct xfrm_state *x, int result,
489 u32 auid, u32 sid);
431#else 490#else
432#define xfrm_audit_log(a,s,t,r,p,x) do { ; } while (0) 491#define xfrm_audit_policy_add(x, r, a, s) do { ; } while (0)
492#define xfrm_audit_policy_delete(x, r, a, s) do { ; } while (0)
493#define xfrm_audit_state_add(x, r, a, s) do { ; } while (0)
494#define xfrm_audit_state_delete(x, r, a, s) do { ; } while (0)
433#endif /* CONFIG_AUDITSYSCALL */ 495#endif /* CONFIG_AUDITSYSCALL */
434 496
435static inline void xfrm_pol_hold(struct xfrm_policy *policy) 497static inline void xfrm_pol_hold(struct xfrm_policy *policy)
@@ -981,9 +1043,9 @@ extern void xfrm_spd_getinfo(struct xfrmk_spdinfo *si);
981extern int xfrm_replay_check(struct xfrm_state *x, __be32 seq); 1043extern int xfrm_replay_check(struct xfrm_state *x, __be32 seq);
982extern void xfrm_replay_advance(struct xfrm_state *x, __be32 seq); 1044extern void xfrm_replay_advance(struct xfrm_state *x, __be32 seq);
983extern void xfrm_replay_notify(struct xfrm_state *x, int event); 1045extern void xfrm_replay_notify(struct xfrm_state *x, int event);
984extern int xfrm_state_check(struct xfrm_state *x, struct sk_buff *skb);
985extern int xfrm_state_mtu(struct xfrm_state *x, int mtu); 1046extern int xfrm_state_mtu(struct xfrm_state *x, int mtu);
986extern int xfrm_init_state(struct xfrm_state *x); 1047extern int xfrm_init_state(struct xfrm_state *x);
1048extern int xfrm_output(struct sk_buff *skb);
987extern int xfrm4_rcv(struct sk_buff *skb); 1049extern int xfrm4_rcv(struct sk_buff *skb);
988extern int xfrm4_output(struct sk_buff *skb); 1050extern int xfrm4_output(struct sk_buff *skb);
989extern int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family); 1051extern int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family);
@@ -1034,7 +1096,7 @@ struct xfrm_policy *xfrm_policy_bysel_ctx(u8 type, int dir,
1034struct xfrm_policy *xfrm_policy_byid(u8, int dir, u32 id, int delete, int *err); 1096struct xfrm_policy *xfrm_policy_byid(u8, int dir, u32 id, int delete, int *err);
1035int xfrm_policy_flush(u8 type, struct xfrm_audit *audit_info); 1097int xfrm_policy_flush(u8 type, struct xfrm_audit *audit_info);
1036u32 xfrm_get_acqseq(void); 1098u32 xfrm_get_acqseq(void);
1037void xfrm_alloc_spi(struct xfrm_state *x, __be32 minspi, __be32 maxspi); 1099extern int xfrm_alloc_spi(struct xfrm_state *x, u32 minspi, u32 maxspi);
1038struct xfrm_state * xfrm_find_acq(u8 mode, u32 reqid, u8 proto, 1100struct xfrm_state * xfrm_find_acq(u8 mode, u32 reqid, u8 proto,
1039 xfrm_address_t *daddr, xfrm_address_t *saddr, 1101 xfrm_address_t *daddr, xfrm_address_t *saddr,
1040 int create, unsigned short family); 1102 int create, unsigned short family);
@@ -1113,12 +1175,6 @@ static inline int xfrm_aevent_is_on(void)
1113 return ret; 1175 return ret;
1114} 1176}
1115 1177
1116static inline void xfrm_aevent_doreplay(struct xfrm_state *x)
1117{
1118 if (xfrm_aevent_is_on())
1119 xfrm_replay_notify(x, XFRM_REPLAY_UPDATE);
1120}
1121
1122#ifdef CONFIG_XFRM_MIGRATE 1178#ifdef CONFIG_XFRM_MIGRATE
1123static inline struct xfrm_algo *xfrm_algo_clone(struct xfrm_algo *orig) 1179static inline struct xfrm_algo *xfrm_algo_clone(struct xfrm_algo *orig)
1124{ 1180{