dn.h 7.0 KB

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