blob: 465b7830278209fee5a1454d634739c9e17a3a50 [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>
Arnaldo Carvalho de Meloc752f072005-08-09 20:08:28 -07006#include <net/tcp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007#include <asm/byteorder.h>
8
Steven Whitehousec4ea94a2006-03-20 22:42:39 -08009#define dn_ntohs(x) le16_to_cpu(x)
10#define dn_htons(x) cpu_to_le16(x)
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
12struct dn_scp /* Session Control Port */
13{
14 unsigned char state;
15#define DN_O 1 /* Open */
16#define DN_CR 2 /* Connect Receive */
17#define DN_DR 3 /* Disconnect Reject */
18#define DN_DRC 4 /* Discon. Rej. Complete*/
19#define DN_CC 5 /* Connect Confirm */
20#define DN_CI 6 /* Connect Initiate */
21#define DN_NR 7 /* No resources */
22#define DN_NC 8 /* No communication */
23#define DN_CD 9 /* Connect Delivery */
24#define DN_RJ 10 /* Rejected */
25#define DN_RUN 11 /* Running */
26#define DN_DI 12 /* Disconnect Initiate */
27#define DN_DIC 13 /* Disconnect Complete */
28#define DN_DN 14 /* Disconnect Notificat */
29#define DN_CL 15 /* Closed */
30#define DN_CN 16 /* Closed Notification */
31
Steven Whitehousec4ea94a2006-03-20 22:42:39 -080032 __le16 addrloc;
33 __le16 addrrem;
34 __u16 numdat;
35 __u16 numoth;
36 __u16 numoth_rcv;
37 __u16 numdat_rcv;
38 __u16 ackxmt_dat;
39 __u16 ackxmt_oth;
40 __u16 ackrcv_dat;
41 __u16 ackrcv_oth;
42 __u8 flowrem_sw;
43 __u8 flowloc_sw;
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#define DN_SEND 2
45#define DN_DONTSEND 1
46#define DN_NOCHANGE 0
Steven Whitehousec4ea94a2006-03-20 22:42:39 -080047 __u16 flowrem_dat;
48 __u16 flowrem_oth;
49 __u16 flowloc_dat;
50 __u16 flowloc_oth;
51 __u8 services_rem;
52 __u8 services_loc;
53 __u8 info_rem;
54 __u8 info_loc;
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
Steven Whitehousec4ea94a2006-03-20 22:42:39 -080056 __u16 segsize_rem;
57 __u16 segsize_loc;
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
Steven Whitehousec4ea94a2006-03-20 22:42:39 -080059 __u8 nonagle;
60 __u8 multi_ireq;
61 __u8 accept_mode;
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 unsigned long seg_total; /* Running total of current segment */
63
64 struct optdata_dn conndata_in;
65 struct optdata_dn conndata_out;
66 struct optdata_dn discdata_in;
67 struct optdata_dn discdata_out;
68 struct accessdata_dn accessdata;
69
70 struct sockaddr_dn addr; /* Local address */
71 struct sockaddr_dn peer; /* Remote address */
72
73 /*
74 * In this case the RTT estimation is not specified in the
75 * docs, nor is any back off algorithm. Here we follow well
76 * known tcp algorithms with a few small variations.
77 *
78 * snd_window: Max number of packets we send before we wait for
79 * an ack to come back. This will become part of a
80 * more complicated scheme when we support flow
81 * control.
82 *
83 * nsp_srtt: Round-Trip-Time (x8) in jiffies. This is a rolling
84 * average.
85 * nsp_rttvar: Round-Trip-Time-Varience (x4) in jiffies. This is the
86 * varience of the smoothed average (but calculated in
87 * a simpler way than for normal statistical varience
88 * calculations).
89 *
90 * nsp_rxtshift: Backoff counter. Value is zero normally, each time
91 * a packet is lost is increases by one until an ack
92 * is received. Its used to index an array of backoff
93 * multipliers.
94 */
95#define NSP_MIN_WINDOW 1
96#define NSP_MAX_WINDOW (0x07fe)
97 unsigned long max_window;
98 unsigned long snd_window;
99#define NSP_INITIAL_SRTT (HZ)
100 unsigned long nsp_srtt;
101#define NSP_INITIAL_RTTVAR (HZ*3)
102 unsigned long nsp_rttvar;
103#define NSP_MAXRXTSHIFT 12
104 unsigned long nsp_rxtshift;
105
106 /*
107 * Output queues, one for data, one for otherdata/linkservice
108 */
109 struct sk_buff_head data_xmit_queue;
110 struct sk_buff_head other_xmit_queue;
111
112 /*
113 * Input queue for other data
114 */
115 struct sk_buff_head other_receive_queue;
116 int other_report;
117
118 /*
119 * Stuff to do with the slow timer
120 */
121 unsigned long stamp; /* time of last transmit */
122 unsigned long persist;
123 int (*persist_fxn)(struct sock *sk);
124 unsigned long keepalive;
125 void (*keepalive_fxn)(struct sock *sk);
126
127 /*
128 * This stuff is for the fast timer for delayed acks
129 */
130 struct timer_list delack_timer;
131 int delack_pending;
132 void (*delack_fxn)(struct sock *sk);
133
134};
135
136static inline struct dn_scp *DN_SK(struct sock *sk)
137{
138 return (struct dn_scp *)(sk + 1);
139}
140
141/*
142 * src,dst : Source and Destination DECnet addresses
143 * hops : Number of hops through the network
144 * dst_port, src_port : NSP port numbers
145 * services, info : Useful data extracted from conninit messages
146 * rt_flags : Routing flags byte
147 * nsp_flags : NSP layer flags byte
148 * segsize : Size of segment
149 * segnum : Number, for data, otherdata and linkservice
150 * xmit_count : Number of times we've transmitted this skb
151 * stamp : Time stamp of most recent transmission, used in RTT calculations
152 * iif: Input interface number
153 *
154 * As a general policy, this structure keeps all addresses in network
155 * byte order, and all else in host byte order. Thus dst, src, dst_port
156 * and src_port are in network order. All else is in host order.
157 *
158 */
159#define DN_SKB_CB(skb) ((struct dn_skb_cb *)(skb)->cb)
160struct dn_skb_cb {
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800161 __le16 dst;
162 __le16 src;
163 __u16 hops;
164 __le16 dst_port;
165 __le16 src_port;
166 __u8 services;
167 __u8 info;
168 __u8 rt_flags;
169 __u8 nsp_flags;
170 __u16 segsize;
171 __u16 segnum;
172 __u16 xmit_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 unsigned long stamp;
174 int iif;
175};
176
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800177static inline __le16 dn_eth2dn(unsigned char *ethaddr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178{
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800179 return dn_htons(ethaddr[4] | (ethaddr[5] << 8));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180}
181
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800182static inline __le16 dn_saddr2dn(struct sockaddr_dn *saddr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183{
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800184 return *(__le16 *)saddr->sdn_nodeaddr;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185}
186
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800187static inline void dn_dn2eth(unsigned char *ethaddr, __le16 addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188{
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800189 __u16 a = dn_ntohs(addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 ethaddr[0] = 0xAA;
191 ethaddr[1] = 0x00;
192 ethaddr[2] = 0x04;
193 ethaddr[3] = 0x00;
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800194 ethaddr[4] = (__u8)(a & 0xff);
195 ethaddr[5] = (__u8)(a >> 8);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196}
197
198static inline void dn_sk_ports_copy(struct flowi *fl, struct dn_scp *scp)
199{
200 fl->uli_u.dnports.sport = scp->addrloc;
201 fl->uli_u.dnports.dport = scp->addrrem;
202 fl->uli_u.dnports.objnum = scp->addr.sdn_objnum;
203 if (fl->uli_u.dnports.objnum == 0) {
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800204 fl->uli_u.dnports.objnamel = (__u8)dn_ntohs(scp->addr.sdn_objnamel);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 memcpy(fl->uli_u.dnports.objname, scp->addr.sdn_objname, 16);
206 }
207}
208
209extern unsigned dn_mss_from_pmtu(struct net_device *dev, int mtu);
210
211#define DN_MENUVER_ACC 0x01
212#define DN_MENUVER_USR 0x02
213#define DN_MENUVER_PRX 0x04
214#define DN_MENUVER_UIC 0x08
215
216extern struct sock *dn_sklist_find_listener(struct sockaddr_dn *addr);
217extern struct sock *dn_find_by_skb(struct sk_buff *skb);
218#define DN_ASCBUF_LEN 9
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800219extern char *dn_addr2asc(__u16, char *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220extern int dn_destroy_timer(struct sock *sk);
221
222extern int dn_sockaddr2username(struct sockaddr_dn *addr, unsigned char *buf, unsigned char type);
223extern int dn_username2sockaddr(unsigned char *data, int len, struct sockaddr_dn *addr, unsigned char *type);
224
225extern void dn_start_slow_timer(struct sock *sk);
226extern void dn_stop_slow_timer(struct sock *sk);
227
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800228extern __le16 decnet_address;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229extern int decnet_debug_level;
230extern int decnet_time_wait;
231extern int decnet_dn_count;
232extern int decnet_di_count;
233extern int decnet_dr_count;
234extern int decnet_no_fc_max_cwnd;
235
Steven Whitehouse1f12bcc2005-12-05 13:42:06 -0800236extern int sysctl_decnet_mem[3];
237extern int sysctl_decnet_wmem[3];
238extern int sysctl_decnet_rmem[3];
239
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240#endif /* _NET_DN_H */