aboutsummaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
Diffstat (limited to 'include/net')
-rw-r--r--include/net/activity_stats.h25
-rw-r--r--include/net/netfilter/nf_nat_protocol.h74
-rw-r--r--include/net/netfilter/nf_nat_rule.h15
-rw-r--r--include/net/nfc.h156
4 files changed, 270 insertions, 0 deletions
diff --git a/include/net/activity_stats.h b/include/net/activity_stats.h
new file mode 100644
index 00000000000..10e4c1506ee
--- /dev/null
+++ b/include/net/activity_stats.h
@@ -0,0 +1,25 @@
1/*
2 * Copyright (C) 2010 Google, Inc.
3 *
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * Author: Mike Chan (mike@android.com)
14 */
15
16#ifndef __activity_stats_h
17#define __activity_stats_h
18
19#ifdef CONFIG_NET_ACTIVITY_STATS
20void activity_stats_update(void);
21#else
22#define activity_stats_update(void) {}
23#endif
24
25#endif /* _NET_ACTIVITY_STATS_H */
diff --git a/include/net/netfilter/nf_nat_protocol.h b/include/net/netfilter/nf_nat_protocol.h
new file mode 100644
index 00000000000..93cc90d28e6
--- /dev/null
+++ b/include/net/netfilter/nf_nat_protocol.h
@@ -0,0 +1,74 @@
1/* Header for use in defining a given protocol. */
2#ifndef _NF_NAT_PROTOCOL_H
3#define _NF_NAT_PROTOCOL_H
4#include <net/netfilter/nf_nat.h>
5#include <linux/netfilter/nfnetlink_conntrack.h>
6
7struct nf_nat_range;
8
9struct nf_nat_protocol {
10 /* Protocol number. */
11 unsigned int protonum;
12
13 struct module *me;
14
15 /* Translate a packet to the target according to manip type.
16 Return true if succeeded. */
17 bool (*manip_pkt)(struct sk_buff *skb,
18 unsigned int iphdroff,
19 const struct nf_conntrack_tuple *tuple,
20 enum nf_nat_manip_type maniptype);
21
22 /* Is the manipable part of the tuple between min and max incl? */
23 bool (*in_range)(const struct nf_conntrack_tuple *tuple,
24 enum nf_nat_manip_type maniptype,
25 const union nf_conntrack_man_proto *min,
26 const union nf_conntrack_man_proto *max);
27
28 /* Alter the per-proto part of the tuple (depending on
29 maniptype), to give a unique tuple in the given range if
30 possible. Per-protocol part of tuple is initialized to the
31 incoming packet. */
32 void (*unique_tuple)(struct nf_conntrack_tuple *tuple,
33 const struct nf_nat_range *range,
34 enum nf_nat_manip_type maniptype,
35 const struct nf_conn *ct);
36
37 int (*range_to_nlattr)(struct sk_buff *skb,
38 const struct nf_nat_range *range);
39
40 int (*nlattr_to_range)(struct nlattr *tb[],
41 struct nf_nat_range *range);
42};
43
44/* Protocol registration. */
45extern int nf_nat_protocol_register(const struct nf_nat_protocol *proto);
46extern void nf_nat_protocol_unregister(const struct nf_nat_protocol *proto);
47
48/* Built-in protocols. */
49extern const struct nf_nat_protocol nf_nat_protocol_tcp;
50extern const struct nf_nat_protocol nf_nat_protocol_udp;
51extern const struct nf_nat_protocol nf_nat_protocol_icmp;
52extern const struct nf_nat_protocol nf_nat_unknown_protocol;
53
54extern int init_protocols(void) __init;
55extern void cleanup_protocols(void);
56extern const struct nf_nat_protocol *find_nat_proto(u_int16_t protonum);
57
58extern bool nf_nat_proto_in_range(const struct nf_conntrack_tuple *tuple,
59 enum nf_nat_manip_type maniptype,
60 const union nf_conntrack_man_proto *min,
61 const union nf_conntrack_man_proto *max);
62
63extern void nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple,
64 const struct nf_nat_range *range,
65 enum nf_nat_manip_type maniptype,
66 const struct nf_conn *ct,
67 u_int16_t *rover);
68
69extern int nf_nat_proto_range_to_nlattr(struct sk_buff *skb,
70 const struct nf_nat_range *range);
71extern int nf_nat_proto_nlattr_to_range(struct nlattr *tb[],
72 struct nf_nat_range *range);
73
74#endif /*_NF_NAT_PROTO_H*/
diff --git a/include/net/netfilter/nf_nat_rule.h b/include/net/netfilter/nf_nat_rule.h
new file mode 100644
index 00000000000..2890bdc4cd9
--- /dev/null
+++ b/include/net/netfilter/nf_nat_rule.h
@@ -0,0 +1,15 @@
1#ifndef _NF_NAT_RULE_H
2#define _NF_NAT_RULE_H
3#include <net/netfilter/nf_conntrack.h>
4#include <net/netfilter/nf_nat.h>
5#include <linux/netfilter_ipv4/ip_tables.h>
6
7extern int nf_nat_rule_init(void) __init;
8extern void nf_nat_rule_cleanup(void);
9extern int nf_nat_rule_find(struct sk_buff *skb,
10 unsigned int hooknum,
11 const struct net_device *in,
12 const struct net_device *out,
13 struct nf_conn *ct);
14
15#endif /* _NF_NAT_RULE_H */
diff --git a/include/net/nfc.h b/include/net/nfc.h
new file mode 100644
index 00000000000..cc0130312f7
--- /dev/null
+++ b/include/net/nfc.h
@@ -0,0 +1,156 @@
1/*
2 * Copyright (C) 2011 Instituto Nokia de Tecnologia
3 *
4 * Authors:
5 * Lauro Ramos Venancio <lauro.venancio@openbossa.org>
6 * Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the
20 * Free Software Foundation, Inc.,
21 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */
23
24#ifndef __NET_NFC_H
25#define __NET_NFC_H
26
27#include <linux/device.h>
28#include <linux/skbuff.h>
29
30#define nfc_dev_info(dev, fmt, arg...) dev_info((dev), "NFC: " fmt "\n", ## arg)
31#define nfc_dev_err(dev, fmt, arg...) dev_err((dev), "NFC: " fmt "\n", ## arg)
32#define nfc_dev_dbg(dev, fmt, arg...) dev_dbg((dev), fmt "\n", ## arg)
33
34struct nfc_dev;
35
36/**
37 * data_exchange_cb_t - Definition of nfc_data_exchange callback
38 *
39 * @context: nfc_data_exchange cb_context parameter
40 * @skb: response data
41 * @err: If an error has occurred during data exchange, it is the
42 * error number. Zero means no error.
43 *
44 * When a rx or tx package is lost or corrupted or the target gets out
45 * of the operating field, err is -EIO.
46 */
47typedef void (*data_exchange_cb_t)(void *context, struct sk_buff *skb,
48 int err);
49
50struct nfc_ops {
51 int (*start_poll)(struct nfc_dev *dev, u32 protocols);
52 void (*stop_poll)(struct nfc_dev *dev);
53 int (*activate_target)(struct nfc_dev *dev, u32 target_idx,
54 u32 protocol);
55 void (*deactivate_target)(struct nfc_dev *dev, u32 target_idx);
56 int (*data_exchange)(struct nfc_dev *dev, u32 target_idx,
57 struct sk_buff *skb, data_exchange_cb_t cb,
58 void *cb_context);
59};
60
61struct nfc_target {
62 u32 idx;
63 u32 supported_protocols;
64 u16 sens_res;
65 u8 sel_res;
66};
67
68struct nfc_genl_data {
69 u32 poll_req_pid;
70 struct mutex genl_data_mutex;
71};
72
73struct nfc_dev {
74 unsigned idx;
75 unsigned target_idx;
76 struct nfc_target *targets;
77 int n_targets;
78 int targets_generation;
79 spinlock_t targets_lock;
80 struct device dev;
81 bool polling;
82 struct nfc_genl_data genl_data;
83 u32 supported_protocols;
84
85 struct nfc_ops *ops;
86};
87#define to_nfc_dev(_dev) container_of(_dev, struct nfc_dev, dev)
88
89extern struct class nfc_class;
90
91struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops,
92 u32 supported_protocols);
93
94/**
95 * nfc_free_device - free nfc device
96 *
97 * @dev: The nfc device to free
98 */
99static inline void nfc_free_device(struct nfc_dev *dev)
100{
101 put_device(&dev->dev);
102}
103
104int nfc_register_device(struct nfc_dev *dev);
105
106void nfc_unregister_device(struct nfc_dev *dev);
107
108/**
109 * nfc_set_parent_dev - set the parent device
110 *
111 * @nfc_dev: The nfc device whose parent is being set
112 * @dev: The parent device
113 */
114static inline void nfc_set_parent_dev(struct nfc_dev *nfc_dev,
115 struct device *dev)
116{
117 nfc_dev->dev.parent = dev;
118}
119
120/**
121 * nfc_set_drvdata - set driver specifc data
122 *
123 * @dev: The nfc device
124 * @data: Pointer to driver specifc data
125 */
126static inline void nfc_set_drvdata(struct nfc_dev *dev, void *data)
127{
128 dev_set_drvdata(&dev->dev, data);
129}
130
131/**
132 * nfc_get_drvdata - get driver specifc data
133 *
134 * @dev: The nfc device
135 */
136static inline void *nfc_get_drvdata(struct nfc_dev *dev)
137{
138 return dev_get_drvdata(&dev->dev);
139}
140
141/**
142 * nfc_device_name - get the nfc device name
143 *
144 * @dev: The nfc device whose name to return
145 */
146static inline const char *nfc_device_name(struct nfc_dev *dev)
147{
148 return dev_name(&dev->dev);
149}
150
151struct sk_buff *nfc_alloc_skb(unsigned int size, gfp_t gfp);
152
153int nfc_targets_found(struct nfc_dev *dev, struct nfc_target *targets,
154 int ntargets);
155
156#endif /* __NET_NFC_H */