blob: 913b73d239f54a11b87e7b304e0cea825fc7e416 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _NET_DN_H
2#define _NET_DN_H
3
4#include <linux/dn.h>
5#include <net/sock.h>
David S. Miller4c5e40362012-02-15 16:37:44 -05006#include <net/flow.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007#include <asm/byteorder.h>
Harvey Harrison475ad8e2008-11-27 23:04:13 -08008#include <asm/unaligned.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
10struct dn_scp /* Session Control Port */
11{
12 unsigned char state;
13#define DN_O 1 /* Open */
14#define DN_CR 2 /* Connect Receive */
15#define DN_DR 3 /* Disconnect Reject */
16#define DN_DRC 4 /* Discon. Rej. Complete*/
17#define DN_CC 5 /* Connect Confirm */
18#define DN_CI 6 /* Connect Initiate */
19#define DN_NR 7 /* No resources */
20#define DN_NC 8 /* No communication */
21#define DN_CD 9 /* Connect Delivery */
22#define DN_RJ 10 /* Rejected */
23#define DN_RUN 11 /* Running */
24#define DN_DI 12 /* Disconnect Initiate */
25#define DN_DIC 13 /* Disconnect Complete */
26#define DN_DN 14 /* Disconnect Notificat */
27#define DN_CL 15 /* Closed */
28#define DN_CN 16 /* Closed Notification */
29
Steven Whitehousec4ea94a2006-03-20 22:42:39 -080030 __le16 addrloc;
31 __le16 addrrem;
32 __u16 numdat;
33 __u16 numoth;
34 __u16 numoth_rcv;
35 __u16 numdat_rcv;
36 __u16 ackxmt_dat;
37 __u16 ackxmt_oth;
38 __u16 ackrcv_dat;
39 __u16 ackrcv_oth;
40 __u8 flowrem_sw;
41 __u8 flowloc_sw;
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#define DN_SEND 2
43#define DN_DONTSEND 1
44#define DN_NOCHANGE 0
Steven Whitehousec4ea94a2006-03-20 22:42:39 -080045 __u16 flowrem_dat;
46 __u16 flowrem_oth;
47 __u16 flowloc_dat;
48 __u16 flowloc_oth;
49 __u8 services_rem;
50 __u8 services_loc;
51 __u8 info_rem;
52 __u8 info_loc;
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
Steven Whitehousec4ea94a2006-03-20 22:42:39 -080054 __u16 segsize_rem;
55 __u16 segsize_loc;
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
Steven Whitehousec4ea94a2006-03-20 22:42:39 -080057 __u8 nonagle;
58 __u8 multi_ireq;
59 __u8 accept_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 unsigned long seg_total; /* Running total of current segment */
61
62 struct optdata_dn conndata_in;
63 struct optdata_dn conndata_out;
64 struct optdata_dn discdata_in;
65 struct optdata_dn discdata_out;
66 struct accessdata_dn accessdata;
67
68 struct sockaddr_dn addr; /* Local address */
69 struct sockaddr_dn peer; /* Remote address */
70
71 /*
72 * In this case the RTT estimation is not specified in the
73 * docs, nor is any back off algorithm. Here we follow well
74 * known tcp algorithms with a few small variations.
75 *
76 * snd_window: Max number of packets we send before we wait for
77 * an ack to come back. This will become part of a
78 * more complicated scheme when we support flow
79 * control.
80 *
81 * nsp_srtt: Round-Trip-Time (x8) in jiffies. This is a rolling
82 * average.
83 * nsp_rttvar: Round-Trip-Time-Varience (x4) in jiffies. This is the
84 * varience of the smoothed average (but calculated in
85 * a simpler way than for normal statistical varience
86 * calculations).
87 *
88 * nsp_rxtshift: Backoff counter. Value is zero normally, each time
89 * a packet is lost is increases by one until an ack
90 * is received. Its used to index an array of backoff
91 * multipliers.
92 */
93#define NSP_MIN_WINDOW 1
94#define NSP_MAX_WINDOW (0x07fe)
95 unsigned long max_window;
96 unsigned long snd_window;
97#define NSP_INITIAL_SRTT (HZ)
98 unsigned long nsp_srtt;
99#define NSP_INITIAL_RTTVAR (HZ*3)
100 unsigned long nsp_rttvar;
101#define NSP_MAXRXTSHIFT 12
102 unsigned long nsp_rxtshift;
103
104 /*
105 * Output queues, one for data, one for otherdata/linkservice
106 */
107 struct sk_buff_head data_xmit_queue;
108 struct sk_buff_head other_xmit_queue;
109
110 /*
111 * Input queue for other data
112 */
113 struct sk_buff_head other_receive_queue;
114 int other_report;
115
116 /*
117 * Stuff to do with the slow timer
118 */
119 unsigned long stamp; /* time of last transmit */
120 unsigned long persist;
121 int (*persist_fxn)(struct sock *sk);
122 unsigned long keepalive;
123 void (*keepalive_fxn)(struct sock *sk);
124
125 /*
126 * This stuff is for the fast timer for delayed acks
127 */
128 struct timer_list delack_timer;
129 int delack_pending;
130 void (*delack_fxn)(struct sock *sk);
131
132};
133
134static inline struct dn_scp *DN_SK(struct sock *sk)
135{
136 return (struct dn_scp *)(sk + 1);
137}
138
139/*
140 * src,dst : Source and Destination DECnet addresses
141 * hops : Number of hops through the network
142 * dst_port, src_port : NSP port numbers
143 * services, info : Useful data extracted from conninit messages
144 * rt_flags : Routing flags byte
145 * nsp_flags : NSP layer flags byte
146 * segsize : Size of segment
147 * segnum : Number, for data, otherdata and linkservice
148 * xmit_count : Number of times we've transmitted this skb
149 * stamp : Time stamp of most recent transmission, used in RTT calculations
150 * iif: Input interface number
151 *
152 * As a general policy, this structure keeps all addresses in network
153 * byte order, and all else in host byte order. Thus dst, src, dst_port
154 * and src_port are in network order. All else is in host order.
155 *
156 */
157#define DN_SKB_CB(skb) ((struct dn_skb_cb *)(skb)->cb)
158struct dn_skb_cb {
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800159 __le16 dst;
160 __le16 src;
161 __u16 hops;
162 __le16 dst_port;
163 __le16 src_port;
164 __u8 services;
165 __u8 info;
166 __u8 rt_flags;
167 __u8 nsp_flags;
168 __u16 segsize;
169 __u16 segnum;
170 __u16 xmit_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171 unsigned long stamp;
172 int iif;
173};
174
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800175static inline __le16 dn_eth2dn(unsigned char *ethaddr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176{
Harvey Harrisonc4106aa2008-11-27 00:12:47 -0800177 return get_unaligned((__le16 *)(ethaddr + 4));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178}
179
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800180static inline __le16 dn_saddr2dn(struct sockaddr_dn *saddr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181{
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800182 return *(__le16 *)saddr->sdn_nodeaddr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183}
184
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800185static inline void dn_dn2eth(unsigned char *ethaddr, __le16 addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186{
Harvey Harrisonc4106aa2008-11-27 00:12:47 -0800187 __u16 a = le16_to_cpu(addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188 ethaddr[0] = 0xAA;
189 ethaddr[1] = 0x00;
190 ethaddr[2] = 0x04;
191 ethaddr[3] = 0x00;
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800192 ethaddr[4] = (__u8)(a & 0xff);
193 ethaddr[5] = (__u8)(a >> 8);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194}
195
David S. Millerbef55ae2011-03-12 17:17:10 -0500196static inline void dn_sk_ports_copy(struct flowidn *fld, struct dn_scp *scp)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197{
David S. Millerbef55ae2011-03-12 17:17:10 -0500198 fld->fld_sport = scp->addrloc;
199 fld->fld_dport = scp->addrrem;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200}
201
Joe Perches59ddd962013-09-20 11:23:20 -0700202unsigned int dn_mss_from_pmtu(struct net_device *dev, int mtu);
Rashika Kheriaab3301bd2014-02-09 22:22:53 +0530203void dn_register_sysctl(void);
204void dn_unregister_sysctl(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205
206#define DN_MENUVER_ACC 0x01
207#define DN_MENUVER_USR 0x02
208#define DN_MENUVER_PRX 0x04
209#define DN_MENUVER_UIC 0x08
210
Joe Perches59ddd962013-09-20 11:23:20 -0700211struct sock *dn_sklist_find_listener(struct sockaddr_dn *addr);
212struct sock *dn_find_by_skb(struct sk_buff *skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213#define DN_ASCBUF_LEN 9
Joe Perches59ddd962013-09-20 11:23:20 -0700214char *dn_addr2asc(__u16, char *);
215int dn_destroy_timer(struct sock *sk);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216
Joe Perches59ddd962013-09-20 11:23:20 -0700217int dn_sockaddr2username(struct sockaddr_dn *addr, unsigned char *buf,
218 unsigned char type);
219int dn_username2sockaddr(unsigned char *data, int len, struct sockaddr_dn *addr,
220 unsigned char *type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221
Joe Perches59ddd962013-09-20 11:23:20 -0700222void dn_start_slow_timer(struct sock *sk);
223void dn_stop_slow_timer(struct sock *sk);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800225extern __le16 decnet_address;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226extern int decnet_debug_level;
227extern int decnet_time_wait;
228extern int decnet_dn_count;
229extern int decnet_di_count;
230extern int decnet_dr_count;
231extern int decnet_no_fc_max_cwnd;
232
Eric Dumazet8d987e52010-11-09 23:24:26 +0000233extern long sysctl_decnet_mem[3];
Steven Whitehouse1f12bcc2005-12-05 13:42:06 -0800234extern int sysctl_decnet_wmem[3];
235extern int sysctl_decnet_rmem[3];
236
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237#endif /* _NET_DN_H */