Browse code

- support for URI parameters - recognizes transport, lr, r2, and maddr parameters

Jan Janak authored on 07/04/2003 20:27:37
Showing 2 changed files
... ...
@@ -29,6 +29,8 @@
29 29
  * History:
30 30
  * -------
31 31
  * 2003-03-24 Created by janakj
32
+ * 2003-04-07 shm duplication added (janakj)
33
+ * 2003-04-07 URI class added (janakj)
32 34
  */
33 35
 
34 36
 #include <stdio.h>
... ...
@@ -106,6 +108,50 @@ static inline void parse_contact_class(param_hooks_t* _h, param_t* _p)
106 108
 }
107 109
 
108 110
 
111
+/*
112
+ * Try to find out parameter name, recognized parameters
113
+ * are transport, lr, r2, maddr
114
+ */
115
+static inline void parse_uri_class(param_hooks_t* _h, param_t* _p)
116
+{
117
+	switch(_p->name.s[0]) {
118
+	case 't':
119
+	case 'T':
120
+		if ((_p->name.len == 9) &&
121
+		    (!strncasecmp(_p->name.s + 1, "ransport", 8))) {
122
+			_p->type = P_TRANSPORT;
123
+			_h->uri.transport = _p;
124
+		}
125
+		break;
126
+
127
+	case 'l':
128
+	case 'L':
129
+		if ((_p->name.len == 2) && ((_p->name.s[1] == 'r') || (_p->name.s[1] == 'R'))) {
130
+			_p->type = P_LR;
131
+			_h->uri.lr = _p;
132
+		}
133
+		break;
134
+
135
+	case 'r':
136
+	case 'R':
137
+		if ((_p->name.len == 2) && (_p->name.s[1] == '2')) {
138
+			_p->type = P_R2;
139
+			_h->uri.r2 = _p;
140
+		}
141
+		break;
142
+
143
+	case 'm':
144
+	case 'M':
145
+		if ((_p->name.len == 5) &&
146
+		    (!strncasecmp(_p->name.s + 1, "addr", 4))) {
147
+			_p->type = P_MADDR;
148
+			_p->uri.maddr = _p;
149
+		}
150
+		break;
151
+	}
152
+}
153
+
154
+
109 155
 /*
110 156
  * Parse quoted string in a parameter body
111 157
  * return the string without quotes in _r
... ...
@@ -243,6 +289,7 @@ static inline void parse_param_name(str* _s, pclass_t _c, param_hooks_t* _h, par
243 289
 	switch(_c) {
244 290
 	case CLASS_RR:      parse_rr_class(_h, _p);      break;
245 291
 	case CLASS_CONTACT: parse_contact_class(_h, _p); break;
292
+	case CLASS_URI:     parse_uri_class(_h, _p);     break;
246 293
 	default: break;
247 294
 	}
248 295
 }
... ...
@@ -411,13 +458,17 @@ static inline void print_param(param_t* _p)
411 458
 	printf("---param(%p)---\n", _p);
412 459
 	
413 460
 	switch(_p->type) {
414
-	case P_OTHER:   type = "P_OTHER";   break;
415
-	case P_LR:      type = "P_LR";      break;
416
-	case P_R2:      type = "P_R2";      break;
417
-	case P_Q:       type = "P_Q";       break;
418
-	case P_EXPIRES: type = "P_EXPIRES"; break;
419
-	case P_METHOD:  type = "P_METHOD";  break;
420
-	default:        type = "UNKNOWN";   break;
461
+	case P_OTHER:     type = "P_OTHER";     break;
462
+	case P_LR:        type = "P_LR";        break;
463
+	case P_R2:        type = "P_R2";        break;
464
+	case P_Q:         type = "P_Q";         break;
465
+	case P_EXPIRES:   type = "P_EXPIRES";   break;
466
+	case P_METHOD:    type = "P_METHOD";    break;
467
+	case P_TRANSPORT: type = "P_TRANSPORT"; break;
468
+	case P_LR:        type = "P_LR";        break;
469
+	case P_R2:        type = "P_R2";        break;
470
+	case P_MADDR:     type = "P_MADDR";     break;
471
+	default:          type = "UNKNOWN";     break;
421 472
 	}
422 473
 	
423 474
 	printf("type: %s\n", type);
... ...
@@ -29,6 +29,8 @@
29 29
  * History:
30 30
  * -------
31 31
  * 2003-03-24 Created by janakj
32
+ * 2003-04-07 shm duplication support (janakj)
33
+ * 2003-04-07 URI class added (janakj)
32 34
  */
33 35
 
34 36
 #ifndef PARSE_PARAM_H
... ...
@@ -44,7 +46,11 @@ typedef enum ptype {
44 46
 	P_R2,        /* Route & Record-Route: r2 parameter - Route & Record-Route */
45 47
 	P_Q,         /* Contact: q parameter */
46 48
 	P_EXPIRES,   /* Contact: expires parameter */
47
-	P_METHOD     /* Contact: method parameter */
49
+	P_METHOD,    /* Contact: method parameter */
50
+	P_TRANSPORT, /* URI: transport parameter */
51
+	P_LR,        /* URI: lr parameter */
52
+	P_R2,        /* URI: r2 parameter (ser specific) */
53
+	P_MADDR      /* URI: maddr parameter */
48 54
 } ptype_t;
49 55
 
50 56
 
... ...
@@ -54,7 +60,8 @@ typedef enum ptype {
54 60
 typedef enum pclass {
55 61
 	CLASS_ANY = 0,  /* Any parameters, well-known hooks will be not used */
56 62
 	CLASS_RR,       /* Route & Record-Route parameters */
57
-	CLASS_CONTACT   /* Contact parameters */
63
+	CLASS_CONTACT,  /* Contact parameters */
64
+	CLASS_URI       /* URI parameters */
58 65
 } pclass_t;
59 66
 
60 67
 
... ...
@@ -89,12 +96,24 @@ struct contact_hooks {
89 96
 };
90 97
 
91 98
 
99
+/*
100
+ * Hooks to well known parameter for URI class of parameters
101
+ */
102
+struct uri_hooks {
103
+	struct param* transport; /* transport parameter */
104
+	struct param* lr;        /* lr parameter */
105
+	struct param* r2;        /* r2 parameter */
106
+	struct param* maddr;     /* maddr parameter */
107
+};
108
+
109
+
92 110
 /*
93 111
  * Union of hooks structures for all classes
94 112
  */
95 113
 typedef union param_hooks {
96 114
  	struct rr_hooks rr;           /* Route & Record-Route hooks */
97 115
 	struct contact_hooks contact; /* Contact hooks */
116
+	struct uri_hooks uri;         /* URI hooks */
98 117
 } param_hooks_t;
99 118
 
100 119