1 /*********************************************************************
5 * Description: Information Access Protocol (IAP)
6 * Status: Experimental.
7 * Author: Dag Brattli <dagb@cs.uit.no>
8 * Created at: Thu Aug 21 00:02:07 1997
9 * Modified at: Sat Dec 25 16:42:42 1999
10 * Modified by: Dag Brattli <dagb@cs.uit.no>
12 * Copyright (c) 1998-1999 Dag Brattli <dagb@cs.uit.no>,
13 * All Rights Reserved.
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.
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.
24 ********************************************************************/
26 #include <linux/config.h>
27 #include <linux/types.h>
28 #include <linux/skbuff.h>
29 #include <linux/string.h>
30 #include <linux/init.h>
32 #include <asm/byteorder.h>
33 #include <asm/unaligned.h>
35 #include <net/irda/irda.h>
36 #include <net/irda/irttp.h>
37 #include <net/irda/irmod.h>
38 #include <net/irda/irlmp.h>
39 #include <net/irda/irias_object.h>
40 #include <net/irda/iriap_event.h>
41 #include <net/irda/iriap.h>
43 /* FIXME: This one should go in irlmp.c */
44 static const char *ias_charset_types
[] = {
58 static hashbin_t
*iriap
= NULL
;
59 static __u32 service_handle
;
61 extern char *lmp_reasons
[];
63 static void __iriap_close(struct iriap_cb
*self
);
64 static int iriap_register_lsap(struct iriap_cb
*self
, __u8 slsap_sel
, int mode
);
65 static void iriap_disconnect_indication(void *instance
, void *sap
,
66 LM_REASON reason
, struct sk_buff
*skb
);
67 static void iriap_connect_indication(void *instance
, void *sap
,
68 struct qos_info
*qos
, __u32 max_sdu_size
,
71 static void iriap_connect_confirm(void *instance
, void *sap
,
73 __u32 max_sdu_size
, __u8 max_header_size
,
75 static int iriap_data_indication(void *instance
, void *sap
,
79 * Function iriap_init (void)
81 * Initializes the IrIAP layer, called by the module initialization code
84 int __init
iriap_init(void)
86 struct ias_object
*obj
;
87 struct iriap_cb
*server
;
91 /* Allocate master array */
92 iriap
= hashbin_new(HB_LOCAL
);
96 objects
= hashbin_new(HB_LOCAL
);
98 WARNING(__FUNCTION__
"(), Can't allocate objects hashbin!\n");
103 * Register some default services for IrLMP
105 hints
= irlmp_service_to_hint(S_COMPUTER
);
106 service_handle
= irlmp_register_service(hints
);
108 /* Register the Device object with LM-IAS */
109 obj
= irias_new_object("Device", IAS_DEVICE_ID
);
110 irias_add_string_attrib(obj
, "DeviceName", "Linux", IAS_KERNEL_ATTR
);
112 oct_seq
[0] = 0x01; /* Version 1 */
113 oct_seq
[1] = 0x00; /* IAS support bits */
114 oct_seq
[2] = 0x00; /* LM-MUX support bits */
115 #ifdef CONFIG_IRDA_ULTRA
116 oct_seq
[2] |= 0x04; /* Connectionless Data support */
118 irias_add_octseq_attrib(obj
, "IrLMPSupport", oct_seq
, 3,
120 irias_insert_object(obj
);
123 * Register server support with IrLMP so we can accept incoming
126 server
= iriap_open(LSAP_IAS
, IAS_SERVER
, NULL
, NULL
);
128 IRDA_DEBUG(0, __FUNCTION__
"(), unable to open server\n");
131 iriap_register_lsap(server
, LSAP_IAS
, IAS_SERVER
);
137 * Function iriap_cleanup (void)
139 * Initializes the IrIAP layer, called by the module cleanup code in
142 void iriap_cleanup(void)
144 irlmp_unregister_service(service_handle
);
146 hashbin_delete(iriap
, (FREE_FUNC
) __iriap_close
);
147 hashbin_delete(objects
, (FREE_FUNC
) __irias_delete_object
);
151 * Function iriap_open (void)
153 * Opens an instance of the IrIAP layer, and registers with IrLMP
155 struct iriap_cb
*iriap_open(__u8 slsap_sel
, int mode
, void *priv
,
156 CONFIRM_CALLBACK callback
)
158 struct iriap_cb
*self
;
160 IRDA_DEBUG(2, __FUNCTION__
"()\n");
162 self
= kmalloc(sizeof(struct iriap_cb
), GFP_ATOMIC
);
164 WARNING(__FUNCTION__
"(), Unable to kmalloc!\n");
169 * Initialize instance
171 memset(self
, 0, sizeof(struct iriap_cb
));
173 self
->magic
= IAS_MAGIC
;
175 if (mode
== IAS_CLIENT
)
176 iriap_register_lsap(self
, slsap_sel
, mode
);
178 self
->confirm
= callback
;
181 init_timer(&self
->watchdog_timer
);
183 hashbin_insert(iriap
, (irda_queue_t
*) self
, (int) self
, NULL
);
185 /* Initialize state machines */
186 iriap_next_client_state(self
, S_DISCONNECT
);
187 iriap_next_call_state(self
, S_MAKE_CALL
);
188 iriap_next_server_state(self
, R_DISCONNECT
);
189 iriap_next_r_connect_state(self
, R_WAITING
);
195 * Function __iriap_close (self)
197 * Removes (deallocates) the IrIAP instance
200 static void __iriap_close(struct iriap_cb
*self
)
202 IRDA_DEBUG(4, __FUNCTION__
"()\n");
204 ASSERT(self
!= NULL
, return;);
205 ASSERT(self
->magic
== IAS_MAGIC
, return;);
207 del_timer(&self
->watchdog_timer
);
210 dev_kfree_skb(self
->skb
);
218 * Function iriap_close (void)
220 * Closes IrIAP and deregisters with IrLMP
222 void iriap_close(struct iriap_cb
*self
)
224 struct iriap_cb
*entry
;
226 IRDA_DEBUG(2, __FUNCTION__
"()\n");
228 ASSERT(self
!= NULL
, return;);
229 ASSERT(self
->magic
== IAS_MAGIC
, return;);
232 irlmp_close_lsap(self
->lsap
);
236 entry
= (struct iriap_cb
*) hashbin_remove(iriap
, (int) self
, NULL
);
237 ASSERT(entry
== self
, return;);
242 static int iriap_register_lsap(struct iriap_cb
*self
, __u8 slsap_sel
, int mode
)
246 IRDA_DEBUG(2, __FUNCTION__
"()\n");
248 irda_notify_init(¬ify
);
249 notify
.connect_confirm
= iriap_connect_confirm
;
250 notify
.connect_indication
= iriap_connect_indication
;
251 notify
.disconnect_indication
= iriap_disconnect_indication
;
252 notify
.data_indication
= iriap_data_indication
;
253 notify
.instance
= self
;
254 if (mode
== IAS_CLIENT
)
255 strcpy(notify
.name
, "IrIAS cli");
257 strcpy(notify
.name
, "IrIAS srv");
259 self
->lsap
= irlmp_open_lsap(slsap_sel
, ¬ify
, 0);
260 if (self
->lsap
== NULL
) {
261 ERROR(__FUNCTION__
"(), Unable to allocated LSAP!\n");
264 self
->slsap_sel
= self
->lsap
->slsap_sel
;
270 * Function iriap_disconnect_indication (handle, reason)
272 * Got disconnect, so clean up everything assosiated with this connection
275 static void iriap_disconnect_indication(void *instance
, void *sap
,
277 struct sk_buff
*userdata
)
279 struct iriap_cb
*self
;
281 IRDA_DEBUG(4, __FUNCTION__
"(), reason=%s\n", lmp_reasons
[reason
]);
283 self
= (struct iriap_cb
*) instance
;
285 ASSERT(self
!= NULL
, return;);
286 ASSERT(self
->magic
== IAS_MAGIC
, return;);
288 ASSERT(iriap
!= NULL
, return;);
290 del_timer(&self
->watchdog_timer
);
292 if (self
->mode
== IAS_CLIENT
) {
293 IRDA_DEBUG(4, __FUNCTION__
"(), disconnect as client\n");
296 iriap_do_client_event(self
, IAP_LM_DISCONNECT_INDICATION
,
299 * Inform service user that the request failed by sending
300 * it a NULL value. Warning, the client might close us, so
301 * remember no to use self anymore after calling confirm
304 self
->confirm(IAS_DISCONNECT
, 0, NULL
, self
->priv
);
306 IRDA_DEBUG(4, __FUNCTION__
"(), disconnect as server\n");
307 iriap_do_server_event(self
, IAP_LM_DISCONNECT_INDICATION
,
313 dev_kfree_skb(userdata
);
317 * Function iriap_disconnect_request (handle)
322 void iriap_disconnect_request(struct iriap_cb
*self
)
326 IRDA_DEBUG(4, __FUNCTION__
"()\n");
328 ASSERT(self
!= NULL
, return;);
329 ASSERT(self
->magic
== IAS_MAGIC
, return;);
331 skb
= dev_alloc_skb(64);
333 IRDA_DEBUG(0, __FUNCTION__
334 "(), Could not allocate an sk_buff of length %d\n", 64);
339 * Reserve space for MUX control and LAP header
341 skb_reserve(skb
, LMP_MAX_HEADER
);
343 irlmp_disconnect_request(self
->lsap
, skb
);
346 void iriap_getinfobasedetails_request(void)
348 IRDA_DEBUG(0, __FUNCTION__
"(), Not implemented!\n");
351 void iriap_getinfobasedetails_confirm(void)
353 IRDA_DEBUG(0, __FUNCTION__
"(), Not implemented!\n");
356 void iriap_getobjects_request(void)
358 IRDA_DEBUG(0, __FUNCTION__
"(), Not implemented!\n");
361 void iriap_getobjects_confirm(void)
363 IRDA_DEBUG(0, __FUNCTION__
"(), Not implemented!\n");
366 void iriap_getvalue(void)
368 IRDA_DEBUG(0, __FUNCTION__
"(), Not implemented!\n");
372 * Function iriap_getvaluebyclass (addr, name, attr)
374 * Retreive all values from attribute in all objects with given class
377 int iriap_getvaluebyclass_request(struct iriap_cb
*self
,
378 __u32 saddr
, __u32 daddr
,
379 char *name
, char *attr
)
382 int name_len
, attr_len
;
385 ASSERT(self
!= NULL
, return -1;);
386 ASSERT(self
->magic
== IAS_MAGIC
, return -1;);
388 /* Client must supply the destination device address */
396 * Save operation, so we know what the later indication is about
398 self
->operation
= GET_VALUE_BY_CLASS
;
400 /* Give ourselves 10 secs to finish this operation */
401 iriap_start_watchdog_timer(self
, 10*HZ
);
403 skb
= dev_alloc_skb(64);
407 name_len
= strlen(name
);
408 attr_len
= strlen(attr
);
410 /* Reserve space for MUX and LAP header */
411 skb_reserve(skb
, self
->max_header_size
);
412 skb_put(skb
, 3+name_len
+attr_len
);
416 frame
[0] = IAP_LST
| GET_VALUE_BY_CLASS
;
417 frame
[1] = name_len
; /* Insert length of name */
418 memcpy(frame
+2, name
, name_len
); /* Insert name */
419 frame
[2+name_len
] = attr_len
; /* Insert length of attr */
420 memcpy(frame
+3+name_len
, attr
, attr_len
); /* Insert attr */
422 iriap_do_client_event(self
, IAP_CALL_REQUEST_GVBC
, skb
);
428 * Function iriap_getvaluebyclass_confirm (self, skb)
430 * Got result from GetValueByClass command. Parse it and return result
434 void iriap_getvaluebyclass_confirm(struct iriap_cb
*self
, struct sk_buff
*skb
)
436 struct ias_value
*value
;
446 ASSERT(self
!= NULL
, return;);
447 ASSERT(self
->magic
== IAS_MAGIC
, return;);
448 ASSERT(skb
!= NULL
, return;);
450 /* Initialize variables */
454 /* Get length, MSB first */
455 len
= be16_to_cpu(get_unaligned((__u16
*)(fp
+n
))); n
+= 2;
457 IRDA_DEBUG(4, __FUNCTION__
"(), len=%d\n", len
);
459 /* Get object ID, MSB first */
460 obj_id
= be16_to_cpu(get_unaligned((__u16
*)(fp
+n
))); n
+= 2;
463 IRDA_DEBUG(4, __FUNCTION__
"(), Value type = %d\n", type
);
467 memcpy(&tmp_cpu32
, fp
+n
, 4); n
+= 4;
468 be32_to_cpus(&tmp_cpu32
);
469 value
= irias_new_integer_value(tmp_cpu32
);
471 /* Legal values restricted to 0x01-0x6f, page 15 irttp */
472 IRDA_DEBUG(4, __FUNCTION__
"(), lsap=%d\n", value
->t
.integer
);
480 /* case CS_ISO_8859_1: */
481 /* case CS_ISO_8859_2: */
482 /* case CS_ISO_8859_3: */
483 /* case CS_ISO_8859_4: */
484 /* case CS_ISO_8859_5: */
485 /* case CS_ISO_8859_6: */
486 /* case CS_ISO_8859_7: */
487 /* case CS_ISO_8859_8: */
488 /* case CS_ISO_8859_9: */
489 /* case CS_UNICODE: */
491 IRDA_DEBUG(0, __FUNCTION__
492 "(), charset %s, not supported\n",
493 ias_charset_types
[charset
]);
495 /* Aborting, close connection! */
496 iriap_disconnect_request(self
);
502 IRDA_DEBUG(4, __FUNCTION__
"(), strlen=%d\n", value_len
);
503 ASSERT(value_len
< 64, return;);
505 /* Make sure the string is null-terminated */
506 fp
[n
+value_len
] = 0x00;
508 IRDA_DEBUG(4, "Got string %s\n", fp
+n
);
509 value
= irias_new_string_value(fp
+n
);
512 value_len
= be16_to_cpu(get_unaligned((__u16
*)(fp
+n
)));
515 ASSERT(value_len
<= 55, return;);
517 value
= irias_new_octseq_value(fp
+n
, value_len
);
520 value
= irias_new_missing_value();
524 /* Finished, close connection! */
525 iriap_disconnect_request(self
);
527 /* Warning, the client might close us, so remember no to use self
528 * anymore after calling confirm
531 self
->confirm(IAS_SUCCESS
, obj_id
, value
, self
->priv
);
533 IRDA_DEBUG(0, __FUNCTION__
"(), missing handler!\n");
534 irias_delete_value(value
);
540 * Function iriap_getvaluebyclass_response ()
542 * Send answer back to remote LM-IAS
545 void iriap_getvaluebyclass_response(struct iriap_cb
*self
, __u16 obj_id
,
546 __u8 ret_code
, struct ias_value
*value
)
550 __u32 tmp_be32
, tmp_be16
;
553 IRDA_DEBUG(4, __FUNCTION__
"()\n");
555 ASSERT(self
!= NULL
, return;);
556 ASSERT(self
->magic
== IAS_MAGIC
, return;);
557 ASSERT(value
!= NULL
, return;);
558 ASSERT(value
->len
<= 1024, return;);
560 /* Initialize variables */
564 * We must adjust the size of the response after the length of the
565 * value. We add 32 bytes because of the 6 bytes for the frame and
566 * max 5 bytes for the value coding.
568 skb
= dev_alloc_skb(value
->len
+ self
->max_header_size
+ 32);
572 /* Reserve space for MUX and LAP header */
573 skb_reserve(skb
, self
->max_header_size
);
579 fp
[n
++] = GET_VALUE_BY_CLASS
| IAP_LST
;
582 /* Insert list length (MSB first) */
583 tmp_be16
= __constant_htons(0x0001);
584 memcpy(fp
+n
, &tmp_be16
, 2); n
+= 2;
586 /* Insert object identifier ( MSB first) */
587 tmp_be16
= cpu_to_be16(obj_id
);
588 memcpy(fp
+n
, &tmp_be16
, 2); n
+= 2;
590 switch (value
->type
) {
592 skb_put(skb
, 3 + value
->len
);
593 fp
[n
++] = value
->type
;
594 fp
[n
++] = 0; /* ASCII */
595 fp
[n
++] = (__u8
) value
->len
;
596 memcpy(fp
+n
, value
->t
.string
, value
->len
); n
+=value
->len
;
600 fp
[n
++] = value
->type
;
602 tmp_be32
= cpu_to_be32(value
->t
.integer
);
603 memcpy(fp
+n
, &tmp_be32
, 4); n
+= 4;
606 skb_put(skb
, 3 + value
->len
);
607 fp
[n
++] = value
->type
;
609 tmp_be16
= cpu_to_be16(value
->len
);
610 memcpy(fp
+n
, &tmp_be16
, 2); n
+= 2;
611 memcpy(fp
+n
, value
->t
.oct_seq
, value
->len
); n
+=value
->len
;
614 IRDA_DEBUG( 3, __FUNCTION__
": sending IAS_MISSING\n");
616 fp
[n
++] = value
->type
;
619 IRDA_DEBUG(0, __FUNCTION__
"(), type not implemented!\n");
622 iriap_do_r_connect_event(self
, IAP_CALL_RESPONSE
, skb
);
626 * Function iriap_getvaluebyclass_indication (self, skb)
628 * getvaluebyclass is requested from peer LM-IAS
631 void iriap_getvaluebyclass_indication(struct iriap_cb
*self
,
634 struct ias_object
*obj
;
635 struct ias_attrib
*attrib
;
643 IRDA_DEBUG(4, __FUNCTION__
"()\n");
645 ASSERT(self
!= NULL
, return;);
646 ASSERT(self
->magic
== IAS_MAGIC
, return;);
647 ASSERT(skb
!= NULL
, return;);
653 memcpy(name
, fp
+n
, name_len
); n
+=name_len
;
654 name
[name_len
] = '\0';
657 memcpy(attr
, fp
+n
, attr_len
); n
+=attr_len
;
658 attr
[attr_len
] = '\0';
660 /* We do not need the buffer anymore */
663 IRDA_DEBUG(4, "LM-IAS: Looking up %s: %s\n", name
, attr
);
664 obj
= irias_find_object(name
);
667 IRDA_DEBUG(2, "LM-IAS: Object %s not found\n", name
);
668 iriap_getvaluebyclass_response(self
, 0x1235, IAS_CLASS_UNKNOWN
,
672 IRDA_DEBUG(4, "LM-IAS: found %s, id=%d\n", obj
->name
, obj
->id
);
674 attrib
= irias_find_attrib(obj
, attr
);
675 if (attrib
== NULL
) {
676 IRDA_DEBUG(2, "LM-IAS: Attribute %s not found\n", attr
);
677 iriap_getvaluebyclass_response(self
, obj
->id
,
678 IAS_ATTRIB_UNKNOWN
, &missing
);
682 /* We have a match; send the value. */
683 iriap_getvaluebyclass_response(self
, obj
->id
, IAS_SUCCESS
,
690 * Function iriap_send_ack (void)
695 void iriap_send_ack(struct iriap_cb
*self
)
700 IRDA_DEBUG(2, __FUNCTION__
"()\n");
702 ASSERT(self
!= NULL
, return;);
703 ASSERT(self
->magic
== IAS_MAGIC
, return;);
705 skb
= dev_alloc_skb(64);
709 /* Reserve space for MUX and LAP header */
710 skb_reserve(skb
, self
->max_header_size
);
715 frame
[0] = IAP_LST
| IAP_ACK
| self
->operation
;
717 irlmp_data_request(self
->lsap
, skb
);
720 void iriap_connect_request(struct iriap_cb
*self
)
724 ASSERT(self
!= NULL
, return;);
725 ASSERT(self
->magic
== IAS_MAGIC
, return;);
727 ret
= irlmp_connect_request(self
->lsap
, LSAP_IAS
,
728 self
->saddr
, self
->daddr
,
731 IRDA_DEBUG(0, __FUNCTION__
"(), connect failed!\n");
732 self
->confirm(IAS_DISCONNECT
, 0, NULL
, self
->priv
);
737 * Function iriap_connect_confirm (handle, skb)
739 * LSAP connection confirmed!
742 static void iriap_connect_confirm(void *instance
, void *sap
,
743 struct qos_info
*qos
, __u32 max_seg_size
,
744 __u8 max_header_size
,
745 struct sk_buff
*userdata
)
747 struct iriap_cb
*self
;
749 self
= (struct iriap_cb
*) instance
;
751 ASSERT(self
!= NULL
, return;);
752 ASSERT(self
->magic
== IAS_MAGIC
, return;);
753 ASSERT(userdata
!= NULL
, return;);
755 self
->max_data_size
= max_seg_size
;
756 self
->max_header_size
= max_header_size
;
758 del_timer(&self
->watchdog_timer
);
760 iriap_do_client_event(self
, IAP_LM_CONNECT_CONFIRM
, userdata
);
764 * Function iriap_connect_indication ( handle, skb)
766 * Remote LM-IAS is requesting connection
769 static void iriap_connect_indication(void *instance
, void *sap
,
770 struct qos_info
*qos
, __u32 max_seg_size
,
771 __u8 max_header_size
,
772 struct sk_buff
*userdata
)
774 struct iriap_cb
*self
, *new;
776 IRDA_DEBUG(0, __FUNCTION__
"()\n");
778 self
= (struct iriap_cb
*) instance
;
780 ASSERT(self
!= NULL
, return;);
781 ASSERT(self
->magic
== IAS_MAGIC
, return;);
783 /* Start new server */
784 new = iriap_open(LSAP_IAS
, IAS_SERVER
, NULL
, NULL
);
786 IRDA_DEBUG(0, __FUNCTION__
"(), open failed\n");
787 dev_kfree_skb(userdata
);
791 /* Now attach up the new "socket" */
792 new->lsap
= irlmp_dup(self
->lsap
, new);
794 IRDA_DEBUG(0, __FUNCTION__
"(), dup failed!\n");
798 new->max_data_size
= max_seg_size
;
799 new->max_header_size
= max_header_size
;
801 /* Clean up the original one to keep it in listen state */
802 self
->lsap
->dlsap_sel
= LSAP_ANY
;
803 self
->lsap
->lsap_state
= LSAP_DISCONNECTED
;
804 /* FIXME: refcount in irlmp might get wrong */
806 iriap_do_server_event(new, IAP_LM_CONNECT_INDICATION
, userdata
);
810 * Function iriap_data_indication (handle, skb)
812 * Receives data from connection identified by handle from IrLMP
815 static int iriap_data_indication(void *instance
, void *sap
,
818 struct iriap_cb
*self
;
822 IRDA_DEBUG(3, __FUNCTION__
"()\n");
824 self
= (struct iriap_cb
*) instance
;
826 ASSERT(self
!= NULL
, return 0;);
827 ASSERT(self
->magic
== IAS_MAGIC
, return 0;);
829 ASSERT(skb
!= NULL
, return 0;);
833 if (self
->mode
== IAS_SERVER
) {
835 IRDA_DEBUG(4, __FUNCTION__
"(), Calling server!\n");
836 iriap_do_r_connect_event(self
, IAP_RECV_F_LST
, skb
);
841 if (~opcode
& IAP_LST
) {
842 WARNING(__FUNCTION__
"(), IrIAS multiframe commands or "
843 "results is not implemented yet!\n");
848 /* Check for ack frames since they don't contain any data */
849 if (opcode
& IAP_ACK
) {
850 IRDA_DEBUG(0, __FUNCTION__
"() Got ack frame!\n");
855 opcode
&= ~IAP_LST
; /* Mask away LST bit */
859 IRDA_DEBUG(0, "IrLMP GetInfoBaseDetails not implemented!\n");
862 case GET_VALUE_BY_CLASS
:
863 iriap_do_call_event(self
, IAP_RECV_F_LST
, NULL
);
867 iriap_getvaluebyclass_confirm(self
, skb
);
869 case IAS_CLASS_UNKNOWN
:
870 IRDA_DEBUG(1, __FUNCTION__
"(), No such class!\n");
871 /* Finished, close connection! */
872 iriap_disconnect_request(self
);
875 * Warning, the client might close us, so remember
876 * no to use self anymore after calling confirm
879 self
->confirm(IAS_CLASS_UNKNOWN
, 0, NULL
,
883 case IAS_ATTRIB_UNKNOWN
:
884 IRDA_DEBUG(1, __FUNCTION__
"(), No such attribute!\n");
885 /* Finished, close connection! */
886 iriap_disconnect_request(self
);
889 * Warning, the client might close us, so remember
890 * no to use self anymore after calling confirm
893 self
->confirm(IAS_ATTRIB_UNKNOWN
, 0, NULL
,
900 IRDA_DEBUG(0, __FUNCTION__
"(), Unknown op-code: %02x\n",
909 * Function iriap_call_indication (self, skb)
911 * Received call to server from peer LM-IAS
914 void iriap_call_indication(struct iriap_cb
*self
, struct sk_buff
*skb
)
919 IRDA_DEBUG(4, __FUNCTION__
"()\n");
921 ASSERT(self
!= NULL
, return;);
922 ASSERT(self
->magic
== IAS_MAGIC
, return;);
923 ASSERT(skb
!= NULL
, return;);
928 if (~opcode
& 0x80) {
929 WARNING(__FUNCTION__
"(), IrIAS multiframe commands or results"
930 "is not implemented yet!\n");
933 opcode
&= 0x7f; /* Mask away LST bit */
938 "(), GetInfoBaseDetails not implemented yet!\n");
940 case GET_VALUE_BY_CLASS
:
941 iriap_getvaluebyclass_indication(self
, skb
);
947 * Function iriap_watchdog_timer_expired (data)
949 * Query has taken to long time, so abort
952 void iriap_watchdog_timer_expired(void *data
)
954 struct iriap_cb
*self
= (struct iriap_cb
*) data
;
956 ASSERT(self
!= NULL
, return;);
957 ASSERT(self
->magic
== IAS_MAGIC
, return;);
959 /* iriap_close(self); */
962 #ifdef CONFIG_PROC_FS
964 static char *ias_value_types
[] = {
971 int irias_proc_read(char *buf
, char **start
, off_t offset
, int len
)
973 struct ias_object
*obj
;
974 struct ias_attrib
*attrib
;
977 ASSERT( objects
!= NULL
, return 0;);
984 len
+= sprintf(buf
+len
, "LM-IAS Objects:\n");
986 /* List all objects */
987 obj
= (struct ias_object
*) hashbin_get_first(objects
);
988 while ( obj
!= NULL
) {
989 ASSERT(obj
->magic
== IAS_OBJECT_MAGIC
, return 0;);
991 len
+= sprintf(buf
+len
, "name: %s, ", obj
->name
);
992 len
+= sprintf(buf
+len
, "id=%d", obj
->id
);
993 len
+= sprintf(buf
+len
, "\n");
995 /* List all attributes for this object */
996 attrib
= (struct ias_attrib
*)
997 hashbin_get_first(obj
->attribs
);
998 while (attrib
!= NULL
) {
999 ASSERT(attrib
->magic
== IAS_ATTRIB_MAGIC
, return 0;);
1001 len
+= sprintf(buf
+len
, " - Attribute name: \"%s\", ",
1003 len
+= sprintf(buf
+len
, "value[%s]: ",
1004 ias_value_types
[attrib
->value
->type
]);
1006 switch (attrib
->value
->type
) {
1008 len
+= sprintf(buf
+len
, "%d\n",
1009 attrib
->value
->t
.integer
);
1012 len
+= sprintf(buf
+len
, "\"%s\"\n",
1013 attrib
->value
->t
.string
);
1016 len
+= sprintf(buf
+len
, "octet sequence\n");
1019 len
+= sprintf(buf
+len
, "missing\n");
1022 IRDA_DEBUG(0, __FUNCTION__
1023 "(), Unknown value type!\n");
1026 len
+= sprintf(buf
+len
, "\n");
1028 attrib
= (struct ias_attrib
*)
1029 hashbin_get_next(obj
->attribs
);
1031 obj
= (struct ias_object
*) hashbin_get_next(objects
);
1033 restore_flags(flags
);
1038 #endif /* PROC_FS */