rose.h 7.6 KB

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