dn.h 7.0 KB

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