1 /*********************************************************************
2  *
3  * Filename:      irias_object.h
4  * Version:
5  * Description:
6  * Status:        Experimental.
7  * Author:        Dag Brattli <dagb@cs.uit.no>
8  * Created at:    Thu Oct  1 22:49:50 1998
9  * Modified at:   Wed Dec 15 11:20:57 1999
10  * Modified by:   Dag Brattli <dagb@cs.uit.no>
11  *
12  *     Copyright (c) 1998-1999 Dag Brattli, All Rights Reserved.
13  *
14  *     This program is free software; you can redistribute it and/or
15  *     modify it under the terms of the GNU General Public License as
16  *     published by the Free Software Foundation; either version 2 of
17  *     the License, or (at your option) any later version.
18  *
19  *     Neither Dag Brattli nor University of Troms� admit liability nor
20  *     provide warranty for any of this software. This material is
21  *     provided "AS-IS" and at no charge.
22  *
23  ********************************************************************/
24 
25 #ifndef LM_IAS_OBJECT_H
26 #define LM_IAS_OBJECT_H
27 
28 #include <net/irda/irda.h>
29 #include <net/irda/irqueue.h>
30 
31 /* LM-IAS Attribute types */
32 #define IAS_MISSING 0
33 #define IAS_INTEGER 1
34 #define IAS_OCT_SEQ 2
35 #define IAS_STRING  3
36 
37 /* Object ownership of attributes (user or kernel) */
38 #define IAS_KERNEL_ATTR	0
39 #define IAS_USER_ATTR	1
40 
41 /*
42  *  LM-IAS Object
43  */
44 struct ias_object {
45 	irda_queue_t q;     /* Must be first! */
46 	magic_t magic;
47 
48 	char  *name;
49 	int   id;
50 	hashbin_t *attribs;
51 };
52 
53 /*
54  *  Values used by LM-IAS attributes
55  */
56 struct ias_value {
57         __u8    type;    /* Value description */
58 	__u8	owner;	/* Managed from user/kernel space */
59 	int     charset; /* Only used by string type */
60         int     len;
61 
62 	/* Value */
63 	union {
64 		int integer;
65 		char *string;
66 		__u8 *oct_seq;
67 	} t;
68 };
69 
70 /*
71  *  Attributes used by LM-IAS objects
72  */
73 struct ias_attrib {
74 	irda_queue_t q; /* Must be first! */
75 	int magic;
76 
77         char *name;   	         /* Attribute name */
78 	struct ias_value *value; /* Attribute value */
79 };
80 
81 char *strndup(char *str, int max);
82 
83 struct ias_object *irias_new_object(char *name, int id);
84 void irias_insert_object(struct ias_object *obj);
85 int  irias_delete_object(struct ias_object *obj);
86 int  irias_delete_attrib(struct ias_object *obj, struct ias_attrib *attrib);
87 void __irias_delete_object(struct ias_object *obj);
88 
89 void irias_add_integer_attrib(struct ias_object *obj, char *name, int value,
90 			      int user);
91 void irias_add_string_attrib(struct ias_object *obj, char *name, char *value,
92 			     int user);
93 void irias_add_octseq_attrib(struct ias_object *obj, char *name, __u8 *octets,
94 			     int len, int user);
95 int irias_object_change_attribute(char *obj_name, char *attrib_name,
96 				  struct ias_value *new_value);
97 struct ias_object *irias_find_object(char *name);
98 struct ias_attrib *irias_find_attrib(struct ias_object *obj, char *name);
99 
100 struct ias_value *irias_new_string_value(char *string);
101 struct ias_value *irias_new_integer_value(int integer);
102 struct ias_value *irias_new_octseq_value(__u8 *octseq , int len);
103 struct ias_value *irias_new_missing_value(void);
104 void irias_delete_value(struct ias_value *value);
105 
106 extern struct ias_value missing;
107 extern hashbin_t *objects;
108 
109 #endif
110