rose.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Declarations of Rose type objects.
  4. *
  5. * Jonathan Naylor G4KLX 25/8/96
  6. */
  7. #ifndef _ROSE_H
  8. #define _ROSE_H
  9. #include <linux/rose.h>
  10. #include <net/sock.h>
  11. #define ROSE_ADDR_LEN 5
  12. #define ROSE_MIN_LEN 3
  13. #define ROSE_CALL_REQ_ADDR_LEN_OFF 3
  14. #define ROSE_CALL_REQ_ADDR_LEN_VAL 0xAA /* each address is 10 digits */
  15. #define ROSE_CALL_REQ_DEST_ADDR_OFF 4
  16. #define ROSE_CALL_REQ_SRC_ADDR_OFF 9
  17. #define ROSE_CALL_REQ_FACILITIES_OFF 14
  18. #define ROSE_GFI 0x10
  19. #define ROSE_Q_BIT 0x80
  20. #define ROSE_D_BIT 0x40
  21. #define ROSE_M_BIT 0x10
  22. #define ROSE_CALL_REQUEST 0x0B
  23. #define ROSE_CALL_ACCEPTED 0x0F
  24. #define ROSE_CLEAR_REQUEST 0x13
  25. #define ROSE_CLEAR_CONFIRMATION 0x17
  26. #define ROSE_DATA 0x00
  27. #define ROSE_INTERRUPT 0x23
  28. #define ROSE_INTERRUPT_CONFIRMATION 0x27
  29. #define ROSE_RR 0x01
  30. #define ROSE_RNR 0x05
  31. #define ROSE_REJ 0x09
  32. #define ROSE_RESET_REQUEST 0x1B
  33. #define ROSE_RESET_CONFIRMATION 0x1F
  34. #define ROSE_REGISTRATION_REQUEST 0xF3
  35. #define ROSE_REGISTRATION_CONFIRMATION 0xF7
  36. #define ROSE_RESTART_REQUEST 0xFB
  37. #define ROSE_RESTART_CONFIRMATION 0xFF
  38. #define ROSE_DIAGNOSTIC 0xF1
  39. #define ROSE_ILLEGAL 0xFD
  40. /* Define Link State constants. */
  41. enum {
  42. ROSE_STATE_0, /* Ready */
  43. ROSE_STATE_1, /* Awaiting Call Accepted */
  44. ROSE_STATE_2, /* Awaiting Clear Confirmation */
  45. ROSE_STATE_3, /* Data Transfer */
  46. ROSE_STATE_4, /* Awaiting Reset Confirmation */
  47. ROSE_STATE_5 /* Deferred Call Acceptance */
  48. };
  49. #define ROSE_DEFAULT_T0 180000 /* Default T10 T20 value */
  50. #define ROSE_DEFAULT_T1 200000 /* Default T11 T21 value */
  51. #define ROSE_DEFAULT_T2 180000 /* Default T12 T22 value */
  52. #define ROSE_DEFAULT_T3 180000 /* Default T13 T23 value */
  53. #define ROSE_DEFAULT_HB 5000 /* Default Holdback value */
  54. #define ROSE_DEFAULT_IDLE 0 /* No Activity Timeout - none */
  55. #define ROSE_DEFAULT_ROUTING 1 /* Default routing flag */
  56. #define ROSE_DEFAULT_FAIL_TIMEOUT 120000 /* Time until link considered usable */
  57. #define ROSE_DEFAULT_MAXVC 50 /* Maximum number of VCs per neighbour */
  58. #define ROSE_DEFAULT_WINDOW_SIZE 7 /* Default window size */
  59. #define ROSE_MODULUS 8
  60. #define ROSE_MAX_PACKET_SIZE 251 /* Maximum packet size */
  61. #define ROSE_COND_ACK_PENDING 0x01
  62. #define ROSE_COND_PEER_RX_BUSY 0x02
  63. #define ROSE_COND_OWN_RX_BUSY 0x04
  64. #define FAC_NATIONAL 0x00
  65. #define FAC_CCITT 0x0F
  66. #define FAC_NATIONAL_RAND 0x7F
  67. #define FAC_NATIONAL_FLAGS 0x3F
  68. #define FAC_NATIONAL_DEST_DIGI 0xE9
  69. #define FAC_NATIONAL_SRC_DIGI 0xEB
  70. #define FAC_NATIONAL_FAIL_CALL 0xED
  71. #define FAC_NATIONAL_FAIL_ADD 0xEE
  72. #define FAC_NATIONAL_DIGIS 0xEF
  73. #define FAC_CCITT_DEST_NSAP 0xC9
  74. #define FAC_CCITT_SRC_NSAP 0xCB
  75. struct rose_neigh {
  76. struct rose_neigh *next;
  77. ax25_address callsign;
  78. ax25_digi *digipeat;
  79. ax25_cb *ax25;
  80. struct net_device *dev;
  81. unsigned short count;
  82. unsigned short use;
  83. unsigned int number;
  84. char restarted;
  85. char dce_mode;
  86. char loopback;
  87. struct sk_buff_head queue;
  88. struct timer_list t0timer;
  89. struct timer_list ftimer;
  90. };
  91. struct rose_node {
  92. struct rose_node *next;
  93. rose_address address;
  94. unsigned short mask;
  95. unsigned char count;
  96. char loopback;
  97. struct rose_neigh *neighbour[3];
  98. };
  99. struct rose_route {
  100. struct rose_route *next;
  101. unsigned int lci1, lci2;
  102. rose_address src_addr, dest_addr;
  103. ax25_address src_call, dest_call;
  104. struct rose_neigh *neigh1, *neigh2;
  105. unsigned int rand;
  106. };
  107. struct rose_sock {
  108. struct sock sock;
  109. rose_address source_addr, dest_addr;
  110. ax25_address source_call, dest_call;
  111. unsigned char source_ndigis, dest_ndigis;
  112. ax25_address source_digis[ROSE_MAX_DIGIS];
  113. ax25_address dest_digis[ROSE_MAX_DIGIS];
  114. struct rose_neigh *neighbour;
  115. struct net_device *device;
  116. unsigned int lci, rand;
  117. unsigned char state, condition, qbitincl, defer;
  118. unsigned char cause, diagnostic;
  119. unsigned short vs, vr, va, vl;
  120. unsigned long t1, t2, t3, hb, idle;
  121. #ifdef M_BIT
  122. unsigned short fraglen;
  123. struct sk_buff_head frag_queue;
  124. #endif
  125. struct sk_buff_head ack_queue;
  126. struct rose_facilities_struct facilities;
  127. struct timer_list timer;
  128. struct timer_list idletimer;
  129. };
  130. #define rose_sk(sk) ((struct rose_sock *)(sk))
  131. /* af_rose.c */
  132. extern ax25_address rose_callsign;
  133. extern int sysctl_rose_restart_request_timeout;
  134. extern int sysctl_rose_call_request_timeout;
  135. extern int sysctl_rose_reset_request_timeout;
  136. extern int sysctl_rose_clear_request_timeout;
  137. extern int sysctl_rose_no_activity_timeout;
  138. extern int sysctl_rose_ack_hold_back_timeout;
  139. extern int sysctl_rose_routing_control;
  140. extern int sysctl_rose_link_fail_timeout;
  141. extern int sysctl_rose_maximum_vcs;
  142. extern int sysctl_rose_window_size;
  143. int rosecmp(rose_address *, rose_address *);
  144. int rosecmpm(rose_address *, rose_address *, unsigned short);
  145. char *rose2asc(char *buf, const rose_address *);
  146. struct sock *rose_find_socket(unsigned int, struct rose_neigh *);
  147. void rose_kill_by_neigh(struct rose_neigh *);
  148. unsigned int rose_new_lci(struct rose_neigh *);
  149. int rose_rx_call_request(struct sk_buff *, struct net_device *,
  150. struct rose_neigh *, unsigned int);
  151. void rose_destroy_socket(struct sock *);
  152. /* rose_dev.c */
  153. void rose_setup(struct net_device *);
  154. /* rose_in.c */
  155. int rose_process_rx_frame(struct sock *, struct sk_buff *);
  156. /* rose_link.c */
  157. void rose_start_ftimer(struct rose_neigh *);
  158. void rose_stop_ftimer(struct rose_neigh *);
  159. void rose_stop_t0timer(struct rose_neigh *);
  160. int rose_ftimer_running(struct rose_neigh *);
  161. void rose_link_rx_restart(struct sk_buff *, struct rose_neigh *,
  162. unsigned short);
  163. void rose_transmit_clear_request(struct rose_neigh *, unsigned int,
  164. unsigned char, unsigned char);
  165. void rose_transmit_link(struct sk_buff *, struct rose_neigh *);
  166. /* rose_loopback.c */
  167. void rose_loopback_init(void);
  168. void rose_loopback_clear(void);
  169. int rose_loopback_queue(struct sk_buff *, struct rose_neigh *);
  170. /* rose_out.c */
  171. void rose_kick(struct sock *);
  172. void rose_enquiry_response(struct sock *);
  173. /* rose_route.c */
  174. extern struct rose_neigh *rose_loopback_neigh;
  175. extern const struct file_operations rose_neigh_fops;
  176. extern const struct file_operations rose_nodes_fops;
  177. extern const struct file_operations rose_routes_fops;
  178. void rose_add_loopback_neigh(void);
  179. int __must_check rose_add_loopback_node(rose_address *);
  180. void rose_del_loopback_node(rose_address *);
  181. void rose_rt_device_down(struct net_device *);
  182. void rose_link_device_down(struct net_device *);
  183. struct net_device *rose_dev_first(void);
  184. struct net_device *rose_dev_get(rose_address *);
  185. struct rose_route *rose_route_free_lci(unsigned int, struct rose_neigh *);
  186. struct rose_neigh *rose_get_neigh(rose_address *, unsigned char *,
  187. unsigned char *, int);
  188. int rose_rt_ioctl(unsigned int, void __user *);
  189. void rose_link_failed(ax25_cb *, int);
  190. int rose_route_frame(struct sk_buff *, ax25_cb *);
  191. void rose_rt_free(void);
  192. /* rose_subr.c */
  193. void rose_clear_queues(struct sock *);
  194. void rose_frames_acked(struct sock *, unsigned short);
  195. void rose_requeue_frames(struct sock *);
  196. int rose_validate_nr(struct sock *, unsigned short);
  197. void rose_write_internal(struct sock *, int);
  198. int rose_decode(struct sk_buff *, int *, int *, int *, int *, int *);
  199. int rose_parse_facilities(unsigned char *, unsigned int,
  200. struct rose_facilities_struct *);
  201. void rose_disconnect(struct sock *, int, int, int);
  202. /* rose_timer.c */
  203. void rose_start_heartbeat(struct sock *);
  204. void rose_start_t1timer(struct sock *);
  205. void rose_start_t2timer(struct sock *);
  206. void rose_start_t3timer(struct sock *);
  207. void rose_start_hbtimer(struct sock *);
  208. void rose_start_idletimer(struct sock *);
  209. void rose_stop_heartbeat(struct sock *);
  210. void rose_stop_timer(struct sock *);
  211. void rose_stop_idletimer(struct sock *);
  212. /* sysctl_net_rose.c */
  213. void rose_register_sysctl(void);
  214. void rose_unregister_sysctl(void);
  215. #endif