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