Browse code

- add_avp_list and reset_domain_avps added

Jan Janak authored on 19/11/2005 16:51:51
Showing 2 changed files
... ...
@@ -82,34 +82,14 @@ inline static unsigned short compute_ID( str *name )
82 82
 }
83 83
 
84 84
 
85
-int add_avp(unsigned short flags, int_str name, int_str val)
85
+int add_avp_list(avp_t** list, unsigned short flags, int_str name, int_str val)
86 86
 {
87
-	avp_t **list;
88 87
 	avp_t *avp;
89 88
 	str *s;
90 89
 	struct str_int_data *sid;
91 90
 	struct str_str_data *ssd;
92
-	unsigned short avp_class;
93 91
 	int len;
94 92
 
95
-	if ((flags & ALL_AVP_CLASSES) == 0) {
96
-		     /* The caller did not specify any class to search in, so enable
97
-		      * all of them by default
98
-		      */
99
-		flags |= ALL_AVP_CLASSES;
100
-	}
101
-
102
-	if (IS_USER_AVP(flags)) {
103
-		list = crt_user_avps;
104
-		avp_class = AVP_USER;
105
-	} else if (IS_DOMAIN_AVP(flags)) {
106
-		list = crt_domain_avps;
107
-		avp_class = AVP_DOMAIN;
108
-	} else {
109
-		list = crt_global_avps;
110
-		avp_class = AVP_GLOBAL;
111
-	}
112
-
113 93
 	assert(list != 0);
114 94
 
115 95
 	if ( name.s==0 ) {
... ...
@@ -142,10 +122,7 @@ int add_avp(unsigned short flags, int_str name, int_str val)
142 142
 		goto error;
143 143
 	}
144 144
 
145
-		 /* Make that only the selected class is set
146
-		  * if the caller set more classes in flags
147
-		  */
148
-	avp->flags = flags & (~(ALL_AVP_CLASSES) | avp_class);
145
+	avp->flags = flags;
149 146
 	avp->id = (flags&AVP_NAME_STR)? compute_ID(name.s) : name.n ;
150 147
 
151 148
 	avp->next = *list;
... ...
@@ -194,6 +171,36 @@ error:
194 194
 }
195 195
 
196 196
 
197
+int add_avp(unsigned short flags, int_str name, int_str val)
198
+{
199
+	unsigned short avp_class;
200
+	avp_t **list;
201
+
202
+	if ((flags & ALL_AVP_CLASSES) == 0) {
203
+		     /* The caller did not specify any class to search in, so enable
204
+		      * all of them by default
205
+		      */
206
+		flags |= ALL_AVP_CLASSES;
207
+	}
208
+
209
+	if (IS_USER_AVP(flags)) {
210
+		list = crt_user_avps;
211
+		avp_class = AVP_USER;
212
+	} else if (IS_DOMAIN_AVP(flags)) {
213
+		list = crt_domain_avps;
214
+		avp_class = AVP_DOMAIN;
215
+	} else {
216
+		list = crt_global_avps;
217
+		avp_class = AVP_GLOBAL;
218
+	}
219
+
220
+		 /* Make that only the selected class is set
221
+		  * if the caller set more classes in flags
222
+		  */
223
+	return add_avp_list(list, flags & (~(ALL_AVP_CLASSES) | avp_class), name, val);
224
+}
225
+
226
+
197 227
 /* get value functions */
198 228
 inline str* get_avp_name(avp_t *avp)
199 229
 {
... ...
@@ -459,6 +466,17 @@ void reset_user_avps(void)
459 459
 }
460 460
 
461 461
 
462
+void reset_domain_avps(void)
463
+{
464
+	assert( crt_user_avps!=0 );
465
+	
466
+	if ( crt_user_avps!=&domain_avps) {
467
+		crt_domain_avps = &domain_avps;
468
+	}
469
+	     /* Do not destroy avps here, domain module takes care of it */
470
+}
471
+
472
+
462 473
 avp_t** set_user_avp_list( avp_t **list )
463 474
 {
464 475
 	avp_t **foo;
... ...
@@ -56,6 +56,14 @@
56 56
 #include "str.h"
57 57
 
58 58
 
59
+#define AVP_UID          "uid"           /* Unique user identifier */
60
+#define AVP_DID          "did"           /* Unique domain identifier */
61
+#define AVP_REALM        "digest_realm"  /* Digest realm */
62
+#define AVP_FR_TIMER     "fr_timer"      /* Value of final response timer */
63
+#define AVP_FR_INV_TIMER "fr_inv_timer"  /* Value of final response invite timer */
64
+#define AVP_RPID         "rpid"          /* Remote-Party-ID */
65
+
66
+
59 67
 struct str_int_data {
60 68
 	str name;
61 69
 	int val;
... ...
@@ -117,6 +125,8 @@ struct search_state {
117 117
 /* add functions */
118 118
 int add_avp(unsigned short flags, int_str name, int_str val);
119 119
 
120
+int add_avp_list(avp_t** list, unsigned short flags, int_str name, int_str val);
121
+
120 122
 /* search functions */
121 123
 avp_t *search_first_avp( unsigned short flags, int_str name,
122 124
 			 int_str *val, struct search_state* state);
... ...
@@ -124,6 +134,7 @@ avp_t *search_next_avp(struct search_state* state, int_str *val);
124 124
 
125 125
 /* free functions */
126 126
 void reset_user_avps(void);
127
+void reset_domain_avps(void);
127 128
 
128 129
 void destroy_avp(avp_t *avp);
129 130
 void destroy_avp_list(avp_t **list );