irnet_irda.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:5k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * IrNET protocol module : Synchronous PPP over an IrDA socket.
  3.  *
  4.  * Jean II - HPL `00 - <jt@hpl.hp.com>
  5.  *
  6.  * This file contains all definitions and declarations necessary for the
  7.  * IRDA part of the IrNET module (dealing with IrTTP, IrIAS and co).
  8.  * This file is a private header, so other modules don't want to know
  9.  * what's in there...
  10.  */
  11. #ifndef IRNET_IRDA_H
  12. #define IRNET_IRDA_H
  13. /***************************** INCLUDES *****************************/
  14. /* Please add other headers in irnet.h */
  15. #include "irnet.h" /* Module global include */
  16. /************************ CONSTANTS & MACROS ************************/
  17. /*
  18.  * Name of the service (socket name) used by IrNET
  19.  */
  20. /* IAS object name (or part of it) */
  21. #define IRNET_SERVICE_NAME "IrNetv1"
  22. /* IAS attribute */
  23. #define IRNET_IAS_VALUE "IrDA:TinyTP:LsapSel"
  24. /* LMP notify name for client (only for /proc/net/irda/irlmp) */
  25. #define IRNET_NOTIFY_NAME "IrNET socket"
  26. /* LMP notify name for server (only for /proc/net/irda/irlmp) */
  27. #define IRNET_NOTIFY_NAME_SERV "IrNET server"
  28. /****************************** TYPES ******************************/
  29. /*
  30.  * This is the main structure where we store all the data pertaining to
  31.  * the IrNET server (listen for connection requests) and the root
  32.  * of the IrNET socket list
  33.  */
  34. typedef struct irnet_root
  35. {
  36.   irnet_socket s; /* To pretend we are a client... */
  37.   /* Generic stuff */
  38.   int magic; /* Paranoia */
  39.   int running; /* Are we operational ? */
  40.   /* Link list of all IrNET instances opened */
  41.   hashbin_t * list;
  42.   spinlock_t spinlock; /* Serialize access to the list */
  43.   /* Note : the way hashbin has been designed is absolutely not
  44.    * reentrant, beware... So, we blindly protect all with spinlock */
  45.   /* Handle for the hint bit advertised in IrLMP */
  46.   __u32 skey;
  47.   /* Server socket part */
  48.   struct ias_object * ias_obj; /* Our service name + lsap in IAS */
  49. } irnet_root;
  50. /**************************** PROTOTYPES ****************************/
  51. /* ----------------------- CONTROL CHANNEL ----------------------- */
  52. static void
  53. irnet_post_event(irnet_socket *,
  54.  irnet_event,
  55.  __u32,
  56.  __u32,
  57.  char *);
  58. /* ----------------------- IRDA SUBROUTINES ----------------------- */
  59. static inline int
  60. irnet_open_tsap(irnet_socket *);
  61. static inline __u8
  62. irnet_ias_to_tsap(irnet_socket *,
  63.   int,
  64.   struct ias_value *);
  65. static inline int
  66. irnet_find_lsap_sel(irnet_socket *);
  67. static inline int
  68. irnet_connect_tsap(irnet_socket *);
  69. static inline int
  70. irnet_discover_next_daddr(irnet_socket *);
  71. static inline int
  72. irnet_discover_daddr_and_lsap_sel(irnet_socket *);
  73. static inline int
  74. irnet_dname_to_daddr(irnet_socket *);
  75. /* ------------------------ SERVER SOCKET ------------------------ */
  76. static inline int
  77. irnet_daddr_to_dname(irnet_socket *);
  78. static inline irnet_socket *
  79. irnet_find_socket(irnet_socket *);
  80. static inline int
  81. irnet_connect_socket(irnet_socket *,
  82.      irnet_socket *,
  83.      struct qos_info *,
  84.      __u32,
  85.      __u8);
  86. static inline void
  87. irnet_disconnect_server(irnet_socket *,
  88. struct sk_buff *);
  89. static inline int
  90. irnet_setup_server(void);
  91. static inline void
  92. irnet_destroy_server(void);
  93. /* ---------------------- IRDA-TTP CALLBACKS ---------------------- */
  94. static int
  95. irnet_data_indication(void *, /* instance */
  96.       void *, /* sap */
  97.       struct sk_buff *);
  98. static void
  99. irnet_disconnect_indication(void *,
  100.     void *,
  101.     LM_REASON,
  102.     struct sk_buff *);
  103. static void
  104. irnet_connect_confirm(void *,
  105.       void *,
  106.       struct qos_info *,
  107.       __u32,
  108.       __u8,
  109.       struct sk_buff *);
  110. static void
  111. irnet_flow_indication(void *,
  112.       void *,
  113.       LOCAL_FLOW);
  114. static void
  115. irnet_status_indication(void *,
  116. LINK_STATUS,
  117. LOCK_STATUS);
  118. static void
  119. irnet_connect_indication(void *,
  120.  void *,
  121.  struct qos_info *,
  122.  __u32,
  123.  __u8,
  124.  struct sk_buff *);
  125. /* -------------------- IRDA-IAS/LMP CALLBACKS -------------------- */
  126. static void
  127. irnet_getvalue_confirm(int,
  128.        __u16,
  129.        struct ias_value *,
  130.        void *);
  131. static void
  132. irnet_discovervalue_confirm(int,
  133.     __u16, 
  134.     struct ias_value *,
  135.     void *);
  136. #ifdef DISCOVERY_EVENTS
  137. static void
  138. irnet_discovery_indication(discovery_t *,
  139.    DISCOVERY_MODE,
  140.    void *);
  141. static void
  142. irnet_expiry_indication(discovery_t *,
  143. DISCOVERY_MODE,
  144. void *);
  145. #endif
  146. /* -------------------------- PROC ENTRY -------------------------- */
  147. #ifdef CONFIG_PROC_FS
  148. static int
  149. irnet_proc_read(char *,
  150. char **,
  151. off_t,
  152. int);
  153. #endif /* CONFIG_PROC_FS */
  154. /**************************** VARIABLES ****************************/
  155. /*
  156.  * The IrNET server. Listen to connection requests and co...
  157.  */
  158. static struct irnet_root irnet_server;
  159. /* Control channel stuff (note : extern) */
  160. struct irnet_ctrl_channel irnet_events;
  161. /* The /proc/net/irda directory, defined elsewhere... */
  162. #ifdef CONFIG_PROC_FS
  163. extern struct proc_dir_entry *proc_irda;
  164. #endif /* CONFIG_PROC_FS */
  165. #endif /* IRNET_IRDA_H */