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