patch-2.2.3 linux/net/irda/irlan/irlan_common.c
Next file: linux/net/irda/irlan/irlan_eth.c
Previous file: linux/net/irda/irlan/irlan_client_event.c
Back to the patch index
Back to the overall index
- Lines: 1628
- Date:
Sun Mar 7 15:26:44 1999
- Orig file:
v2.2.2/linux/net/irda/irlan/irlan_common.c
- Orig date:
Wed Jan 20 23:14:07 1999
diff -u --recursive --new-file v2.2.2/linux/net/irda/irlan/irlan_common.c linux/net/irda/irlan/irlan_common.c
@@ -1,12 +1,12 @@
/*********************************************************************
*
* Filename: irlan_common.c
- * Version: 0.1
+ * Version: 0.9
* Description: IrDA LAN Access Protocol Implementation
* Status: Experimental.
* Author: Dag Brattli <dagb@cs.uit.no>
* Created at: Sun Aug 31 20:14:37 1997
- * Modified at: Tue Jan 19 23:11:30 1999
+ * Modified at: Wed Feb 17 23:49:10 1999
* Modified by: Dag Brattli <dagb@cs.uit.no>
*
* Copyright (c) 1997 Dag Brattli <dagb@cs.uit.no>, All Rights Reserved.
@@ -44,17 +44,59 @@
#include <net/irda/timer.h>
#include <net/irda/irlan_common.h>
+#include <net/irda/irlan_client.h>
+#include <net/irda/irlan_provider.h>
+#include <net/irda/irlan_eth.h>
+#include <net/irda/irlan_filter.h>
-static void __irlan_close( struct irlan_cb *self);
+/* extern char sysctl_devname[]; */
/*
* Master structure
*/
hashbin_t *irlan = NULL;
+/* Module parameters */
+static int eth = 0; /* Use "eth" or "irlan" name for devices */
+static int access = ACCESS_PEER; /* PEER, DIRECT or HOSTED */
+static int timeout = IRLAN_TIMEOUT;
+
+static char *irlan_state[] = {
+ "IRLAN_IDLE",
+ "IRLAN_QUERY",
+ "IRLAN_CONN",
+ "IRLAN_INFO",
+ "IRLAN_MEDIA",
+ "IRLAN_OPEN",
+ "IRLAN_WAIT",
+ "IRLAN_ARB",
+ "IRLAN_DATA",
+ "IRLAN_CLOSE",
+ "IRLAN_SYNC"
+};
+
+static char *irlan_access[] = {
+ "UNKNOWN",
+ "DIRECT",
+ "PEER",
+ "HOSTED"
+};
+
+static char *irlan_media[] = {
+ "UNKNOWN",
+ "802.3",
+ "802.5"
+};
+
+static void __irlan_close(struct irlan_cb *self);
+static int __irlan_insert_param(struct sk_buff *skb, char *param, int type,
+ __u8 value_byte, __u16 value_short,
+ __u8 *value_array, __u16 value_len);
+static void irlan_close_tsaps(struct irlan_cb *self);
+
#ifdef CONFIG_PROC_FS
-static int irlan_proc_read( char *buf, char **start, off_t offset,
- int len, int unused);
+static int irlan_proc_read(char *buf, char **start, off_t offset, int len,
+ int unused);
extern struct proc_dir_entry proc_irda;
@@ -64,7 +106,164 @@
0, NULL,
&irlan_proc_read,
};
+#endif /* CONFIG_PROC_FS */
+
+void irlan_watchdog_timer_expired(unsigned long data)
+{
+ struct irmanager_event mgr_event;
+ struct irlan_cb *self = (struct irlan_cb *) data;
+
+ DEBUG(2, __FUNCTION__ "()\n");
+
+ ASSERT(self != NULL, return;);
+ ASSERT(self->magic == IRLAN_MAGIC, return;);
+
+ /* Check if device still configured */
+ if (self->dev.start) {
+ mgr_event.event = EVENT_IRLAN_STOP;
+ sprintf(mgr_event.devname, "%s", self->ifname);
+ irmanager_notify(&mgr_event);
+
+ /*
+ * We set this to false, so that irlan_dev_close known that
+ * notify_irmanager should actually be set to TRUE again
+ * instead of FALSE, since this close has not been initiated
+ * by the user.
+ */
+ self->notify_irmanager = FALSE;
+ } else
+ irlan_close(self);
+}
+
+void irlan_start_watchdog_timer(struct irlan_cb *self, int timeout)
+{
+ DEBUG(4, __FUNCTION__ "()\n");
+
+ irda_start_timer(&self->watchdog_timer, timeout, (unsigned long) self,
+ irlan_watchdog_timer_expired);
+}
+
+static int irlan_eth_open(struct device *dev)
+{
+ struct irlan_cb *self;
+
+ DEBUG(4, __FUNCTION__ "()\n");
+
+ ASSERT(dev != NULL, return -1;);
+
+ self = (struct irlan_cb *) dev->priv;
+
+ ASSERT(self != NULL, return -1;);
+
+ /* Ready to play! */
+/* dev->tbusy = 0; */ /* Wait until data link is ready */
+ dev->interrupt = 0;
+ dev->start = 1;
+
+ self->notify_irmanager = TRUE;
+
+ MOD_INC_USE_COUNT;
+
+ return 0;
+}
+
+/*
+ * Function irlan_eth_close (dev)
+ *
+ * Stop the ether network device, his function will usually be called by
+ * ifconfig down. We should now disconnect the link, We start the
+ * close timer, so that the instance will be removed if we are unable
+ * to discover the remote device after the disconnect.
+ */
+static int irlan_eth_close(struct device *dev)
+{
+ struct irlan_cb *self = (struct irlan_cb *) dev->priv;
+
+ DEBUG(4, __FUNCTION__ "()\n");
+
+ /* Stop device */
+ dev->tbusy = 1;
+ dev->start = 0;
+
+ MOD_DEC_USE_COUNT;
+
+ irlan_close_data_channel(self);
+
+ irlan_close_tsaps(self);
+
+ irlan_do_client_event(self, IRLAN_LMP_DISCONNECT, NULL);
+ irlan_do_provider_event(self, IRLAN_LMP_DISCONNECT, NULL);
+
+ irlan_start_watchdog_timer(self, IRLAN_TIMEOUT);
+
+ /* Device closed by user */
+ if (self->notify_irmanager)
+ self->notify_irmanager = FALSE;
+ else
+ self->notify_irmanager = TRUE;
+
+ return 0;
+}
+/*
+ * Function irlan_eth_init (dev)
+ *
+ * The network device initialization function.
+ *
+ */
+int irlan_eth_init(struct device *dev)
+{
+ struct irmanager_event mgr_event;
+ struct irlan_cb *self;
+
+ DEBUG(4, __FUNCTION__"()\n");
+
+ ASSERT(dev != NULL, return -1;);
+
+ self = (struct irlan_cb *) dev->priv;
+
+ dev->open = irlan_eth_open;
+ dev->stop = irlan_eth_close;
+ dev->hard_start_xmit = irlan_eth_xmit;
+ dev->get_stats = irlan_eth_get_stats;
+ dev->set_multicast_list = irlan_eth_set_multicast_list;
+
+ dev->tbusy = 1;
+
+ ether_setup(dev);
+
+ dev->tx_queue_len = TTP_MAX_QUEUE;
+
+#ifdef 0
+ /*
+ * OK, since we are emulating an IrLAN sever we will have to give
+ * ourself an ethernet address!
+ * FIXME: this must be more dynamically
+ */
+ dev->dev_addr[0] = 0x40;
+ dev->dev_addr[1] = 0x00;
+ dev->dev_addr[2] = 0x00;
+ dev->dev_addr[3] = 0x00;
+ dev->dev_addr[4] = 0x23;
+ dev->dev_addr[5] = 0x45;
#endif
+ /*
+ * Network device has now been registered, so tell irmanager about
+ * it, so it can be configured with network parameters
+ */
+ mgr_event.event = EVENT_IRLAN_START;
+ sprintf(mgr_event.devname, "%s", self->ifname);
+ irmanager_notify(&mgr_event);
+
+ /*
+ * We set this so that we only notify once, since if
+ * configuration of the network device fails, the user
+ * will have to sort it out first anyway. No need to
+ * try again.
+ */
+ self->notify_irmanager = FALSE;
+
+ return 0;
+}
/*
* Function irlan_init (void)
@@ -72,61 +271,147 @@
* Initialize IrLAN layer
*
*/
-__initfunc(int irlan_init( void))
+__initfunc(int irlan_init(void))
{
+ struct irlan_cb *new;
+
+ DEBUG(4, __FUNCTION__"()\n");
+
/* Allocate master array */
- irlan = hashbin_new( HB_LOCAL);
- if ( irlan == NULL) {
- printk( KERN_WARNING "IrLAN: Can't allocate hashbin!\n");
+ irlan = hashbin_new(HB_LOCAL);
+ if (irlan == NULL) {
+ printk(KERN_WARNING "IrLAN: Can't allocate hashbin!\n");
return -ENOMEM;
}
#ifdef CONFIG_PROC_FS
- proc_register( &proc_irda, &proc_irlan);
+ proc_register(&proc_irda, &proc_irlan);
#endif /* CONFIG_PROC_FS */
+ DEBUG(4, __FUNCTION__ "()\n");
+
+ /* Register with IrLMP as a service user */
+ irlmp_register_layer(S_LAN, CLIENT, TRUE,
+ irlan_client_discovery_indication);
+
+ /* Register with IrLMP as a service */
+ irlmp_register_layer(S_LAN, SERVER, FALSE, NULL);
+
+ /* Start the first IrLAN instance */
+ new = irlan_open(DEV_ADDR_ANY, DEV_ADDR_ANY, FALSE);
+
+ /* Do some fast discovery! */
+ irlmp_discovery_request(8);
+
return 0;
}
void irlan_cleanup(void)
{
- DEBUG( 4, __FUNCTION__ "()\n");
+ DEBUG(4, __FUNCTION__ "()\n");
+
+ irlmp_unregister_layer(S_LAN, SERVER);
+
+ irlmp_unregister_layer(S_LAN, CLIENT);
#ifdef CONFIG_PROC_FS
- proc_unregister( &proc_irda, proc_irlan.low_ino);
-#endif
+ proc_unregister(&proc_irda, proc_irlan.low_ino);
+#endif /* CONFIG_PROC_FS */
/*
* Delete hashbin and close all irlan client instances in it
*/
- hashbin_delete( irlan, (FREE_FUNC) __irlan_close);
+ hashbin_delete(irlan, (FREE_FUNC) __irlan_close);
}
+/*
+ * Function irlan_register_netdev (self)
+ *
+ * Registers the network device to be used. We should don't register until
+ * we have been binded to a particular provider or client.
+ */
+int irlan_register_netdev(struct irlan_cb *self)
+{
+ int i=0;
+
+ DEBUG(4, __FUNCTION__ "()\n");
+
+ /* Check if we should call the device eth<x> or irlan<x> */
+ if (!eth) {
+ /* Get the first free irlan<x> name */
+ do {
+ sprintf(self->ifname, "%s%d", "irlan", i++);
+ } while (dev_get(self->ifname) != NULL);
+ }
+ self->dev.name = self->ifname;
+
+ if (register_netdev(&self->dev) != 0) {
+ DEBUG(2, __FUNCTION__
+ "(), register_netdev() failed!\n");
+ return -1;
+ }
+ self->netdev_registered = TRUE;
+
+ return 0;
+}
/*
* Function irlan_open (void)
*
- *
- *
+ * Open new instance of a client/provider, we should only register the
+ * network device if this instance is ment for a particular client/provider
*/
-struct irlan_cb *irlan_open(void)
+struct irlan_cb *irlan_open(__u32 saddr, __u32 daddr, int netdev)
{
struct irlan_cb *self;
- DEBUG( 4, __FUNCTION__ "()\n");
+ DEBUG(2, __FUNCTION__ "()\n");
/*
* Initialize the irlan structure.
*/
- self = kmalloc( sizeof(struct irlan_cb), GFP_ATOMIC);
- if ( self == NULL)
+ self = kmalloc(sizeof(struct irlan_cb), GFP_ATOMIC);
+ if (self == NULL)
return NULL;
- memset( self, 0, sizeof( struct irlan_cb));
+ memset(self, 0, sizeof(struct irlan_cb));
/*
* Initialize local device structure
*/
self->magic = IRLAN_MAGIC;
+ ASSERT(irlan != NULL, return NULL;);
+
+ sprintf(self->ifname, "%s", "unknown");
+
+ self->dev.priv = (void *) self;
+ self->dev.next = NULL;
+ self->dev.init = irlan_eth_init;
+
+ self->saddr = saddr;
+ self->daddr = daddr;
+
+ /* Provider access can only be PEER, DIRECT, or HOSTED */
+ self->access_type = access;
+ self->media = MEDIA_802_3;
+
+ self->notify_irmanager = TRUE;
+
+ init_timer(&self->watchdog_timer);
+ init_timer(&self->client.kick_timer);
+
+ hashbin_insert(irlan, (QUEUE *) self, daddr, NULL);
+
+ irlan_next_client_state(self, IRLAN_IDLE);
+ irlan_next_provider_state(self, IRLAN_IDLE);
+
+ irlan_open_data_tsap(self);
+ irlan_provider_open_ctrl_tsap(self);
+ irlan_client_open_ctrl_tsap(self);
+
+ /* Register network device now, or wait until some later time? */
+ if (netdev)
+ irlan_register_netdev(self);
+
return self;
}
/*
@@ -137,63 +422,281 @@
* hashbin_remove() first!!!
*
*/
-void __irlan_close( struct irlan_cb *self)
+static void __irlan_close(struct irlan_cb *self)
{
- DEBUG( 4, __FUNCTION__ "()\n");
+ DEBUG(2, __FUNCTION__ "()\n");
- ASSERT( self != NULL, return;);
- ASSERT( self->magic == IRLAN_MAGIC, return;);
+ ASSERT(self != NULL, return;);
+ ASSERT(self->magic == IRLAN_MAGIC, return;);
- /*
- * Disconnect open TSAP connections
- */
- if ( self->tsap_data) {
- irttp_disconnect_request( self->tsap_data, NULL, P_HIGH);
-
- /* FIXME: this will close the tsap before the disconenct
- * frame has been sent
+ del_timer(&self->watchdog_timer);
+ del_timer(&self->client.kick_timer);
+
+ /* Close all open connections and remove TSAPs */
+ irlan_close_tsaps(self);
+
+ if (self->netdev_registered)
+ unregister_netdev(&self->dev);
+
+ self->magic = 0;
+ kfree(self);
+}
+
+/*
+ * Function irlan_close (self)
+ *
+ * Close instance
+ *
+ */
+void irlan_close(struct irlan_cb *self)
+{
+ struct irlan_cb *entry;
+
+ DEBUG(2, __FUNCTION__ "()\n");
+
+ ASSERT(self != NULL, return;);
+ ASSERT(self->magic == IRLAN_MAGIC, return;);
+
+ /* Check if device is still configured */
+ if (self->dev.start) {
+ DEBUG(2, __FUNCTION__
+ "(), Device still configured, closing later!\n");
+ return;
+ }
+ DEBUG(2, __FUNCTION__ "(), daddr=%08x\n", self->daddr);
+ entry = hashbin_remove(irlan, self->daddr, NULL);
+
+ ASSERT(entry == self, return;);
+
+ __irlan_close(self);
+}
+
+void irlan_connect_indication(void *instance, void *sap, struct qos_info *qos,
+ int max_sdu_size, struct sk_buff *skb)
+{
+ struct irlan_cb *self;
+ struct tsap_cb *tsap;
+
+ DEBUG(2, __FUNCTION__ "()\n");
+
+ self = (struct irlan_cb *) instance;
+ tsap = (struct tsap_cb *) sap;
+
+ ASSERT(self != NULL, return;);
+ ASSERT(self->magic == IRLAN_MAGIC, return;);
+ ASSERT(tsap == self->tsap_data,return;);
+
+ DEBUG(2, "IrLAN, We are now connected!\n");
+ del_timer(&self->watchdog_timer);
+
+ irlan_do_provider_event(self, IRLAN_DATA_CONNECT_INDICATION, skb);
+ irlan_do_client_event(self, IRLAN_DATA_CONNECT_INDICATION, skb);
+
+ if (self->access_type == ACCESS_PEER) {
+ /*
+ * Data channel is open, so we are now allowed to
+ * configure the remote filter
*/
- /* irttp_close_tsap( self->tsap_data); */
+ irlan_get_unicast_addr(self);
+ irlan_open_unicast_addr(self);
}
- if ( self->tsap_ctrl) {
- irttp_disconnect_request( self->tsap_ctrl, NULL, P_HIGH);
-
- /* irttp_close_tsap( self->tsap_control); */
+ /* Ready to transfer Ethernet frames */
+ self->dev.tbusy = 0;
+}
+
+void irlan_connect_confirm(void *instance, void *sap, struct qos_info *qos,
+ int max_sdu_size, struct sk_buff *skb)
+{
+ struct irlan_cb *self;
+
+ DEBUG(2, __FUNCTION__ "()\n");
+
+ self = (struct irlan_cb *) instance;
+
+ ASSERT(self != NULL, return;);
+ ASSERT(self->magic == IRLAN_MAGIC, return;);
+
+ /* TODO: we could set the MTU depending on the max_sdu_size */
+
+ DEBUG(2, "IrLAN, We are now connected!\n");
+ del_timer(&self->watchdog_timer);
+
+ /*
+ * Data channel is open, so we are now allowed to configure the remote
+ * filter
+ */
+ irlan_get_unicast_addr(self);
+ irlan_open_unicast_addr(self);
+
+ /* Ready to transfer Ethernet frames */
+ self->dev.tbusy = 0;
+}
+
+/*
+ * Function irlan_client_disconnect_indication (handle)
+ *
+ * Callback function for the IrTTP layer. Indicates a disconnection of
+ * the specified connection (handle)
+ */
+void irlan_disconnect_indication(void *instance, void *sap, LM_REASON reason,
+ struct sk_buff *userdata)
+{
+ struct irlan_cb *self;
+ struct tsap_cb *tsap;
+
+ DEBUG(2, __FUNCTION__ "(), reason=%d\n", reason);
+
+ self = (struct irlan_cb *) instance;
+ tsap = (struct tsap_cb *) sap;
+
+ ASSERT(self != NULL, return;);
+ ASSERT(self->magic == IRLAN_MAGIC, return;);
+ ASSERT(tsap != NULL, return;);
+ ASSERT(tsap->magic == TTP_TSAP_MAGIC, return;);
+
+ ASSERT(tsap == self->tsap_data, return;);
+
+ DEBUG(2, "IrLAN, data channel disconnected by peer!\n");
+
+ switch(reason) {
+ case LM_USER_REQUEST: /* User request */
+ irlan_close(self);
+ break;
+ case LM_LAP_DISCONNECT: /* Unexpected IrLAP disconnect */
+ irlan_start_watchdog_timer(self, IRLAN_TIMEOUT);
+ break;
+ case LM_CONNECT_FAILURE: /* Failed to establish IrLAP connection */
+ DEBUG(2, __FUNCTION__ "(), LM_CONNECT_FAILURE not impl\n");
+ break;
+ case LM_LAP_RESET: /* IrLAP reset */
+ DEBUG(2, __FUNCTION__ "(), LM_CONNECT_FAILURE not impl\n");
+ break;
+ case LM_INIT_DISCONNECT:
+ DEBUG(2, __FUNCTION__ "(), LM_CONNECT_FAILURE not impl\n");
+ break;
+ default:
+ break;
}
- unregister_netdev( &self->dev);
+ /* Stop IP from transmitting more packets */
+ /* irlan_client_flow_indication(handle, FLOW_STOP, priv); */
- /*
- * Make sure that nobody uses this instance anymore!
+ irlan_do_client_event(self, IRLAN_LMP_DISCONNECT, NULL);
+ irlan_do_provider_event(self, IRLAN_LMP_DISCONNECT, NULL);
+}
+
+void irlan_open_data_tsap(struct irlan_cb *self)
+{
+ struct notify_t notify;
+ struct tsap_cb *tsap;
+
+ DEBUG(4, __FUNCTION__ "()\n");
+
+ ASSERT(self != NULL, return;);
+ ASSERT(self->magic == IRLAN_MAGIC, return;);
+
+ /* Check if already open */
+ if (self->tsap_data)
+ return;
+
+ irda_notify_init(¬ify);
+
+ notify.data_indication = irlan_eth_receive;
+ notify.udata_indication = irlan_eth_receive;
+ notify.connect_indication = irlan_connect_indication;
+ notify.connect_confirm = irlan_connect_confirm;
+ notify.flow_indication = irlan_eth_flow_indication;
+ notify.disconnect_indication = irlan_disconnect_indication;
+ notify.instance = self;
+ strncpy(notify.name, "IrLAN data", NOTIFY_MAX_NAME);
+
+ tsap = irttp_open_tsap(LSAP_ANY, DEFAULT_INITIAL_CREDIT, ¬ify);
+ if (!tsap) {
+ DEBUG(2, __FUNCTION__ "(), Got no tsap!\n");
+ return;
+ }
+ self->tsap_data = tsap;
+
+ /*
+ * This is the data TSAP selector which we will pass to the client
+ * when the client ask for it.
*/
- self->magic = 0;
-
- /*
- * Dealloacte structure
+ self->stsap_sel_data = self->tsap_data->stsap_sel;
+}
+
+static void irlan_close_tsaps(struct irlan_cb *self)
+{
+ DEBUG(4, __FUNCTION__ "()\n");
+
+ ASSERT(self != NULL, return;);
+ ASSERT(self->magic == IRLAN_MAGIC, return;);
+
+ /*
+ * Disconnect and close all open TSAP connections
*/
- kfree( self);
+ if (self->tsap_data) {
+ irttp_disconnect_request(self->tsap_data, NULL, P_NORMAL);
+ irttp_close_tsap(self->tsap_data);
+ self->tsap_data = NULL;
+
+ }
+ if (self->client.tsap_ctrl) {
+ irttp_disconnect_request(self->client.tsap_ctrl, NULL,
+ P_NORMAL);
+ irttp_close_tsap(self->client.tsap_ctrl);
+ self->client.tsap_ctrl = NULL;
+ }
+ if (self->provider.tsap_ctrl) {
+ irttp_disconnect_request(self->provider.tsap_ctrl, NULL,
+ P_NORMAL);
+ irttp_close_tsap(self->provider.tsap_ctrl);
+ self->provider.tsap_ctrl = NULL;
+ }
}
/*
- * Function irlan_close (self)
+ * Function irlan_ias_register (self, tsap_sel)
*
- *
+ * Register with LM-IAS
*
*/
-void irlan_close( struct irlan_cb *self)
+void irlan_ias_register(struct irlan_cb *self, __u8 tsap_sel)
{
- struct irlan_cb *entry;
-
- DEBUG( 4, __FUNCTION__ "()\n");
+ struct ias_object *obj;
+ struct ias_value *new_value;
- ASSERT( self != NULL, return;);
- ASSERT( self->magic == IRLAN_MAGIC, return;);
+ ASSERT(self != NULL, return;);
+ ASSERT(self->magic == IRLAN_MAGIC, return;);
- entry = hashbin_remove( irlan, self->daddr, NULL);
-
- ASSERT( entry == self, return;);
+ /*
+ * Check if object has already been registred by a previous provider.
+ * If that is the case, we just change the value of the attribute
+ */
+ if (!irias_find_object("IrLAN")) {
+ obj = irias_new_object("IrLAN", IAS_IRLAN_ID);
+ irias_add_integer_attrib(obj, "IrDA:TinyTP:LsapSel", tsap_sel);
+ irias_insert_object(obj);
+ } else {
+ new_value = irias_new_integer_value(tsap_sel);
+ irias_object_change_attribute("IrLAN", "IrDA:TinyTP:LsapSel",
+ new_value);
+ }
- __irlan_close( self);
+ /* Register PnP object only if not registred before */
+ if (!irias_find_object("PnP")) {
+ obj = irias_new_object("PnP", IAS_PNP_ID);
+#if 0
+ irias_add_string_attrib(obj, "Name", sysctl_devname);
+#else
+ irias_add_string_attrib(obj, "Name", "Linux");
+#endif
+ irias_add_string_attrib(obj, "DeviceID", "HWP19F0");
+ irias_add_integer_attrib(obj, "CompCnt", 2);
+ irias_add_string_attrib(obj, "Comp#01", "PNP8294");
+ irias_add_string_attrib(obj, "Comp#02", "PNP8389");
+ irias_add_string_attrib(obj, "Manufacturer", "Linux-IrDA Project");
+ irias_insert_object(obj);
+ }
}
/*
@@ -202,33 +705,30 @@
* Send Get Provider Information command to peer IrLAN layer
*
*/
-void irlan_get_provider_info( struct irlan_cb *self)
+void irlan_get_provider_info(struct irlan_cb *self)
{
struct sk_buff *skb;
__u8 *frame;
- DEBUG( 4, __FUNCTION__ "()\n");
+ DEBUG(4, __FUNCTION__ "()\n");
- ASSERT( self != NULL, return;);
- ASSERT( self->magic == IRLAN_MAGIC, return;);
+ ASSERT(self != NULL, return;);
+ ASSERT(self->magic == IRLAN_MAGIC, return;);
- skb = dev_alloc_skb( 64);
- if (skb == NULL) {
- DEBUG( 0, __FUNCTION__
- "(), Could not allocate an skb of length %d\n", 64);
+ skb = dev_alloc_skb(64);
+ if (!skb)
return;
- }
/* Reserve space for TTP, LMP, and LAP header */
- skb_reserve( skb, TTP_HEADER+LMP_HEADER+LAP_HEADER);
- skb_put( skb, 2);
+ skb_reserve(skb, TTP_HEADER+LMP_HEADER+LAP_HEADER);
+ skb_put(skb, 2);
frame = skb->data;
frame[0] = CMD_GET_PROVIDER_INFO;
frame[1] = 0x00; /* Zero parameters */
- irttp_data_request( self->tsap_ctrl, skb);
+ irttp_data_request(self->client.tsap_ctrl, skb);
}
/*
@@ -237,26 +737,22 @@
* Send an Open Data Command to provider
*
*/
-void irlan_open_data_channel( struct irlan_cb *self)
+void irlan_open_data_channel(struct irlan_cb *self)
{
struct sk_buff *skb;
__u8 *frame;
- DEBUG( 4, __FUNCTION__ "()\n");
+ DEBUG(4, __FUNCTION__ "()\n");
- ASSERT( self != NULL, return;);
- ASSERT( self->magic == IRLAN_MAGIC, return;);
+ ASSERT(self != NULL, return;);
+ ASSERT(self->magic == IRLAN_MAGIC, return;);
- skb = dev_alloc_skb( 64);
- if (skb == NULL) {
- DEBUG( 0, __FUNCTION__
- "(), Could not allocate an skb of length %d\n", 64);
+ skb = dev_alloc_skb(64);
+ if (!skb)
return;
- }
- /* Reserve space for TTP, LMP, and LAP header */
- skb_reserve( skb, TTP_HEADER+LMP_HEADER+LAP_HEADER);
- skb_put( skb, 2);
+ skb_reserve(skb, TTP_HEADER+LMP_HEADER+LAP_HEADER);
+ skb_put(skb, 2);
frame = skb->data;
@@ -264,13 +760,41 @@
frame[0] = CMD_OPEN_DATA_CHANNEL;
frame[1] = 0x02; /* Two parameters */
- insert_string_param( skb, "MEDIA", "802.3");
- insert_string_param( skb, "ACCESS_TYPE", "DIRECT");
- /* insert_string_param( skb, "MODE", "UNRELIABLE"); */
+ irlan_insert_string_param(skb, "MEDIA", "802.3");
+ irlan_insert_string_param(skb, "ACCESS_TYPE", "DIRECT");
+ /* irlan_insert_string_param(skb, "MODE", "UNRELIABLE"); */
/* self->use_udata = TRUE; */
- irttp_data_request( self->tsap_ctrl, skb);
+ irttp_data_request(self->client.tsap_ctrl, skb);
+}
+
+void irlan_close_data_channel(struct irlan_cb *self)
+{
+ struct sk_buff *skb;
+ __u8 *frame;
+
+ DEBUG(4, __FUNCTION__ "()\n");
+
+ ASSERT(self != NULL, return;);
+ ASSERT(self->magic == IRLAN_MAGIC, return;);
+
+ skb = dev_alloc_skb(64);
+ if (!skb)
+ return;
+
+ skb_reserve(skb, TTP_HEADER+LMP_HEADER+LAP_HEADER);
+ skb_put(skb, 2);
+
+ frame = skb->data;
+
+ /* Build frame */
+ frame[0] = CMD_CLOSE_DATA_CHAN;
+ frame[1] = 0x01; /* Two parameters */
+
+ irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data);
+
+ irttp_data_request(self->client.tsap_ctrl, skb);
}
/*
@@ -280,84 +804,74 @@
* address.
*
*/
-void irlan_open_unicast_addr( struct irlan_cb *self)
+void irlan_open_unicast_addr(struct irlan_cb *self)
{
struct sk_buff *skb;
__u8 *frame;
- DEBUG( 4, __FUNCTION__ "()\n");
+ DEBUG(4, __FUNCTION__ "()\n");
- ASSERT( self != NULL, return;);
- ASSERT( self->magic == IRLAN_MAGIC, return;);
+ ASSERT(self != NULL, return;);
+ ASSERT(self->magic == IRLAN_MAGIC, return;);
- skb = dev_alloc_skb( 128);
- if (skb == NULL) {
- DEBUG( 0, __FUNCTION__
- "(), Could not allocate an skb of length %d\n", 64);
+ skb = dev_alloc_skb(128);
+ if (!skb)
return;
- }
/* Reserve space for TTP, LMP, and LAP header */
- skb_reserve( skb, TTP_HEADER+LMP_HEADER+LAP_HEADER);
- skb_put( skb, 2);
+ skb_reserve(skb, TTP_HEADER+LMP_HEADER+LAP_HEADER);
+ skb_put(skb, 2);
frame = skb->data;
frame[0] = CMD_FILTER_OPERATION;
frame[1] = 0x03; /* Three parameters */
- insert_byte_param( skb, "DATA_CHAN" , self->dtsap_sel_data);
- insert_string_param( skb, "FILTER_TYPE", "DIRECTED");
- insert_string_param( skb, "FILTER_MODE", "FILTER");
+ irlan_insert_byte_param(skb, "DATA_CHAN" , self->dtsap_sel_data);
+ irlan_insert_string_param(skb, "FILTER_TYPE", "DIRECTED");
+ irlan_insert_string_param(skb, "FILTER_MODE", "FILTER");
- irttp_data_request( self->tsap_ctrl, skb);
+ irttp_data_request(self->client.tsap_ctrl, skb);
}
/*
* Function irlan_set_broadcast_filter (self, status)
*
* Make IrLAN provider accept ethernet frames addressed to the broadcast
- * address. Be careful with the use of this one, sice there may be a lot
+ * address. Be careful with the use of this one, since there may be a lot
* of broadcast traffic out there. We can still function without this
* one but then _we_ have to initiate all communication with other
- * hosts, sice ARP request for this host will not be answered.
+ * hosts, since ARP request for this host will not be answered.
*/
-void irlan_set_broadcast_filter( struct irlan_cb *self, int status)
+void irlan_set_broadcast_filter(struct irlan_cb *self, int status)
{
struct sk_buff *skb;
__u8 *frame;
- DEBUG( 4, __FUNCTION__ "()\n");
+ DEBUG(2, __FUNCTION__ "()\n");
- ASSERT( self != NULL, return;);
- ASSERT( self->magic == IRLAN_MAGIC, return;);
+ ASSERT(self != NULL, return;);
+ ASSERT(self->magic == IRLAN_MAGIC, return;);
- /* Should only be used by client */
- if (!self->client)
+ skb = dev_alloc_skb(128);
+ if (!skb)
return;
- skb = dev_alloc_skb( 128);
- if (skb == NULL) {
- DEBUG( 0, __FUNCTION__
- "(), Could not allocate an skb of length %d\n", 64);
- return;
- }
-
/* Reserve space for TTP, LMP, and LAP header */
- skb_reserve( skb, TTP_HEADER+LMP_HEADER+LAP_HEADER);
- skb_put( skb, 2);
+ skb_reserve(skb, TTP_HEADER+LMP_HEADER+LAP_HEADER);
+ skb_put(skb, 2);
frame = skb->data;
frame[0] = CMD_FILTER_OPERATION;
frame[1] = 0x03; /* Three parameters */
- insert_byte_param( skb, "DATA_CHAN", self->dtsap_sel_data);
- insert_string_param( skb, "FILTER_TYPE", "BROADCAST");
- if ( status)
- insert_string_param( skb, "FILTER_MODE", "FILTER");
+ irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data);
+ irlan_insert_string_param(skb, "FILTER_TYPE", "BROADCAST");
+ if (status)
+ irlan_insert_string_param(skb, "FILTER_MODE", "FILTER");
else
- insert_string_param( skb, "FILTER_MODE", "NONE");
+ irlan_insert_string_param(skb, "FILTER_MODE", "NONE");
- irttp_data_request( self->tsap_ctrl, skb);
+ irttp_data_request(self->client.tsap_ctrl, skb);
}
/*
@@ -367,43 +881,36 @@
* address.
*
*/
-void irlan_set_multicast_filter( struct irlan_cb *self, int status)
+void irlan_set_multicast_filter(struct irlan_cb *self, int status)
{
struct sk_buff *skb;
__u8 *frame;
- DEBUG( 4, __FUNCTION__ "()\n");
+ DEBUG(2, __FUNCTION__ "()\n");
- ASSERT( self != NULL, return;);
- ASSERT( self->magic == IRLAN_MAGIC, return;);
+ ASSERT(self != NULL, return;);
+ ASSERT(self->magic == IRLAN_MAGIC, return;);
- /* Should only be used by client */
- if (!self->client)
+ skb = dev_alloc_skb(128);
+ if (!skb)
return;
- skb = dev_alloc_skb( 128);
- if (skb == NULL) {
- DEBUG( 0, __FUNCTION__
- "(), Could not allocate an skb of length %d\n", 64);
- return;
- }
-
/* Reserve space for TTP, LMP, and LAP header */
- skb_reserve( skb, TTP_HEADER+LMP_HEADER+LAP_HEADER);
- skb_put( skb, 2);
+ skb_reserve(skb, TTP_HEADER+LMP_HEADER+LAP_HEADER);
+ skb_put(skb, 2);
frame = skb->data;
frame[0] = CMD_FILTER_OPERATION;
frame[1] = 0x03; /* Three parameters */
- insert_byte_param( skb, "DATA_CHAN", self->dtsap_sel_data);
- insert_string_param( skb, "FILTER_TYPE", "MULTICAST");
- if ( status)
- insert_string_param( skb, "FILTER_MODE", "ALL");
+ irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data);
+ irlan_insert_string_param(skb, "FILTER_TYPE", "MULTICAST");
+ if (status)
+ irlan_insert_string_param(skb, "FILTER_MODE", "ALL");
else
- insert_string_param( skb, "FILTER_MODE", "NONE");
+ irlan_insert_string_param(skb, "FILTER_MODE", "NONE");
- irttp_data_request( self->tsap_ctrl, skb);
+ irttp_data_request(self->client.tsap_ctrl, skb);
}
/*
@@ -414,36 +921,33 @@
* can construct its packets.
*
*/
-void irlan_get_unicast_addr( struct irlan_cb *self)
+void irlan_get_unicast_addr(struct irlan_cb *self)
{
struct sk_buff *skb;
__u8 *frame;
- DEBUG( 4, __FUNCTION__ "()\n");
+ DEBUG(2, __FUNCTION__ "()\n");
- ASSERT( self != NULL, return;);
- ASSERT( self->magic == IRLAN_MAGIC, return;);
+ ASSERT(self != NULL, return;);
+ ASSERT(self->magic == IRLAN_MAGIC, return;);
- skb = dev_alloc_skb( 128);
- if (skb == NULL) {
- DEBUG( 0, "irlan_client_get_unicast_addr: "
- "Could not allocate an sk_buff of length %d\n", 64);
+ skb = dev_alloc_skb(128);
+ if (!skb)
return;
- }
/* Reserve space for TTP, LMP, and LAP header */
- skb_reserve( skb, TTP_HEADER+LMP_HEADER+LAP_HEADER);
- skb_put( skb, 2);
+ skb_reserve(skb, TTP_HEADER+LMP_HEADER+LAP_HEADER);
+ skb_put(skb, 2);
frame = skb->data;
frame[0] = CMD_FILTER_OPERATION;
frame[1] = 0x03; /* Three parameters */
- insert_byte_param( skb, "DATA_CHAN", self->dtsap_sel_data);
- insert_string_param( skb, "FILTER_TYPE", "DIRECTED");
- insert_string_param( skb, "FILTER_OPERATION", "DYNAMIC");
+ irlan_insert_byte_param(skb, "DATA_CHAN", self->dtsap_sel_data);
+ irlan_insert_string_param(skb, "FILTER_TYPE", "DIRECTED");
+ irlan_insert_string_param(skb, "FILTER_OPERATION", "DYNAMIC");
- irttp_data_request( self->tsap_ctrl, skb);
+ irttp_data_request(self->client.tsap_ctrl, skb);
}
/*
@@ -452,26 +956,23 @@
*
*
*/
-void irlan_get_media_char( struct irlan_cb *self)
+void irlan_get_media_char(struct irlan_cb *self)
{
struct sk_buff *skb;
__u8 *frame;
- DEBUG( 4, __FUNCTION__ "()\n");
+ DEBUG(4, __FUNCTION__ "()\n");
- ASSERT( self != NULL, return;);
- ASSERT( self->magic == IRLAN_MAGIC, return;);
+ ASSERT(self != NULL, return;);
+ ASSERT(self->magic == IRLAN_MAGIC, return;);
- skb = dev_alloc_skb( 64);
- if (skb == NULL) {
- DEBUG( 0,"irlan_server_get_media_char: "
- "Could not allocate an sk_buff of length %d\n", 64);
+ skb = dev_alloc_skb(64);
+ if (!skb)
return;
- }
/* Reserve space for TTP, LMP, and LAP header */
- skb_reserve( skb, TTP_HEADER+LMP_HEADER+LAP_HEADER);
- skb_put( skb, 2);
+ skb_reserve(skb, TTP_HEADER+LMP_HEADER+LAP_HEADER);
+ skb_put(skb, 2);
frame = skb->data;
@@ -479,9 +980,9 @@
frame[0] = CMD_GET_MEDIA_CHAR;
frame[1] = 0x01; /* One parameter */
- insert_string_param( skb, "MEDIA", "802.3");
+ irlan_insert_string_param(skb, "MEDIA", "802.3");
- irttp_data_request( self->tsap_ctrl, skb);
+ irttp_data_request(self->client.tsap_ctrl, skb);
}
/*
@@ -490,47 +991,14 @@
* Insert byte parameter into frame
*
*/
-int insert_byte_param( struct sk_buff *skb, char *param, __u8 value)
+int irlan_insert_byte_param(struct sk_buff *skb, char *param, __u8 value)
{
- __u8 *frame;
- __u8 len_param;
- __u16 len_value;
- int n=0;
-
- if ( skb == NULL) {
- DEBUG( 0, "insert_param: Got NULL skb\n");
- return 0;
- }
-
- len_param = strlen( param);
- len_value = 1;
-
- /*
- * Insert at end of sk-buffer
- */
- frame = skb->tail;
-
- /* Make space for data */
- if ( skb_tailroom(skb) < (len_param+len_value+3)) {
- DEBUG( 0, "insert_param: No more space at end of skb\n");
- return 0;
- }
- skb_put( skb, len_param+len_value+3);
-
- /* Insert parameter length */
- frame[n++] = len_param;
-
- /* Insert parameter */
- memcpy( frame+n, param, len_param);
- n += len_param;
-
- /* Insert value length ( 2 byte little endian format, LSB first) */
- frame[n++] = len_value & 0xff;
- frame[n++] = len_value >> 8;
+ return __irlan_insert_param(skb, param, IRLAN_BYTE, value, 0, NULL, 0);
+}
- frame[n++] = value;
-
- return len_param+len_value+3;
+int irlan_insert_short_param(struct sk_buff *skb, char *param, __u16 value)
+{
+ return __irlan_insert_param(skb, param, IRLAN_SHORT, 0, value, NULL, 0);
}
/*
@@ -539,96 +1007,25 @@
* Insert string parameter into frame
*
*/
-int insert_string_param( struct sk_buff *skb, char *param, char *value)
+int irlan_insert_string_param(struct sk_buff *skb, char *param, char *string)
{
- __u8 *frame;
- __u8 len_param;
- __u16 len_value;
- int n=0;
-
- if ( skb == NULL) {
- DEBUG( 0, "insert_param: Got NULL skb\n");
- return 0;
- }
- len_param = strlen( param);
- len_value = strlen( value);
+ int string_len = strlen(string);
- /*
- * Insert at end of sk-buffer
- */
- frame = skb->tail;
-
- /* Make space for data */
- if ( skb_tailroom(skb) < (len_param+len_value+3)) {
- DEBUG( 0, "insert_param: No more space at end of skb\n");
- return 0;
- }
- skb_put( skb, len_param+len_value+3);
-
- /* Insert parameter length */
- frame[n++] = len_param;
-
- /* Insert parameter */
- memcpy( frame+n, param, len_param);
- n += len_param;
-
- /* Insert value length ( 2 byte little endian format, LSB first) */
- frame[n++] = len_value & 0xff;
- frame[n++] = len_value >> 8;
-
- memcpy( frame+n, value, len_value);
- n+=len_value;
-
- return len_param+len_value+3;
+ return __irlan_insert_param(skb, param, IRLAN_ARRAY, 0, 0, string,
+ string_len);
}
/*
- * Function insert_array_param( skb, param, value, len_value)
+ * Function insert_array_param(skb, param, value, len_value)
*
* Insert array parameter into frame
*
*/
-int insert_array_param( struct sk_buff *skb, char *name, __u8 *value,
- __u16 value_len)
+int irlan_insert_array_param(struct sk_buff *skb, char *name, __u8 *array,
+ __u16 array_len)
{
- __u8 *frame;
- __u8 name_len;
- int n=0;
-
- if ( skb == NULL) {
- DEBUG( 0, __FUNCTION__ "(), Got NULL skb\n");
- return 0;
- }
- name_len = strlen( name);
-
- /*
- * Insert at end of sk-buffer
- */
- frame = skb->tail;
-
- /* Make space for data */
- if ( skb_tailroom(skb) < (name_len+value_len+3)) {
- DEBUG( 0, __FUNCTION__ "(), No more space at end of skb\n");
- return 0;
- }
- skb_put( skb, name_len+value_len+3);
-
- /* Insert parameter length */
- frame[n++] = name_len;
-
- /* Insert parameter */
- memcpy( frame+n, name, name_len);
- n += name_len;
-
- /* Insert value length ( 2 byte little endian format, LSB first) */
- /* FIXME: should we use htons() here? */
- frame[n++] = value_len & 0xff;
- frame[n++] = value_len >> 8;
-
- memcpy( frame+n, value, value_len);
- n+=value_len;
-
- return name_len+value_len+3;
+ return __irlan_insert_param(skb, name, IRLAN_ARRAY, 0, 0, array,
+ array_len);
}
/*
@@ -640,130 +1037,121 @@
* | Name Length[1] | Param Name[1..255] | Val Length[2] | Value[0..1016]|
* -----------------------------------------------------------------------
*/
-int insert_param( struct sk_buff *skb, char *param, int type, char *value_char,
- __u8 value_byte, __u16 value_short)
+static int __irlan_insert_param(struct sk_buff *skb, char *param, int type,
+ __u8 value_byte, __u16 value_short,
+ __u8 *value_array, __u16 value_len)
{
__u8 *frame;
- __u8 len_param;
- __u16 len_value;
- int n;
+ __u8 param_len;
+ int n=0;
- if ( skb == NULL) {
- DEBUG( 0, "insert_param: Got NULL skb\n");
+ if (skb == NULL) {
+ DEBUG(2, __FUNCTION__ "(), Got NULL skb\n");
return 0;
- }
-
- n = 0;
+ }
- len_param = strlen( param);
- switch ( type) {
- case 1:
- ASSERT( value_char != NULL, return 0;);
- len_value = strlen( value_char);
+ param_len = strlen(param);
+ switch (type) {
+ case IRLAN_BYTE:
+ value_len = 1;
break;
- case 2:
- len_value = 1;
+ case IRLAN_SHORT:
+ value_len = 2;
break;
- case 3:
- len_value = 2;
+ case IRLAN_ARRAY:
+ ASSERT(value_array != NULL, return 0;);
+ ASSERT(value_len > 0, return 0;);
break;
default:
- DEBUG( 0, "Error in insert_param!\n");
+ DEBUG(2, __FUNCTION__ "(), Unknown parameter type!\n");
return 0;
break;
}
- /*
- * Insert at end of sk-buffer
- */
+ /* Insert at end of sk-buffer */
frame = skb->tail;
/* Make space for data */
- if ( skb_tailroom(skb) < (len_param+len_value+3)) {
- DEBUG( 0, "insert_param: No more space at end of skb\n");
+ if (skb_tailroom(skb) < (param_len+value_len+3)) {
+ DEBUG(2, __FUNCTION__ "(), No more space at end of skb\n");
return 0;
}
- skb_put( skb, len_param+len_value+3);
-
+ skb_put(skb, param_len+value_len+3);
+
/* Insert parameter length */
- frame[n++] = len_param;
+ frame[n++] = param_len;
/* Insert parameter */
- memcpy( frame+n, param, len_param); n += len_param;
+ memcpy(frame+n, param, param_len); n += param_len;
- /* Insert value length ( 2 byte little endian format, LSB first) */
- frame[n++] = len_value & 0xff;
- frame[n++] = len_value >> 8;
+ /* Insert value length (2 byte little endian format, LSB first) */
+ *((__u16 *) (frame+n)) = cpu_to_le16(value_len); n += 2;
/* Insert value */
switch (type) {
- case 1:
- memcpy( frame+n, value_char, len_value); n+=len_value;
- break;
- case 2:
+ case IRLAN_BYTE:
frame[n++] = value_byte;
break;
- case 3:
- frame[n++] = value_short & 0xff;
- frame[n++] = (value_short >> 8) & 0xff;
+ case IRLAN_SHORT:
+ *((__u16 *) (frame+n)) = cpu_to_le16(value_short); n += 2;
+ break;
+ case IRLAN_ARRAY:
+ memcpy(frame+n, value_array, value_len); n+=value_len;
break;
default:
break;
}
- ASSERT( n == (len_param+len_value+3), return 0;);
+ ASSERT(n == (param_len+value_len+3), return 0;);
- return len_param+len_value+3;
+ return param_len+value_len+3;
}
/*
* Function irlan_get_response_param (buf, param, value)
*
* Extracts a single parameter name/value pair from buffer and updates
- * the buffer pointer to point to the next name/value pair.
- *
+ * the buffer pointer to point to the next name/value pair.
*/
-int irlan_get_response_param( __u8 *buf, char *name, char *value, int *len)
+int irlan_get_param(__u8 *buf, char *name, char *value, __u16 *len)
{
__u8 name_len;
__u16 val_len;
int n=0;
-
- DEBUG( 4, "irlan_get_response_param()\n");
- /* get length of parameter name ( 1 byte) */
+ DEBUG(4, __FUNCTION__ "()\n");
+
+ /* get length of parameter name (1 byte) */
name_len = buf[n++];
if (name_len > 254) {
- DEBUG( 0, __FUNCTION__ "(), name_len > 254\n");
- return -1;
+ DEBUG(2, __FUNCTION__ "(), name_len > 254\n");
+ return -RSP_INVALID_COMMAND_FORMAT;
}
/* get parameter name */
- memcpy( name, buf+n, name_len);
+ memcpy(name, buf+n, name_len);
name[ name_len] = '\0';
n+=name_len;
/*
- * Get length of parameter value ( 2 bytes in little endian
+ * Get length of parameter value (2 bytes in little endian
* format)
*/
- val_len = buf[n++] & 0xff;
- val_len |= buf[n++] << 8;
+ val_len = le16_to_cpup(buf+n); n+=2;
if (val_len > 1016) {
- DEBUG( 0, __FUNCTION__ "(), parameter length to long\n");
- return -1;
+ DEBUG(2, __FUNCTION__ "(), parameter length to long\n");
+ return -RSP_INVALID_COMMAND_FORMAT;
}
-
*len = val_len;
/* get parameter value */
- memcpy( value, buf+n, val_len);
+ memcpy(value, buf+n, val_len);
value[ val_len] = '\0';
n+=val_len;
- DEBUG( 4, "Parameter: %s ", name);
- DEBUG( 4, "Value: %s\n", value);
+ DEBUG(4, "Parameter: %s ", name);
+ DEBUG(4, "Value: %s\n", value);
return n;
}
@@ -774,37 +1162,55 @@
*
* Give some info to the /proc file system
*/
-static int irlan_proc_read( char *buf, char **start, off_t offset,
- int len, int unused)
+static int irlan_proc_read(char *buf, char **start, off_t offset, int len,
+ int unused)
{
struct irlan_cb *self;
-
- ASSERT( irlan != NULL, return 0;);
+ unsigned long flags;
+
+ save_flags(flags);
+ cli();
+
+ ASSERT(irlan != NULL, return 0;);
len = 0;
- len += sprintf( buf+len, "IrLAN\n");
-
- self = ( struct irlan_cb *) hashbin_get_first( irlan);
- while ( self != NULL) {
- ASSERT( self->magic == IRLAN_MAGIC, return len;);
-
- len += sprintf( buf+len, "ifname: %s, ",
- self->ifname);
- /* len += sprintf( buf+len, "state: %s, ", */
-/* irlan_client_state[ self->state]); */
- len += sprintf( buf+len, "saddr: %#08x\n",
- self->saddr);
- len += sprintf( buf+len, "daddr: %#08x\n",
- self->daddr);
- len += sprintf( buf+len, "tbusy: %s\n", self->dev.tbusy ?
- "TRUE" : "FALSE");
+ len += sprintf(buf+len, "IrLAN instances:\n");
+
+ self = (struct irlan_cb *) hashbin_get_first(irlan);
+ while (self != NULL) {
+ ASSERT(self->magic == IRLAN_MAGIC, return len;);
- len += sprintf( buf+len, "\n");
+ len += sprintf(buf+len, "ifname: %s,\n",
+ self->ifname);
+ len += sprintf(buf+len, "client state: %s, ",
+ irlan_state[ self->client.state]);
+ len += sprintf(buf+len, "provider state: %s,\n",
+ irlan_state[ self->provider.state]);
+ len += sprintf(buf+len, "saddr: %#08x, ",
+ self->saddr);
+ len += sprintf(buf+len, "daddr: %#08x\n",
+ self->daddr);
+ len += sprintf(buf+len, "version: %d.%d,\n",
+ self->version[1], self->version[0]);
+ len += sprintf(buf+len, "access type: %s\n",
+ irlan_access[ self->access_type]);
+ len += sprintf(buf+len, "media: %s\n",
+ irlan_media[ self->media]);
+
+ len += sprintf(buf+len, "local filter:\n");
+ len += sprintf(buf+len, "remote filter: ");
+ len += irlan_print_filter(self->client.filter_type, buf+len);
+
+ len += sprintf(buf+len, "tx busy: %s\n", self->dev.tbusy ?
+ "TRUE" : "FALSE");
- self = ( struct irlan_cb *) hashbin_get_next( irlan);
- DEBUG( 4, "self=%p\n", self);
+ len += sprintf(buf+len, "\n");
+
+ self = (struct irlan_cb *) hashbin_get_next(irlan);
}
+ restore_flags(flags);
+
return len;
}
#endif
@@ -815,41 +1221,41 @@
* Print return code of request to peer IrLAN layer.
*
*/
-void print_ret_code( __u8 code)
+void print_ret_code(__u8 code)
{
- switch( code) {
+ switch(code) {
case 0:
- printk( KERN_INFO "Success\n");
+ printk(KERN_INFO "Success\n");
break;
case 1:
- printk( KERN_WARNING "Insufficient resources\n");
+ printk(KERN_WARNING "Insufficient resources\n");
break;
case 2:
- printk( KERN_WARNING "Invalid command format\n");
+ printk(KERN_WARNING "Invalid command format\n");
break;
case 3:
- printk( KERN_WARNING "Command not supported\n");
+ printk(KERN_WARNING "Command not supported\n");
break;
case 4:
- printk( KERN_WARNING "Parameter not supported\n");
+ printk(KERN_WARNING "Parameter not supported\n");
break;
case 5:
- printk( KERN_WARNING "Value not supported\n");
+ printk(KERN_WARNING "Value not supported\n");
break;
case 6:
- printk( KERN_WARNING "Not open\n");
+ printk(KERN_WARNING "Not open\n");
break;
case 7:
- printk( KERN_WARNING "Authentication required\n");
+ printk(KERN_WARNING "Authentication required\n");
break;
case 8:
- printk( KERN_WARNING "Invalid password\n");
+ printk(KERN_WARNING "Invalid password\n");
break;
case 9:
- printk( KERN_WARNING "Protocol error\n");
+ printk(KERN_WARNING "Protocol error\n");
break;
case 255:
- printk( KERN_WARNING "Asynchronous status\n");
+ printk(KERN_WARNING "Asynchronous status\n");
break;
}
}
@@ -859,6 +1265,10 @@
MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>");
MODULE_DESCRIPTION("The Linux IrDA LAN protocol");
+MODULE_PARM(eth, "i");
+MODULE_PARM(access, "i");
+MODULE_PARM(timeout, "i");
+
/*
* Function init_module (void)
*
@@ -867,8 +1277,6 @@
*/
int init_module(void)
{
- DEBUG( 4, __FUNCTION__ "(), irlan.c\n");
-
irlan_init();
return 0;
@@ -882,15 +1290,9 @@
*/
void cleanup_module(void)
{
- DEBUG( 4, "--> irlan, cleanup_module\n");
- /* No need to check MOD_IN_USE, as sys_delete_module() checks. */
-
/* Free some memory */
irlan_cleanup();
-
- DEBUG( 4, "irlan, cleanup_module -->\n");
}
#endif /* MODULE */
-
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)