dn.h 7.0 KB

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