diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1999-06-13 16:29:25 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 1999-06-13 16:29:25 +0000 |
commit | db7d4daea91e105e3859cf461d7e53b9b77454b2 (patch) | |
tree | 9bb65b95440af09e8aca63abe56970dd3360cc57 /net/irda/irlpt/irlpt_srvr.c | |
parent | 9c1c01ead627bdda9211c9abd5b758d6c687d8ac (diff) |
Merge with Linux 2.2.8.
Diffstat (limited to 'net/irda/irlpt/irlpt_srvr.c')
-rw-r--r-- | net/irda/irlpt/irlpt_srvr.c | 202 |
1 files changed, 83 insertions, 119 deletions
diff --git a/net/irda/irlpt/irlpt_srvr.c b/net/irda/irlpt/irlpt_srvr.c index b7d6f1bb9..a1362d0dc 100644 --- a/net/irda/irlpt/irlpt_srvr.c +++ b/net/irda/irlpt/irlpt_srvr.c @@ -48,24 +48,24 @@ static int irlpt_server_proc_read(char *buf, char **start, off_t offset, #endif /* CONFIG_PROC_FS */ int irlpt_server_init(void); -static void irlpt_server_cleanup(void); -static void irlpt_server_disconnect_indication( void *instance, void *sap, +static void irlpt_server_disconnect_indication(void *instance, void *sap, LM_REASON reason, struct sk_buff *skb); -static void irlpt_server_connect_confirm( void *instance, void *sap, - struct qos_info *qos, - int max_seg_size, - struct sk_buff *skb); -static void irlpt_server_connect_indication( void *instance, void *sap, - struct qos_info *qos, - int max_seg_size, - struct sk_buff *skb); -static void irlpt_server_data_indication( void *instance, void *sap, - struct sk_buff *skb); +static void irlpt_server_connect_confirm(void *instance, void *sap, + struct qos_info *qos, + __u32 max_seg_size, + struct sk_buff *skb); +static void irlpt_server_connect_indication(void *instance, + void *sap, + struct qos_info *qos, + __u32 max_seg_size, + struct sk_buff *skb); +static int irlpt_server_data_indication(void *instance, void *sap, + struct sk_buff *skb); static void register_irlpt_server(void); static void deregister_irlpt_server(void); -static struct wait_queue *irlpt_server_wait; +static __u32 skey; /* IrLMP service handle */ int irlpt_server_lsap = LSAP_IRLPT; int irlpt_server_debug = 4; @@ -73,7 +73,8 @@ int irlpt_server_debug = 4; #if 0 static char *rcsid = "$Id: irlpt_server.c,v 1.9 1998/10/22 12:02:22 dagb Exp $"; #endif -static char *version = "IrLPT server, $Revision: 1.9 $/$Date: 1998/10/22 12:02:22 $ (Thomas Davis)"; + +static char *version = "IrLPT server, v2 (Thomas Davis)"; struct file_operations irlpt_fops = { irlpt_seek, /* seek */ @@ -96,7 +97,7 @@ struct file_operations irlpt_fops = { #ifdef CONFIG_PROC_FS /* - * Function proc_irlpt_read (buf, start, offset, len, unused) + * Function irlpt_server_proc_read (buf, start, offset, len, unused) * * * @@ -137,21 +138,19 @@ static int irlpt_server_proc_read(char *buf, char **start, off_t offset, break; } - len += sprintf(buf+len, "servicetype: %s\n", - irlpt_service_type[index]); - len += sprintf(buf+len, "porttype: %s\n", + len += sprintf(buf+len, "servicetype: %s, porttype: %s\n", + irlpt_service_type[index], irlpt_port_type[irlpt_server->porttype]); - len += sprintf(buf+len, "daddr: %d\n", - irlpt_server->daddr); - len += sprintf(buf+len, "state: %s\n", - irlpt_server_fsm_state[irlpt_server->state]); - len += sprintf(buf+len, "retries: %d\n", - irlpt_server->open_retries); - len += sprintf(buf+len, "peersap: %d\n", + len += sprintf(buf+len, "saddr: 0x%08x, daddr: 0x%08x\n", + irlpt_server->saddr, irlpt_server->daddr); + len += sprintf(buf+len, "slsap: 0x%08x, dlsap: 0x%08x\n", + irlpt_server->slsap_sel, irlpt_server->dlsap_sel); - len += sprintf(buf+len, "count: %d\n", + len += sprintf(buf+len, "retries: %d, count: %d\n", + irlpt_server->open_retries, irlpt_server->count); - len += sprintf(buf+len, "rx_queue: %d\n", + len += sprintf(buf+len, "fsm state: %s, rx queue depth: %d\n", + irlpt_server_fsm_state[irlpt_server->state], skb_queue_len(&irlpt_server->rx_queue)); len += sprintf(buf+len, "\n"); } @@ -161,14 +160,7 @@ static int irlpt_server_proc_read(char *buf, char **start, off_t offset, return len; } -extern struct proc_dir_entry proc_irda; - -struct proc_dir_entry proc_irlpt_server = { - 0, 12, "irlpt_server", - S_IFREG | S_IRUGO, 1, 0, 0, - 0, NULL /* ops -- default to array */, - &irlpt_server_proc_read /* get_info */, -}; +extern struct proc_dir_entry *proc_irda; #endif /* CONFIG_PROC_FS */ @@ -182,6 +174,8 @@ struct proc_dir_entry proc_irlpt_server = { /*int irlpt_init( struct device *dev) {*/ __initfunc(int irlpt_server_init(void)) { + __u16 hints; + DEBUG( irlpt_server_debug, "--> " __FUNCTION__ "\n"); printk( KERN_INFO "%s\n", version); @@ -194,7 +188,6 @@ __initfunc(int irlpt_server_init(void)) " irlpt_server control block!\n"); return -ENOMEM; } - memset( irlpt_server, 0, sizeof(struct irlpt_cb)); sprintf(irlpt_server->ifname, "irlpt_server"); @@ -209,12 +202,14 @@ __initfunc(int irlpt_server_init(void)) skb_queue_head_init(&irlpt_server->rx_queue); - irlmp_register_layer( S_PRINTER, SERVER, FALSE, NULL); + hints = irlmp_service_to_hint(S_PRINTER); + skey = irlmp_register_service(hints); register_irlpt_server(); #ifdef CONFIG_PROC_FS - proc_register( &proc_irda, &proc_irlpt_server); + create_proc_entry("irlpt_server", 0, proc_irda)->get_info + = irlpt_server_proc_read; #endif /* CONFIG_PROC_FS */ DEBUG( irlpt_server_debug, __FUNCTION__ " -->\n"); @@ -234,12 +229,11 @@ static void irlpt_server_cleanup(void) DEBUG( irlpt_server_debug, "--> " __FUNCTION__ "\n"); + irlmp_unregister_service(skey); deregister_irlpt_server(); while (( skb = skb_dequeue(&irlpt_server->rx_queue)) != NULL) { DEBUG(irlpt_server_debug, __FUNCTION__ ": freeing SKB\n"); - IS_SKB( skb, return;); - FREE_SKB_MAGIC( skb); dev_kfree_skb( skb); } @@ -248,7 +242,7 @@ static void irlpt_server_cleanup(void) kfree(irlpt_server); #ifdef CONFIG_PROC_FS - proc_unregister( &proc_irda, proc_irlpt_server.low_ino); + remove_proc_entry("irlpt_server", proc_irda); #endif DEBUG( irlpt_server_debug, __FUNCTION__ " -->\n"); @@ -258,11 +252,14 @@ static void irlpt_server_cleanup(void) * Function irlpt_disconnect_indication (handle) * */ -static void irlpt_server_disconnect_indication( void *instance, void *sap, +static void irlpt_server_disconnect_indication( void *instance, + void *sap, LM_REASON reason, struct sk_buff *userdata) { +#if 0 struct irlpt_info info; +#endif struct irlpt_cb *self; DEBUG( irlpt_server_debug, "--> " __FUNCTION__ "\n"); @@ -272,17 +269,22 @@ static void irlpt_server_disconnect_indication( void *instance, void *sap, ASSERT( self != NULL, return;); ASSERT( self->magic == IRLPT_MAGIC, return;); +#if 0 info.daddr = self->daddr; +#endif - DEBUG( irlpt_server_debug, __FUNCTION__ ": reason=%d (%s), dlsap_sel=%d\n", + DEBUG( irlpt_server_debug, + __FUNCTION__ ": reason=%d (%s), dlsap_sel=%d\n", reason, irlpt_reasons[reason], self->dlsap_sel); self->connected = IRLPT_DISCONNECTED; self->eof = reason; - wake_up_interruptible(&irlpt_server_wait); + wake_up_interruptible(&self->read_wait); + wake_up_interruptible(&self->write_wait); + wake_up_interruptible(&self->ex_wait); - DEBUG( irlpt_server_debug, __FUNCTION__ ": skb_queue_len=%d\n", + DEBUG( irlpt_server_debug, __FUNCTION__ ": rx queue length: %d\n", skb_queue_len(&irlpt_server->rx_queue)); irlpt_server_do_event( self, LMP_DISCONNECT, NULL, NULL); @@ -298,12 +300,12 @@ static void irlpt_server_disconnect_indication( void *instance, void *sap, * * LSAP connection confirmed! */ -static void irlpt_server_connect_confirm( void *instance, void *sap, - struct qos_info *qos, - int max_seg_size, - struct sk_buff *skb) +static void irlpt_server_connect_confirm(void *instance, + void *sap, + struct qos_info *qos, + __u32 max_seg_size, + struct sk_buff *skb) { - struct irlpt_info info; struct irlpt_cb *self; DEBUG( irlpt_server_debug, "--> " __FUNCTION__ "\n"); @@ -312,21 +314,6 @@ static void irlpt_server_connect_confirm( void *instance, void *sap, ASSERT( self != NULL, return;); ASSERT( self->magic == IRLPT_MAGIC, return;); - info.daddr = self->daddr; - - /* - * Check if we have got some QoS parameters back! This should be the - * negotiated QoS for the link. - */ - if ( qos) { - DEBUG( irlpt_server_debug, __FUNCTION__ - ": IrLPT Negotiated BAUD_RATE: %02x\n", - qos->baud_rate.bits); - DEBUG( irlpt_server_debug, __FUNCTION__ - ": IrLPT Negotiated BAUD_RATE: %d bps.\n", - qos->baud_rate.value); - } - self->connected = TRUE; irlpt_server_do_event( self, LMP_CONNECT, NULL, NULL); @@ -338,19 +325,20 @@ static void irlpt_server_connect_confirm( void *instance, void *sap, * Function irlpt_connect_indication (handle) * */ -static void irlpt_server_connect_indication( void *instance, void *sap, - struct qos_info *qos, - int max_seg_size, - struct sk_buff *skb) +static void irlpt_server_connect_indication(void *instance, + void *sap, + struct qos_info *qos, + __u32 max_seg_size, + struct sk_buff *skb) { struct irlpt_cb *self; struct irlpt_info info; - struct lsap_cb *lsap; DEBUG( irlpt_server_debug, "--> " __FUNCTION__ "\n"); self = ( struct irlpt_cb *) instance; - lsap = (struct lsap_cb *) sap; + + info.lsap = (struct lsap_cb *) sap; ASSERT( self != NULL, return;); ASSERT( self->magic == IRLPT_MAGIC, return;); @@ -358,8 +346,6 @@ static void irlpt_server_connect_indication( void *instance, void *sap, self->connected = IRLPT_CONNECTED; self->eof = FALSE; - info.lsap = lsap; - irlpt_server_do_event( self, LMP_CONNECT, NULL, &info); if (skb) { @@ -370,25 +356,24 @@ static void irlpt_server_connect_indication( void *instance, void *sap, } /* - * Function irlpt_data_indication (handle, skb) + * Function irlpt_server_data_indication (handle, skb) * * This function gets the data that is received on the data channel * */ -static void irlpt_server_data_indication( void *instance, void *sap, - struct sk_buff *skb) +static int irlpt_server_data_indication(void *instance, void *sap, + struct sk_buff *skb) { - struct irlpt_cb *self; DEBUG( irlpt_server_debug, "--> " __FUNCTION__ "\n"); self = ( struct irlpt_cb *) instance; - ASSERT( self != NULL, return;); - ASSERT( self->magic == IRLPT_MAGIC, return;); + ASSERT( self != NULL, return -1;); + ASSERT( self->magic == IRLPT_MAGIC, return -1;); - ASSERT( skb != NULL, return;); + ASSERT( skb != NULL, return -1;); DEBUG( irlpt_server_debug, __FUNCTION__ ": len=%d\n", (int) skb->len); @@ -397,9 +382,11 @@ static void irlpt_server_data_indication( void *instance, void *sap, #endif skb_queue_tail(&self->rx_queue, skb); - wake_up_interruptible(&irlpt_server_wait); + wake_up_interruptible(&self->read_wait); DEBUG( irlpt_server_debug, __FUNCTION__ " -->\n"); + + return 0; } /* @@ -419,9 +406,8 @@ static void register_irlpt_server(void) /* * First register control TSAP */ - if ( !irlpt_server || irlpt_server->magic != IRLPT_MAGIC) { - DEBUG( 0, "irlpt_register_server:, unable to obtain handle!\n"); + DEBUG( 0, __FUNCTION__ ": unable to obtain handle!\n"); return; } @@ -432,12 +418,13 @@ static void register_irlpt_server(void) notify.disconnect_indication = irlpt_server_disconnect_indication; notify.data_indication = irlpt_server_data_indication; notify.instance = irlpt_server; - strcpy(notify.name, "IrLPT"); + strcpy(notify.name, "IrLPT server"); irlpt_server->lsap = irlmp_open_lsap( irlpt_server_lsap, ¬ify); irlpt_server->connected = IRLPT_WAITING; irlpt_server->service_LSAP = irlpt_server_lsap; + irlpt_server->slsap_sel = irlpt_server_lsap; /* * Register with LM-IAS @@ -461,35 +448,9 @@ static void register_irlpt_server(void) */ static void deregister_irlpt_server(void) { -#if 0 - struct notify_t notify; -#endif DEBUG( irlpt_server_debug, "--> " __FUNCTION__ "\n"); -#if 0 - /* - * First register control TSAP - */ - - if ( !irlpt_server || irlpt_server->magic != IRLPT_MAGIC) { - DEBUG( 0, "irlpt_register_server:, unable to obtain handle!\n"); - return; - } - - irda_notify_init(¬ify); - - notify.connect_confirm = irlpt_server_connect_confirm; - notify.connect_indication = irlpt_server_connect_indication; - notify.disconnect_indication = irlpt_server_disconnect_indication; - notify.data_indication = irlpt_server_data_indication; - notify.instance = irlpt_server; - strcpy(notify.name, "IrLPT"); - - irlpt_server->lsap = irlmp_open_lsap( irlpt_server_lsap, ¬ify); - - irlpt_server->connected = IRLPT_WAITING; - irlpt_server->service_LSAP = irlpt_server_lsap; -#endif + irlpt_server->connected = IRLPT_DISCONNECTED; /* * de-Register with LM-IAS @@ -504,7 +465,9 @@ static void deregister_irlpt_server(void) #ifdef MODULE MODULE_AUTHOR("Thomas Davis <ratbert@radiks.net>"); -MODULE_DESCRIPTION("The Linux IrDA/IrLPT protocol"); +MODULE_DESCRIPTION("The Linux IrDA/IrLPT server protocol"); +MODULE_PARM(irlpt_server_debug,"1i"); +MODULE_PARM(irlpt_server_fsm_debug, "1i"); /* * Function init_module (void) @@ -514,14 +477,15 @@ MODULE_DESCRIPTION("The Linux IrDA/IrLPT protocol"); */ int init_module(void) { + int ret; - DEBUG( irlpt_server_debug, "--> irlpt server: init_module\n"); + DEBUG( irlpt_server_debug, "--> IrLPT server: init_module\n"); - irlpt_server_init(); + ret = irlpt_server_init(); - DEBUG( irlpt_server_debug, "irlpt server: init_module -->\n"); + DEBUG( irlpt_server_debug, "IrLPT server: init_module -->\n"); - return 0; + return ret; } /* @@ -532,14 +496,14 @@ int init_module(void) */ void cleanup_module(void) { - DEBUG( irlpt_server_debug, "--> " __FUNCTION__ "\n"); - DEBUG( 3, "--> irlpt server: cleanup_module\n"); + DEBUG( irlpt_server_debug, "--> IrLPT server: cleanup_module\n"); + /* No need to check MOD_IN_USE, as sys_delete_module() checks. */ /* Free some memory */ irlpt_server_cleanup(); - DEBUG( irlpt_server_debug, "irlpt server: cleanup_module -->\n"); + DEBUG( irlpt_server_debug, "IrLPT server: cleanup_module -->\n"); } #endif /* MODULE */ |