irlan_common.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /*********************************************************************
  2. *
  3. * Filename: irlan_common.h
  4. * Version: 0.8
  5. * Description: IrDA LAN access layer
  6. * Status: Experimental.
  7. * Author: Dag Brattli <dagb@cs.uit.no>
  8. * Created at: Sun Aug 31 20:14:37 1997
  9. * Modified at: Sun Oct 31 19:41:24 1999
  10. * Modified by: Dag Brattli <dagb@cs.uit.no>
  11. *
  12. * Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>,
  13. * All Rights Reserved.
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License as
  17. * published by the Free Software Foundation; either version 2 of
  18. * the License, or (at your option) any later version.
  19. *
  20. * Neither Dag Brattli nor University of Tromsø admit liability nor
  21. * provide warranty for any of this software. This material is
  22. * provided "AS-IS" and at no charge.
  23. *
  24. ********************************************************************/
  25. #ifndef IRLAN_H
  26. #define IRLAN_H
  27. #include <asm/param.h> /* for HZ */
  28. #include <linux/kernel.h>
  29. #include <linux/types.h>
  30. #include <linux/skbuff.h>
  31. #include <linux/netdevice.h>
  32. #include <net/irda/irttp.h>
  33. #define IRLAN_MTU 1518
  34. #define IRLAN_TIMEOUT 10*HZ /* 10 seconds */
  35. /* Command packet types */
  36. #define CMD_GET_PROVIDER_INFO 0
  37. #define CMD_GET_MEDIA_CHAR 1
  38. #define CMD_OPEN_DATA_CHANNEL 2
  39. #define CMD_CLOSE_DATA_CHAN 3
  40. #define CMD_RECONNECT_DATA_CHAN 4
  41. #define CMD_FILTER_OPERATION 5
  42. /* Some responses */
  43. #define RSP_SUCCESS 0
  44. #define RSP_INSUFFICIENT_RESOURCES 1
  45. #define RSP_INVALID_COMMAND_FORMAT 2
  46. #define RSP_COMMAND_NOT_SUPPORTED 3
  47. #define RSP_PARAM_NOT_SUPPORTED 4
  48. #define RSP_VALUE_NOT_SUPPORTED 5
  49. #define RSP_NOT_OPEN 6
  50. #define RSP_AUTHENTICATION_REQUIRED 7
  51. #define RSP_INVALID_PASSWORD 8
  52. #define RSP_PROTOCOL_ERROR 9
  53. #define RSP_ASYNCHRONOUS_ERROR 255
  54. /* Media types */
  55. #define MEDIA_802_3 1
  56. #define MEDIA_802_5 2
  57. /* Filter parameters */
  58. #define DATA_CHAN 1
  59. #define FILTER_TYPE 2
  60. #define FILTER_MODE 3
  61. /* Filter types */
  62. #define IRLAN_DIRECTED 0x01
  63. #define IRLAN_FUNCTIONAL 0x02
  64. #define IRLAN_GROUP 0x04
  65. #define IRLAN_MAC_FRAME 0x08
  66. #define IRLAN_MULTICAST 0x10
  67. #define IRLAN_BROADCAST 0x20
  68. #define IRLAN_IPX_SOCKET 0x40
  69. /* Filter modes */
  70. #define ALL 1
  71. #define FILTER 2
  72. #define NONE 3
  73. /* Filter operations */
  74. #define GET 1
  75. #define CLEAR 2
  76. #define ADD 3
  77. #define REMOVE 4
  78. #define DYNAMIC 5
  79. /* Access types */
  80. #define ACCESS_DIRECT 1
  81. #define ACCESS_PEER 2
  82. #define ACCESS_HOSTED 3
  83. #define IRLAN_BYTE 0
  84. #define IRLAN_SHORT 1
  85. #define IRLAN_ARRAY 2
  86. /* IrLAN sits on top if IrTTP */
  87. #define IRLAN_MAX_HEADER (TTP_HEADER+LMP_HEADER)
  88. /* 1 byte for the command code and 1 byte for the parameter count */
  89. #define IRLAN_CMD_HEADER 2
  90. #define IRLAN_STRING_PARAMETER_LEN(name, value) (1 + strlen((name)) + 2 \
  91. + strlen ((value)))
  92. #define IRLAN_BYTE_PARAMETER_LEN(name) (1 + strlen((name)) + 2 + 1)
  93. #define IRLAN_SHORT_PARAMETER_LEN(name) (1 + strlen((name)) + 2 + 2)
  94. /*
  95. * IrLAN client
  96. */
  97. struct irlan_client_cb {
  98. int state;
  99. int open_retries;
  100. struct tsap_cb *tsap_ctrl;
  101. __u32 max_sdu_size;
  102. __u8 max_header_size;
  103. int access_type; /* Access type of provider */
  104. __u8 reconnect_key[255];
  105. __u8 key_len;
  106. __u16 recv_arb_val;
  107. __u16 max_frame;
  108. int filter_type;
  109. int unicast_open;
  110. int broadcast_open;
  111. int tx_busy;
  112. struct sk_buff_head txq; /* Transmit control queue */
  113. struct iriap_cb *iriap;
  114. struct timer_list kick_timer;
  115. };
  116. /*
  117. * IrLAN provider
  118. */
  119. struct irlan_provider_cb {
  120. int state;
  121. struct tsap_cb *tsap_ctrl;
  122. __u32 max_sdu_size;
  123. __u8 max_header_size;
  124. /*
  125. * Store some values here which are used by the provider to parse
  126. * the filter operations
  127. */
  128. int data_chan;
  129. int filter_type;
  130. int filter_mode;
  131. int filter_operation;
  132. int filter_entry;
  133. int access_type; /* Access type */
  134. __u16 send_arb_val;
  135. __u8 mac_address[6]; /* Generated MAC address for peer device */
  136. };
  137. /*
  138. * IrLAN control block
  139. */
  140. struct irlan_cb {
  141. int magic;
  142. struct list_head dev_list;
  143. struct net_device *dev; /* Ethernet device structure*/
  144. __u32 saddr; /* Source device address */
  145. __u32 daddr; /* Destination device address */
  146. int disconnect_reason; /* Why we got disconnected */
  147. int media; /* Media type */
  148. __u8 version[2]; /* IrLAN version */
  149. struct tsap_cb *tsap_data; /* Data TSAP */
  150. int use_udata; /* Use Unit Data transfers */
  151. __u8 stsap_sel_data; /* Source data TSAP selector */
  152. __u8 dtsap_sel_data; /* Destination data TSAP selector */
  153. __u8 dtsap_sel_ctrl; /* Destination ctrl TSAP selector */
  154. struct irlan_client_cb client; /* Client specific fields */
  155. struct irlan_provider_cb provider; /* Provider specific fields */
  156. __u32 max_sdu_size;
  157. __u8 max_header_size;
  158. wait_queue_head_t open_wait;
  159. struct timer_list watchdog_timer;
  160. };
  161. void irlan_close(struct irlan_cb *self);
  162. void irlan_close_tsaps(struct irlan_cb *self);
  163. int irlan_register_netdev(struct irlan_cb *self);
  164. void irlan_ias_register(struct irlan_cb *self, __u8 tsap_sel);
  165. void irlan_start_watchdog_timer(struct irlan_cb *self, int timeout);
  166. void irlan_open_data_tsap(struct irlan_cb *self);
  167. int irlan_run_ctrl_tx_queue(struct irlan_cb *self);
  168. struct irlan_cb *irlan_get_any(void);
  169. void irlan_get_provider_info(struct irlan_cb *self);
  170. void irlan_get_media_char(struct irlan_cb *self);
  171. void irlan_open_data_channel(struct irlan_cb *self);
  172. void irlan_close_data_channel(struct irlan_cb *self);
  173. void irlan_set_multicast_filter(struct irlan_cb *self, int status);
  174. void irlan_set_broadcast_filter(struct irlan_cb *self, int status);
  175. int irlan_insert_byte_param(struct sk_buff *skb, char *param, __u8 value);
  176. int irlan_insert_short_param(struct sk_buff *skb, char *param, __u16 value);
  177. int irlan_insert_string_param(struct sk_buff *skb, char *param, char *value);
  178. int irlan_insert_array_param(struct sk_buff *skb, char *name, __u8 *value,
  179. __u16 value_len);
  180. int irlan_extract_param(__u8 *buf, char *name, char *value, __u16 *len);
  181. #endif