irlan_common.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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 <linux/if_ether.h>
  33. #include <net/irda/irttp.h>
  34. #define IRLAN_MTU 1518
  35. #define IRLAN_TIMEOUT 10*HZ /* 10 seconds */
  36. /* Command packet types */
  37. #define CMD_GET_PROVIDER_INFO 0
  38. #define CMD_GET_MEDIA_CHAR 1
  39. #define CMD_OPEN_DATA_CHANNEL 2
  40. #define CMD_CLOSE_DATA_CHAN 3
  41. #define CMD_RECONNECT_DATA_CHAN 4
  42. #define CMD_FILTER_OPERATION 5
  43. /* Some responses */
  44. #define RSP_SUCCESS 0
  45. #define RSP_INSUFFICIENT_RESOURCES 1
  46. #define RSP_INVALID_COMMAND_FORMAT 2
  47. #define RSP_COMMAND_NOT_SUPPORTED 3
  48. #define RSP_PARAM_NOT_SUPPORTED 4
  49. #define RSP_VALUE_NOT_SUPPORTED 5
  50. #define RSP_NOT_OPEN 6
  51. #define RSP_AUTHENTICATION_REQUIRED 7
  52. #define RSP_INVALID_PASSWORD 8
  53. #define RSP_PROTOCOL_ERROR 9
  54. #define RSP_ASYNCHRONOUS_ERROR 255
  55. /* Media types */
  56. #define MEDIA_802_3 1
  57. #define MEDIA_802_5 2
  58. /* Filter parameters */
  59. #define DATA_CHAN 1
  60. #define FILTER_TYPE 2
  61. #define FILTER_MODE 3
  62. /* Filter types */
  63. #define IRLAN_DIRECTED 0x01
  64. #define IRLAN_FUNCTIONAL 0x02
  65. #define IRLAN_GROUP 0x04
  66. #define IRLAN_MAC_FRAME 0x08
  67. #define IRLAN_MULTICAST 0x10
  68. #define IRLAN_BROADCAST 0x20
  69. #define IRLAN_IPX_SOCKET 0x40
  70. /* Filter modes */
  71. #define ALL 1
  72. #define FILTER 2
  73. #define NONE 3
  74. /* Filter operations */
  75. #define GET 1
  76. #define CLEAR 2
  77. #define ADD 3
  78. #define REMOVE 4
  79. #define DYNAMIC 5
  80. /* Access types */
  81. #define ACCESS_DIRECT 1
  82. #define ACCESS_PEER 2
  83. #define ACCESS_HOSTED 3
  84. #define IRLAN_BYTE 0
  85. #define IRLAN_SHORT 1
  86. #define IRLAN_ARRAY 2
  87. /* IrLAN sits on top if IrTTP */
  88. #define IRLAN_MAX_HEADER (TTP_HEADER+LMP_HEADER)
  89. /* 1 byte for the command code and 1 byte for the parameter count */
  90. #define IRLAN_CMD_HEADER 2
  91. #define IRLAN_STRING_PARAMETER_LEN(name, value) (1 + strlen((name)) + 2 \
  92. + strlen ((value)))
  93. #define IRLAN_BYTE_PARAMETER_LEN(name) (1 + strlen((name)) + 2 + 1)
  94. #define IRLAN_SHORT_PARAMETER_LEN(name) (1 + strlen((name)) + 2 + 2)
  95. /*
  96. * IrLAN client
  97. */
  98. struct irlan_client_cb {
  99. int state;
  100. int open_retries;
  101. struct tsap_cb *tsap_ctrl;
  102. __u32 max_sdu_size;
  103. __u8 max_header_size;
  104. int access_type; /* Access type of provider */
  105. __u8 reconnect_key[255];
  106. __u8 key_len;
  107. __u16 recv_arb_val;
  108. __u16 max_frame;
  109. int filter_type;
  110. int unicast_open;
  111. int broadcast_open;
  112. int tx_busy;
  113. struct sk_buff_head txq; /* Transmit control queue */
  114. struct iriap_cb *iriap;
  115. struct timer_list kick_timer;
  116. };
  117. /*
  118. * IrLAN provider
  119. */
  120. struct irlan_provider_cb {
  121. int state;
  122. struct tsap_cb *tsap_ctrl;
  123. __u32 max_sdu_size;
  124. __u8 max_header_size;
  125. /*
  126. * Store some values here which are used by the provider to parse
  127. * the filter operations
  128. */
  129. int data_chan;
  130. int filter_type;
  131. int filter_mode;
  132. int filter_operation;
  133. int filter_entry;
  134. int access_type; /* Access type */
  135. __u16 send_arb_val;
  136. __u8 mac_address[ETH_ALEN]; /* Generated MAC address for peer device */
  137. };
  138. /*
  139. * IrLAN control block
  140. */
  141. struct irlan_cb {
  142. int magic;
  143. struct list_head dev_list;
  144. struct net_device *dev; /* Ethernet device structure*/
  145. __u32 saddr; /* Source device address */
  146. __u32 daddr; /* Destination device address */
  147. int disconnect_reason; /* Why we got disconnected */
  148. int media; /* Media type */
  149. __u8 version[2]; /* IrLAN version */
  150. struct tsap_cb *tsap_data; /* Data TSAP */
  151. int use_udata; /* Use Unit Data transfers */
  152. __u8 stsap_sel_data; /* Source data TSAP selector */
  153. __u8 dtsap_sel_data; /* Destination data TSAP selector */
  154. __u8 dtsap_sel_ctrl; /* Destination ctrl TSAP selector */
  155. struct irlan_client_cb client; /* Client specific fields */
  156. struct irlan_provider_cb provider; /* Provider specific fields */
  157. __u32 max_sdu_size;
  158. __u8 max_header_size;
  159. wait_queue_head_t open_wait;
  160. struct timer_list watchdog_timer;
  161. };
  162. void irlan_close(struct irlan_cb *self);
  163. void irlan_close_tsaps(struct irlan_cb *self);
  164. int irlan_register_netdev(struct irlan_cb *self);
  165. void irlan_ias_register(struct irlan_cb *self, __u8 tsap_sel);
  166. void irlan_start_watchdog_timer(struct irlan_cb *self, int timeout);
  167. void irlan_open_data_tsap(struct irlan_cb *self);
  168. int irlan_run_ctrl_tx_queue(struct irlan_cb *self);
  169. struct irlan_cb *irlan_get_any(void);
  170. void irlan_get_provider_info(struct irlan_cb *self);
  171. void irlan_get_media_char(struct irlan_cb *self);
  172. void irlan_open_data_channel(struct irlan_cb *self);
  173. void irlan_close_data_channel(struct irlan_cb *self);
  174. void irlan_set_multicast_filter(struct irlan_cb *self, int status);
  175. void irlan_set_broadcast_filter(struct irlan_cb *self, int status);
  176. int irlan_insert_byte_param(struct sk_buff *skb, char *param, __u8 value);
  177. int irlan_insert_short_param(struct sk_buff *skb, char *param, __u16 value);
  178. int irlan_insert_string_param(struct sk_buff *skb, char *param, char *value);
  179. int irlan_insert_array_param(struct sk_buff *skb, char *name, __u8 *value,
  180. __u16 value_len);
  181. int irlan_extract_param(__u8 *buf, char *name, char *value, __u16 *len);
  182. #endif