vserver 2.0 rc7
[linux-2.6.git] / net / irda / ircomm / ircomm_lmp.c
index a773b35..d909720 100644 (file)
 #include <net/irda/ircomm_event.h>
 #include <net/irda/ircomm_lmp.h>
 
-/*
- * Function ircomm_open_lsap (self)
- *
- *    Open LSAP. This function will only be used when using "raw" services
- *
- */
-int ircomm_open_lsap(struct ircomm_cb *self)
-{
-       notify_t notify;
-       
-       IRDA_DEBUG(0, "%s()\n", __FUNCTION__ );
-       
-        /* Register callbacks */
-        irda_notify_init(&notify);
-       notify.data_indication       = ircomm_lmp_data_indication;
-       notify.connect_confirm       = ircomm_lmp_connect_confirm;
-        notify.connect_indication    = ircomm_lmp_connect_indication;
-       notify.disconnect_indication = ircomm_lmp_disconnect_indication;
-       notify.instance = self;
-       strlcpy(notify.name, "IrCOMM", sizeof(notify.name));
-
-       self->lsap = irlmp_open_lsap(LSAP_ANY, &notify, 0);
-       if (!self->lsap) {
-               IRDA_DEBUG(0,"%sfailed to allocate tsap\n", __FUNCTION__ );
-               return -1;
-       }
-       self->slsap_sel = self->lsap->slsap_sel;
-
-       /*
-        *  Initialize the call-table for issuing commands
-        */
-       self->issue.data_request       = ircomm_lmp_data_request;
-       self->issue.connect_request    = ircomm_lmp_connect_request;
-       self->issue.connect_response   = ircomm_lmp_connect_response;
-       self->issue.disconnect_request = ircomm_lmp_disconnect_request;
-
-       return 0;
-}
 
 /*
  * Function ircomm_lmp_connect_request (self, userdata)
@@ -86,9 +48,9 @@ int ircomm_open_lsap(struct ircomm_cb *self)
  *    
  *
  */
-int ircomm_lmp_connect_request(struct ircomm_cb *self, 
-                              struct sk_buff *userdata, 
-                              struct ircomm_info *info)
+static int ircomm_lmp_connect_request(struct ircomm_cb *self, 
+                                     struct sk_buff *userdata, 
+                                     struct ircomm_info *info)
 {
        int ret = 0;
 
@@ -109,7 +71,8 @@ int ircomm_lmp_connect_request(struct ircomm_cb *self,
  *    
  *
  */
-int ircomm_lmp_connect_response(struct ircomm_cb *self, struct sk_buff *userdata)
+static int ircomm_lmp_connect_response(struct ircomm_cb *self,
+                                      struct sk_buff *userdata)
 {
        struct sk_buff *tx_skb;
        int ret;
@@ -129,7 +92,8 @@ int ircomm_lmp_connect_response(struct ircomm_cb *self, struct sk_buff *userdata
                 *  Check that the client has reserved enough space for 
                 *  headers
                 */
-               ASSERT(skb_headroom(userdata) >= LMP_MAX_HEADER, return -1;);
+               IRDA_ASSERT(skb_headroom(userdata) >= LMP_MAX_HEADER,
+                           return -1;);
 
                /* Don't forget to refcount it - should be NULL anyway */
                skb_get(userdata);
@@ -141,9 +105,9 @@ int ircomm_lmp_connect_response(struct ircomm_cb *self, struct sk_buff *userdata
        return 0;
 }
 
-int ircomm_lmp_disconnect_request(struct ircomm_cb *self, 
-                                 struct sk_buff *userdata, 
-                                 struct ircomm_info *info)
+static int ircomm_lmp_disconnect_request(struct ircomm_cb *self, 
+                                        struct sk_buff *userdata, 
+                                        struct ircomm_info *info)
 {
         struct sk_buff *tx_skb;
        int ret;
@@ -175,13 +139,13 @@ int ircomm_lmp_disconnect_request(struct ircomm_cb *self,
  *    been deallocated. We do this to make sure we don't flood IrLAP with 
  *    frames, since we are not using the IrTTP flow control mechanism
  */
-void ircomm_lmp_flow_control(struct sk_buff *skb)
+static void ircomm_lmp_flow_control(struct sk_buff *skb)
 {
        struct irda_skb_cb *cb;
        struct ircomm_cb *self;
        int line;
 
-       ASSERT(skb != NULL, return;);
+       IRDA_ASSERT(skb != NULL, return;);
 
        cb = (struct irda_skb_cb *) skb->cb;
 
@@ -195,8 +159,8 @@ void ircomm_lmp_flow_control(struct sk_buff *skb)
                 return;
        }
 
-        ASSERT(self != NULL, return;);
-       ASSERT(self->magic == IRCOMM_MAGIC, return;);
+        IRDA_ASSERT(self != NULL, return;);
+       IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return;);
 
        self->pkt_count--;
 
@@ -215,13 +179,14 @@ void ircomm_lmp_flow_control(struct sk_buff *skb)
  *    Send data frame to peer device
  *
  */
-int ircomm_lmp_data_request(struct ircomm_cb *self, struct sk_buff *skb, 
-                           int not_used)
+static int ircomm_lmp_data_request(struct ircomm_cb *self,
+                                  struct sk_buff *skb, 
+                                  int not_used)
 {
        struct irda_skb_cb *cb;
        int ret;
 
-       ASSERT(skb != NULL, return -1;);
+       IRDA_ASSERT(skb != NULL, return -1;);
 
        cb = (struct irda_skb_cb *) skb->cb;
        
@@ -243,7 +208,7 @@ int ircomm_lmp_data_request(struct ircomm_cb *self, struct sk_buff *skb,
         }
        ret = irlmp_data_request(self->lsap, skb);
        if (ret) {
-               ERROR("%s(), failed\n", __FUNCTION__);
+               IRDA_ERROR("%s(), failed\n", __FUNCTION__);
                /* irlmp_data_request already free the packet */
        }
 
@@ -256,16 +221,16 @@ int ircomm_lmp_data_request(struct ircomm_cb *self, struct sk_buff *skb,
  *    Incoming data which we must deliver to the state machine, to check
  *    we are still connected.
  */
-int ircomm_lmp_data_indication(void *instance, void *sap,
-                              struct sk_buff *skb)
+static int ircomm_lmp_data_indication(void *instance, void *sap,
+                                     struct sk_buff *skb)
 {
        struct ircomm_cb *self = (struct ircomm_cb *) instance;
 
        IRDA_DEBUG(4, "%s()\n", __FUNCTION__ );
        
-       ASSERT(self != NULL, return -1;);
-       ASSERT(self->magic == IRCOMM_MAGIC, return -1;);
-       ASSERT(skb != NULL, return -1;);
+       IRDA_ASSERT(self != NULL, return -1;);
+       IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return -1;);
+       IRDA_ASSERT(skb != NULL, return -1;);
        
        ircomm_do_event(self, IRCOMM_LMP_DATA_INDICATION, skb, NULL);
 
@@ -282,21 +247,21 @@ int ircomm_lmp_data_indication(void *instance, void *sap,
  *    Connection has been confirmed by peer device
  *
  */
-void ircomm_lmp_connect_confirm(void *instance, void *sap,
-                               struct qos_info *qos, 
-                               __u32 max_seg_size, 
-                               __u8 max_header_size,
-                               struct sk_buff *skb)
+static void ircomm_lmp_connect_confirm(void *instance, void *sap,
+                                      struct qos_info *qos, 
+                                      __u32 max_seg_size, 
+                                      __u8 max_header_size,
+                                      struct sk_buff *skb)
 {
        struct ircomm_cb *self = (struct ircomm_cb *) instance;
        struct ircomm_info info;
 
        IRDA_DEBUG(0, "%s()\n", __FUNCTION__ );
 
-       ASSERT(self != NULL, return;);
-       ASSERT(self->magic == IRCOMM_MAGIC, return;);
-       ASSERT(skb != NULL, return;);
-       ASSERT(qos != NULL, return;);
+       IRDA_ASSERT(self != NULL, return;);
+       IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return;);
+       IRDA_ASSERT(skb != NULL, return;);
+       IRDA_ASSERT(qos != NULL, return;);
 
        info.max_data_size = max_seg_size;
        info.max_header_size = max_header_size;
@@ -315,21 +280,21 @@ void ircomm_lmp_connect_confirm(void *instance, void *sap,
  *    Peer device wants to make a connection with us
  *
  */
-void ircomm_lmp_connect_indication(void *instance, void *sap,
-                                  struct qos_info *qos,
-                                  __u32 max_seg_size,
-                                  __u8 max_header_size,
-                                  struct sk_buff *skb)
+static void ircomm_lmp_connect_indication(void *instance, void *sap,
+                                         struct qos_info *qos,
+                                         __u32 max_seg_size,
+                                         __u8 max_header_size,
+                                         struct sk_buff *skb)
 {
        struct ircomm_cb *self = (struct ircomm_cb *)instance;
        struct ircomm_info info;
 
        IRDA_DEBUG(0, "%s()\n", __FUNCTION__ );
 
-       ASSERT(self != NULL, return;);
-       ASSERT(self->magic == IRCOMM_MAGIC, return;);
-       ASSERT(skb != NULL, return;);
-       ASSERT(qos != NULL, return;);
+       IRDA_ASSERT(self != NULL, return;);
+       IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return;);
+       IRDA_ASSERT(skb != NULL, return;);
+       IRDA_ASSERT(qos != NULL, return;);
 
        info.max_data_size = max_seg_size;
        info.max_header_size = max_header_size;
@@ -347,17 +312,17 @@ void ircomm_lmp_connect_indication(void *instance, void *sap,
  *    Peer device has closed the connection, or the link went down for some
  *    other reason
  */
-void ircomm_lmp_disconnect_indication(void *instance, void *sap, 
-                                     LM_REASON reason,
-                                     struct sk_buff *skb)
+static void ircomm_lmp_disconnect_indication(void *instance, void *sap, 
+                                            LM_REASON reason,
+                                            struct sk_buff *skb)
 {
        struct ircomm_cb *self = (struct ircomm_cb *) instance;
        struct ircomm_info info;
 
        IRDA_DEBUG(0, "%s()\n", __FUNCTION__ );
 
-       ASSERT(self != NULL, return;);
-       ASSERT(self->magic == IRCOMM_MAGIC, return;);
+       IRDA_ASSERT(self != NULL, return;);
+       IRDA_ASSERT(self->magic == IRCOMM_MAGIC, return;);
 
        info.reason = reason;
 
@@ -367,3 +332,41 @@ void ircomm_lmp_disconnect_indication(void *instance, void *sap,
        if(skb)
                dev_kfree_skb(skb);
 }
+/*
+ * Function ircomm_open_lsap (self)
+ *
+ *    Open LSAP. This function will only be used when using "raw" services
+ *
+ */
+int ircomm_open_lsap(struct ircomm_cb *self)
+{
+       notify_t notify;
+
+       IRDA_DEBUG(0, "%s()\n", __FUNCTION__ );
+
+       /* Register callbacks */
+       irda_notify_init(&notify);
+       notify.data_indication       = ircomm_lmp_data_indication;
+       notify.connect_confirm       = ircomm_lmp_connect_confirm;
+       notify.connect_indication    = ircomm_lmp_connect_indication;
+       notify.disconnect_indication = ircomm_lmp_disconnect_indication;
+       notify.instance = self;
+       strlcpy(notify.name, "IrCOMM", sizeof(notify.name));
+
+       self->lsap = irlmp_open_lsap(LSAP_ANY, &notify, 0);
+       if (!self->lsap) {
+               IRDA_DEBUG(0,"%sfailed to allocate tsap\n", __FUNCTION__ );
+               return -1;
+       }
+       self->slsap_sel = self->lsap->slsap_sel;
+
+       /*
+        *  Initialize the call-table for issuing commands
+        */
+       self->issue.data_request       = ircomm_lmp_data_request;
+       self->issue.connect_request    = ircomm_lmp_connect_request;
+       self->issue.connect_response   = ircomm_lmp_connect_response;
+       self->issue.disconnect_request = ircomm_lmp_disconnect_request;
+
+       return 0;
+}