aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/netrom.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/netrom.h')
-rw-r--r--include/net/netrom.h242
1 files changed, 242 insertions, 0 deletions
diff --git a/include/net/netrom.h b/include/net/netrom.h
new file mode 100644
index 000000000000..45f2c7616d8b
--- /dev/null
+++ b/include/net/netrom.h
@@ -0,0 +1,242 @@
1/*
2 * Declarations of NET/ROM type objects.
3 *
4 * Jonathan Naylor G4KLX 9/4/95
5 */
6
7#ifndef _NETROM_H
8#define _NETROM_H
9#include <linux/netrom.h>
10#include <linux/list.h>
11#include <net/sock.h>
12
13#define NR_NETWORK_LEN 15
14#define NR_TRANSPORT_LEN 5
15
16#define NR_PROTO_IP 0x0C
17
18#define NR_PROTOEXT 0x00
19#define NR_CONNREQ 0x01
20#define NR_CONNACK 0x02
21#define NR_DISCREQ 0x03
22#define NR_DISCACK 0x04
23#define NR_INFO 0x05
24#define NR_INFOACK 0x06
25
26#define NR_CHOKE_FLAG 0x80
27#define NR_NAK_FLAG 0x40
28#define NR_MORE_FLAG 0x20
29
30/* Define Link State constants. */
31enum {
32 NR_STATE_0,
33 NR_STATE_1,
34 NR_STATE_2,
35 NR_STATE_3
36};
37
38#define NR_COND_ACK_PENDING 0x01
39#define NR_COND_REJECT 0x02
40#define NR_COND_PEER_RX_BUSY 0x04
41#define NR_COND_OWN_RX_BUSY 0x08
42
43#define NR_DEFAULT_T1 (120 * HZ) /* Outstanding frames - 120 seconds */
44#define NR_DEFAULT_T2 (5 * HZ) /* Response delay - 5 seconds */
45#define NR_DEFAULT_N2 3 /* Number of Retries - 3 */
46#define NR_DEFAULT_T4 (180 * HZ) /* Busy Delay - 180 seconds */
47#define NR_DEFAULT_IDLE (0 * 60 * HZ) /* No Activity Timeout - none */
48#define NR_DEFAULT_WINDOW 4 /* Default Window Size - 4 */
49#define NR_DEFAULT_OBS 6 /* Default Obsolescence Count - 6 */
50#define NR_DEFAULT_QUAL 10 /* Default Neighbour Quality - 10 */
51#define NR_DEFAULT_TTL 16 /* Default Time To Live - 16 */
52#define NR_DEFAULT_ROUTING 1 /* Is routing enabled ? */
53#define NR_DEFAULT_FAILS 2 /* Link fails until route fails */
54
55#define NR_MODULUS 256
56#define NR_MAX_WINDOW_SIZE 127 /* Maximum Window Allowable - 127 */
57#define NR_MAX_PACKET_SIZE 236 /* Maximum Packet Length - 236 */
58
59struct nr_sock {
60 struct sock sock;
61 ax25_address user_addr, source_addr, dest_addr;
62 struct net_device *device;
63 unsigned char my_index, my_id;
64 unsigned char your_index, your_id;
65 unsigned char state, condition, bpqext, window;
66 unsigned short vs, vr, va, vl;
67 unsigned char n2, n2count;
68 unsigned long t1, t2, t4, idle;
69 unsigned short fraglen;
70 struct timer_list t1timer;
71 struct timer_list t2timer;
72 struct timer_list t4timer;
73 struct timer_list idletimer;
74 struct sk_buff_head ack_queue;
75 struct sk_buff_head reseq_queue;
76 struct sk_buff_head frag_queue;
77};
78
79#define nr_sk(sk) ((struct nr_sock *)(sk))
80
81struct nr_neigh {
82 struct hlist_node neigh_node;
83 ax25_address callsign;
84 ax25_digi *digipeat;
85 ax25_cb *ax25;
86 struct net_device *dev;
87 unsigned char quality;
88 unsigned char locked;
89 unsigned short count;
90 unsigned int number;
91 unsigned char failed;
92 atomic_t refcount;
93};
94
95struct nr_route {
96 unsigned char quality;
97 unsigned char obs_count;
98 struct nr_neigh *neighbour;
99};
100
101struct nr_node {
102 struct hlist_node node_node;
103 ax25_address callsign;
104 char mnemonic[7];
105 unsigned char which;
106 unsigned char count;
107 struct nr_route routes[3];
108 atomic_t refcount;
109 spinlock_t node_lock;
110};
111
112/*********************************************************************
113 * nr_node & nr_neigh lists, refcounting and locking
114 *********************************************************************/
115
116#define nr_node_hold(__nr_node) \
117 atomic_inc(&((__nr_node)->refcount))
118
119static __inline__ void nr_node_put(struct nr_node *nr_node)
120{
121 if (atomic_dec_and_test(&nr_node->refcount)) {
122 kfree(nr_node);
123 }
124}
125
126#define nr_neigh_hold(__nr_neigh) \
127 atomic_inc(&((__nr_neigh)->refcount))
128
129static __inline__ void nr_neigh_put(struct nr_neigh *nr_neigh)
130{
131 if (atomic_dec_and_test(&nr_neigh->refcount)) {
132 if (nr_neigh->digipeat != NULL)
133 kfree(nr_neigh->digipeat);
134 kfree(nr_neigh);
135 }
136}
137
138/* nr_node_lock and nr_node_unlock also hold/put the node's refcounter.
139 */
140static __inline__ void nr_node_lock(struct nr_node *nr_node)
141{
142 nr_node_hold(nr_node);
143 spin_lock_bh(&nr_node->node_lock);
144}
145
146static __inline__ void nr_node_unlock(struct nr_node *nr_node)
147{
148 spin_unlock_bh(&nr_node->node_lock);
149 nr_node_put(nr_node);
150}
151
152#define nr_neigh_for_each(__nr_neigh, node, list) \
153 hlist_for_each_entry(__nr_neigh, node, list, neigh_node)
154
155#define nr_neigh_for_each_safe(__nr_neigh, node, node2, list) \
156 hlist_for_each_entry_safe(__nr_neigh, node, node2, list, neigh_node)
157
158#define nr_node_for_each(__nr_node, node, list) \
159 hlist_for_each_entry(__nr_node, node, list, node_node)
160
161#define nr_node_for_each_safe(__nr_node, node, node2, list) \
162 hlist_for_each_entry_safe(__nr_node, node, node2, list, node_node)
163
164
165/*********************************************************************/
166
167/* af_netrom.c */
168extern int sysctl_netrom_default_path_quality;
169extern int sysctl_netrom_obsolescence_count_initialiser;
170extern int sysctl_netrom_network_ttl_initialiser;
171extern int sysctl_netrom_transport_timeout;
172extern int sysctl_netrom_transport_maximum_tries;
173extern int sysctl_netrom_transport_acknowledge_delay;
174extern int sysctl_netrom_transport_busy_delay;
175extern int sysctl_netrom_transport_requested_window_size;
176extern int sysctl_netrom_transport_no_activity_timeout;
177extern int sysctl_netrom_routing_control;
178extern int sysctl_netrom_link_fails_count;
179extern int nr_rx_frame(struct sk_buff *, struct net_device *);
180extern void nr_destroy_socket(struct sock *);
181
182/* nr_dev.c */
183extern int nr_rx_ip(struct sk_buff *, struct net_device *);
184extern void nr_setup(struct net_device *);
185
186/* nr_in.c */
187extern int nr_process_rx_frame(struct sock *, struct sk_buff *);
188
189/* nr_loopback.c */
190extern void nr_loopback_init(void);
191extern void nr_loopback_clear(void);
192extern int nr_loopback_queue(struct sk_buff *);
193
194/* nr_out.c */
195extern void nr_output(struct sock *, struct sk_buff *);
196extern void nr_send_nak_frame(struct sock *);
197extern void nr_kick(struct sock *);
198extern void nr_transmit_buffer(struct sock *, struct sk_buff *);
199extern void nr_establish_data_link(struct sock *);
200extern void nr_enquiry_response(struct sock *);
201extern void nr_check_iframes_acked(struct sock *, unsigned short);
202
203/* nr_route.c */
204extern void nr_rt_device_down(struct net_device *);
205extern struct net_device *nr_dev_first(void);
206extern struct net_device *nr_dev_get(ax25_address *);
207extern int nr_rt_ioctl(unsigned int, void __user *);
208extern void nr_link_failed(ax25_cb *, int);
209extern int nr_route_frame(struct sk_buff *, ax25_cb *);
210extern struct file_operations nr_nodes_fops;
211extern struct file_operations nr_neigh_fops;
212extern void nr_rt_free(void);
213
214/* nr_subr.c */
215extern void nr_clear_queues(struct sock *);
216extern void nr_frames_acked(struct sock *, unsigned short);
217extern void nr_requeue_frames(struct sock *);
218extern int nr_validate_nr(struct sock *, unsigned short);
219extern int nr_in_rx_window(struct sock *, unsigned short);
220extern void nr_write_internal(struct sock *, int);
221extern void nr_transmit_refusal(struct sk_buff *, int);
222extern void nr_disconnect(struct sock *, int);
223
224/* nr_timer.c */
225extern void nr_init_timers(struct sock *sk);
226extern void nr_start_heartbeat(struct sock *);
227extern void nr_start_t1timer(struct sock *);
228extern void nr_start_t2timer(struct sock *);
229extern void nr_start_t4timer(struct sock *);
230extern void nr_start_idletimer(struct sock *);
231extern void nr_stop_heartbeat(struct sock *);
232extern void nr_stop_t1timer(struct sock *);
233extern void nr_stop_t2timer(struct sock *);
234extern void nr_stop_t4timer(struct sock *);
235extern void nr_stop_idletimer(struct sock *);
236extern int nr_t1timer_running(struct sock *);
237
238/* sysctl_net_netrom.c */
239extern void nr_register_sysctl(void);
240extern void nr_unregister_sysctl(void);
241
242#endif