... | ... |
@@ -16,6 +16,8 @@ x (different way) add request header bitmap field for the modules |
16 | 16 |
- ? variable number of params functions in script (no longer limited to 2)? |
17 | 17 |
- kill bind_idx |
18 | 18 |
- fix bind_address for tcp (in some way) |
19 |
+- add conflict in debs/rpms/etc (conflict w/ older ser-mysql, ser-jabber) |
|
20 |
+- new packages ser-radius etc |
|
19 | 21 |
|
20 | 22 |
|
21 | 23 |
High priority: |
... | ... |
@@ -26,7 +26,8 @@ |
26 | 26 |
* |
27 | 27 |
* History: |
28 | 28 |
* -------- |
29 |
- * 2003-01-19 support for duplication lump lists added (jiri) |
|
29 |
+ * 2003-01-19 support for duplication lump lists added (jiri) |
|
30 |
+ * 2003-03-31 added subst lumps -- they expand in ip addr, port a.s.o (andrei) |
|
30 | 31 |
*/ |
31 | 32 |
|
32 | 33 |
|
... | ... |
@@ -149,6 +150,57 @@ struct lump* insert_new_lump_before( struct lump* before, char* new_hdr, |
149 | 150 |
|
150 | 151 |
|
151 | 152 |
|
153 |
+/* inserts a subst lump immediately after hdr |
|
154 |
+ * returns pointer on success, 0 on error */ |
|
155 |
+struct lump* insert_subst_lump_after( struct lump* after, enum lump_subst subst, |
|
156 |
+ int type) |
|
157 |
+{ |
|
158 |
+ struct lump* tmp; |
|
159 |
+ |
|
160 |
+ tmp=pkg_malloc(sizeof(struct lump)); |
|
161 |
+ if (tmp==0){ |
|
162 |
+ ser_error=E_OUT_OF_MEM; |
|
163 |
+ LOG(L_ERR, "ERROR: insert_new_lump_after: out of memory\n"); |
|
164 |
+ return 0; |
|
165 |
+ } |
|
166 |
+ memset(tmp,0,sizeof(struct lump)); |
|
167 |
+ tmp->after=after->after; |
|
168 |
+ tmp->type=type; |
|
169 |
+ tmp->op=LUMP_ADD_SUBST; |
|
170 |
+ tmp->u.subst=subst; |
|
171 |
+ tmp->len=0; |
|
172 |
+ after->after=tmp; |
|
173 |
+ return tmp; |
|
174 |
+} |
|
175 |
+ |
|
176 |
+ |
|
177 |
+ |
|
178 |
+/* inserts a subst lump immediately before "before" |
|
179 |
+ * returns pointer on success, 0 on error */ |
|
180 |
+struct lump* insert_subst_lump_before( struct lump* before, |
|
181 |
+ enum lump_subst subst, |
|
182 |
+ int type) |
|
183 |
+{ |
|
184 |
+ struct lump* tmp; |
|
185 |
+ |
|
186 |
+ tmp=pkg_malloc(sizeof(struct lump)); |
|
187 |
+ if (tmp==0){ |
|
188 |
+ ser_error=E_OUT_OF_MEM; |
|
189 |
+ LOG(L_ERR,"ERROR: insert_new_lump_before: out of memory\n"); |
|
190 |
+ return 0; |
|
191 |
+ } |
|
192 |
+ memset(tmp,0,sizeof(struct lump)); |
|
193 |
+ tmp->before=before->before; |
|
194 |
+ tmp->type=type; |
|
195 |
+ tmp->op=LUMP_ADD_SUBST; |
|
196 |
+ tmp->u.subst=subst; |
|
197 |
+ tmp->len=0; |
|
198 |
+ before->before=tmp; |
|
199 |
+ return tmp; |
|
200 |
+} |
|
201 |
+ |
|
202 |
+ |
|
203 |
+ |
|
152 | 204 |
/* removes an already existing header/data lump */ |
153 | 205 |
struct lump* del_lump(struct lump** list, int offset, int len, int type) |
154 | 206 |
{ |
... | ... |
@@ -25,8 +25,11 @@ |
25 | 25 |
* You should have received a copy of the GNU General Public License |
26 | 26 |
* along with this program; if not, write to the Free Software |
27 | 27 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
28 |
- * |
|
29 |
- * 2003-01-29 s/int/enum ... more convenient for gdb (jiri) |
|
28 |
+ */ |
|
29 |
+/* History: |
|
30 |
+ * -------- |
|
31 |
+ * 2003-01-29 s/int/enum ... more convenient for gdb (jiri) |
|
32 |
+ * 2003-03-31 added subst lumps -- they expand in ip addr, port a.s.o (andrei) |
|
30 | 33 |
*/ |
31 | 34 |
|
32 | 35 |
|
... | ... |
@@ -34,7 +37,12 @@ |
34 | 37 |
#define data_lump_h |
35 | 38 |
|
36 | 39 |
|
37 |
-enum lump_op { LUMP_NOP=0, LUMP_DEL, LUMP_ADD }; |
|
40 |
+enum lump_op { LUMP_NOP=0, LUMP_DEL, LUMP_ADD, LUMP_ADD_SUBST }; |
|
41 |
+enum lump_subst{ SUBST_NOP=0, |
|
42 |
+ SUBST_RCV_IP, SUBST_SND_IP, |
|
43 |
+ SUBST_RCV_PORT, SUBST_SND_PORT, |
|
44 |
+ SUBST_RCV_PROTO, SUBST_SND_PROTO |
|
45 |
+ }; |
|
38 | 46 |
enum lump_flag { LUMPFLAG_NONE=0, LUMPFLAG_DUPED=1, LUMPFLAG_SHMEM=2 }; |
39 | 47 |
|
40 | 48 |
struct lump{ |
... | ... |
@@ -43,6 +51,7 @@ struct lump{ |
43 | 51 |
|
44 | 52 |
union{ |
45 | 53 |
int offset; /* used for DEL, MODIFY */ |
54 |
+ enum lump_subst subst; /*what to subst: ip addr, port, proto*/ |
|
46 | 55 |
char * value; /* used for ADD */ |
47 | 56 |
}u; |
48 | 57 |
int len; /* length of this header field */ |
... | ... |
@@ -89,6 +98,11 @@ struct lump* insert_new_lump_after(struct lump* after, |
89 | 98 |
char* new_hdr, int len, int type); |
90 | 99 |
struct lump* insert_new_lump_before(struct lump* before, char* new_hdr, |
91 | 100 |
int len,int type); |
101 |
+/* substitutions (replace with ip address, port etc) */ |
|
102 |
+struct lump* insert_subst_lump_after(struct lump* after, enum lump_subst subst, |
|
103 |
+ int type); |
|
104 |
+struct lump* insert_subst_lump_before(struct lump* before,enum lump_subst subst, |
|
105 |
+ int type); |
|
92 | 106 |
|
93 | 107 |
|
94 | 108 |
/* removes an already existing header */ |
... | ... |
@@ -42,6 +42,7 @@ |
42 | 42 |
* 2003-01-27 more rport fixes (make use of new via_param->start) (andrei) |
43 | 43 |
* 2003-01-27 next baby-step to removing ZT - PRESERVE_ZT (jiri) |
44 | 44 |
* 2003-01-29 scratchpad removed (jiri) |
45 |
+ * 2003-03-31 added subst lump support (andrei) |
|
45 | 46 |
* |
46 | 47 |
*/ |
47 | 48 |
|
... | ... |
@@ -357,24 +358,89 @@ char* clen_builder(struct sip_msg* msg, unsigned int *clen_len) |
357 | 358 |
|
358 | 359 |
/* computes the "unpacked" len of a lump list, |
359 | 360 |
code moved from build_req_from_req */ |
360 |
-static inline int lumps_len(struct lump* l) |
|
361 |
+static inline int lumps_len(struct sip_msg* msg, struct socket_info* send_sock) |
|
361 | 362 |
{ |
362 | 363 |
int s_offset; |
363 | 364 |
int new_len; |
364 | 365 |
struct lump* t; |
365 | 366 |
struct lump* r; |
366 | 367 |
|
368 |
+#define SUBST_LUMP_LEN(subst_l) \ |
|
369 |
+ switch((subst_l)->u.subst){ \ |
|
370 |
+ case SUBST_RCV_IP: \ |
|
371 |
+ if (msg->rcv.bind_address){ \ |
|
372 |
+ new_len+=msg->rcv.bind_address->address_str.len; \ |
|
373 |
+ if (msg->rcv.bind_address->address.af!=AF_INET) \ |
|
374 |
+ new_len+=2; \ |
|
375 |
+ }else{ \ |
|
376 |
+ /* FIXME */ \ |
|
377 |
+ LOG(L_CRIT, "FIXME: null bind_address\n"); \ |
|
378 |
+ }; \ |
|
379 |
+ break; \ |
|
380 |
+ case SUBST_RCV_PORT: \ |
|
381 |
+ if (msg->rcv.bind_address){ \ |
|
382 |
+ new_len+=msg->rcv.bind_address->port_no_str.len; \ |
|
383 |
+ }else{ \ |
|
384 |
+ /* FIXME */ \ |
|
385 |
+ LOG(L_CRIT, "FIXME: null bind_address\n"); \ |
|
386 |
+ }; \ |
|
387 |
+ break; \ |
|
388 |
+ case SUBST_RCV_PROTO: \ |
|
389 |
+ if (msg->rcv.bind_address){ \ |
|
390 |
+ new_len+=send_sock->port_no_str.len; \ |
|
391 |
+ }else{ \ |
|
392 |
+ /* FIXME */ \ |
|
393 |
+ LOG(L_CRIT, "FIXME: null bind_address\n"); \ |
|
394 |
+ }; \ |
|
395 |
+ break; \ |
|
396 |
+ case SUBST_SND_IP: \ |
|
397 |
+ if (send_sock){ \ |
|
398 |
+ new_len+=send_sock->address_str.len; \ |
|
399 |
+ if (send_sock->address.af!=AF_INET) \ |
|
400 |
+ new_len+=2; \ |
|
401 |
+ }else{ \ |
|
402 |
+ LOG(L_CRIT, "FIXME: lumps_len called with" \ |
|
403 |
+ " null send_sock\n"); \ |
|
404 |
+ }; \ |
|
405 |
+ break; \ |
|
406 |
+ case SUBST_SND_PORT: \ |
|
407 |
+ if (send_sock){ \ |
|
408 |
+ new_len+=send_sock->port_no_str.len; \ |
|
409 |
+ }else{ \ |
|
410 |
+ LOG(L_CRIT, "FIXME: lumps_len called with" \ |
|
411 |
+ " null send_sock\n"); \ |
|
412 |
+ }; \ |
|
413 |
+ break; \ |
|
414 |
+ case SUBST_SND_PROTO: \ |
|
415 |
+ if (send_sock){ \ |
|
416 |
+ new_len+=3; /* tcp, udp or tls*/ \ |
|
417 |
+ }else{ \ |
|
418 |
+ LOG(L_CRIT, "FIXME: lumps_len called with" \ |
|
419 |
+ " null send_sock\n"); \ |
|
420 |
+ }; \ |
|
421 |
+ break; \ |
|
422 |
+ case SUBST_NOP: /* do nothing */ \ |
|
423 |
+ break; \ |
|
424 |
+ default: \ |
|
425 |
+ LOG(L_CRIT, "BUG: unknown subst type %d\n", \ |
|
426 |
+ (subst_l)->u.subst); \ |
|
427 |
+ } |
|
428 |
+ |
|
367 | 429 |
s_offset=0; |
368 | 430 |
new_len=0; |
369 |
- for(t=l;t;t=t->next){ |
|
431 |
+ |
|
432 |
+ for(t=msg->add_rm;t;t=t->next){ |
|
370 | 433 |
for(r=t->before;r;r=r->before){ |
371 | 434 |
switch(r->op){ |
372 | 435 |
case LUMP_ADD: |
373 | 436 |
new_len+=r->len; |
374 | 437 |
break; |
438 |
+ case LUMP_ADD_SUBST: |
|
439 |
+ SUBST_LUMP_LEN(r); |
|
440 |
+ break; |
|
375 | 441 |
default: |
376 | 442 |
/* only ADD allowed for before/after */ |
377 |
- LOG(L_CRIT, "BUG: lumps_len: invalid op " |
|
443 |
+ LOG(L_CRIT, "BUG: lumps_len: invalid op " |
|
378 | 444 |
"for data lump (%x)\n", r->op); |
379 | 445 |
} |
380 | 446 |
} |
... | ... |
@@ -382,6 +448,9 @@ static inline int lumps_len(struct lump* l) |
382 | 448 |
case LUMP_ADD: |
383 | 449 |
new_len+=t->len; |
384 | 450 |
break; |
451 |
+ case LUMP_ADD_SUBST: |
|
452 |
+ SUBST_LUMP_LEN(t); |
|
453 |
+ break; |
|
385 | 454 |
case LUMP_DEL: |
386 | 455 |
/* fix overlapping deleted zones */ |
387 | 456 |
if (t->u.offset < s_offset){ |
... | ... |
@@ -411,6 +480,9 @@ static inline int lumps_len(struct lump* l) |
411 | 480 |
case LUMP_ADD: |
412 | 481 |
new_len+=r->len; |
413 | 482 |
break; |
483 |
+ case LUMP_ADD_SUBST: |
|
484 |
+ SUBST_LUMP_LEN(r); |
|
485 |
+ break; |
|
414 | 486 |
default: |
415 | 487 |
/* only ADD allowed for before/after */ |
416 | 488 |
LOG(L_CRIT, "BUG:lumps_len: invalid" |
... | ... |
@@ -426,22 +498,130 @@ static inline int lumps_len(struct lump* l) |
426 | 498 |
/* another helper functions, adds/Removes the lump, |
427 | 499 |
code moved form build_req_from_req */ |
428 | 500 |
|
429 |
-static inline void process_lumps( struct lump* l, char* new_buf, |
|
430 |
- unsigned int* new_buf_offs, char* orig, |
|
431 |
- unsigned int* orig_offs) |
|
501 |
+static inline void process_lumps( struct sip_msg* msg, |
|
502 |
+ char* new_buf, |
|
503 |
+ unsigned int* new_buf_offs, |
|
504 |
+ unsigned int* orig_offs, |
|
505 |
+ struct socket_info* send_sock) |
|
432 | 506 |
{ |
433 | 507 |
struct lump *t; |
434 | 508 |
struct lump *r; |
509 |
+ char* orig; |
|
435 | 510 |
int size; |
436 | 511 |
int offset; |
437 | 512 |
int s_offset; |
513 |
+ |
|
514 |
+#define SUBST_LUMP(subst_l) \ |
|
515 |
+ switch((subst_l)->u.subst){ \ |
|
516 |
+ case SUBST_RCV_IP: \ |
|
517 |
+ if (msg->rcv.bind_address){ \ |
|
518 |
+ memcpy(new_buf+offset, msg->rcv.bind_address->address_str.s, \ |
|
519 |
+ msg->rcv.bind_address->address_str.len); \ |
|
520 |
+ offset+=msg->rcv.bind_address->address_str.len; \ |
|
521 |
+ }else{ \ |
|
522 |
+ /*FIXME*/ \ |
|
523 |
+ LOG(L_CRIT, "FIXME: process_lumps: null bind_address\n"); \ |
|
524 |
+ }; \ |
|
525 |
+ break; \ |
|
526 |
+ case SUBST_RCV_PORT: \ |
|
527 |
+ if (msg->rcv.bind_address){ \ |
|
528 |
+ memcpy(new_buf+offset, msg->rcv.bind_address->port_no_str.s, \ |
|
529 |
+ msg->rcv.bind_address->port_no_str.len); \ |
|
530 |
+ offset+=msg->rcv.bind_address->port_no_str.len; \ |
|
531 |
+ }else{ \ |
|
532 |
+ /*FIXME*/ \ |
|
533 |
+ LOG(L_CRIT, "FIXME: process_lumps: null bind_address\n"); \ |
|
534 |
+ }; \ |
|
535 |
+ break; \ |
|
536 |
+ case SUBST_SND_IP: \ |
|
537 |
+ if (send_sock){ \ |
|
538 |
+ memcpy(new_buf+offset, send_sock->address_str.s, \ |
|
539 |
+ send_sock->address_str.len); \ |
|
540 |
+ offset+=send_sock->address_str.len; \ |
|
541 |
+ }else{ \ |
|
542 |
+ /*FIXME*/ \ |
|
543 |
+ LOG(L_CRIT, "FIXME: process_lumps: called with" \ |
|
544 |
+ " null send_sock\n"); \ |
|
545 |
+ }; \ |
|
546 |
+ break; \ |
|
547 |
+ case SUBST_SND_PORT: \ |
|
548 |
+ if (send_sock){ \ |
|
549 |
+ memcpy(new_buf+offset, send_sock->port_no_str.s, \ |
|
550 |
+ send_sock->port_no_str.len); \ |
|
551 |
+ offset+=send_sock->port_no_str.len; \ |
|
552 |
+ }else{ \ |
|
553 |
+ /*FIXME*/ \ |
|
554 |
+ LOG(L_CRIT, "FIXME: process_lumps: called with" \ |
|
555 |
+ " null send_sock\n"); \ |
|
556 |
+ }; \ |
|
557 |
+ break; \ |
|
558 |
+ case SUBST_RCV_PROTO: \ |
|
559 |
+ if (msg->rcv.bind_address){ \ |
|
560 |
+ switch(msg->rcv.bind_address->proto){ \ |
|
561 |
+ case PROTO_NONE: \ |
|
562 |
+ case PROTO_UDP: \ |
|
563 |
+ memcpy(new_buf+offset, "udp", 3); \ |
|
564 |
+ offset+=3; \ |
|
565 |
+ break; \ |
|
566 |
+ case PROTO_TCP: \ |
|
567 |
+ memcpy(new_buf+offset, "tcp", 3); \ |
|
568 |
+ offset+=3; \ |
|
569 |
+ break; \ |
|
570 |
+ case PROTO_TLS: \ |
|
571 |
+ memcpy(new_buf+offset, "tls", 3); \ |
|
572 |
+ offset+=3; \ |
|
573 |
+ break; \ |
|
574 |
+ default: \ |
|
575 |
+ LOG(L_CRIT, "BUG: process_lumps: unknown proto %d\n", \ |
|
576 |
+ msg->rcv.bind_address->proto); \ |
|
577 |
+ } \ |
|
578 |
+ }else{ \ |
|
579 |
+ /*FIXME*/ \ |
|
580 |
+ LOG(L_CRIT, "FIXME: process lumps: null bind_address\n"); \ |
|
581 |
+ }; \ |
|
582 |
+ break; \ |
|
583 |
+ case SUBST_SND_PROTO: \ |
|
584 |
+ if (send_sock){ \ |
|
585 |
+ switch(send_sock->proto){ \ |
|
586 |
+ case PROTO_NONE: \ |
|
587 |
+ case PROTO_UDP: \ |
|
588 |
+ memcpy(new_buf+offset, "udp", 3); \ |
|
589 |
+ offset+=3; \ |
|
590 |
+ break; \ |
|
591 |
+ case PROTO_TCP: \ |
|
592 |
+ memcpy(new_buf+offset, "tcp", 3); \ |
|
593 |
+ offset+=3; \ |
|
594 |
+ break; \ |
|
595 |
+ case PROTO_TLS: \ |
|
596 |
+ memcpy(new_buf+offset, "tls", 3); \ |
|
597 |
+ offset+=3; \ |
|
598 |
+ break; \ |
|
599 |
+ default: \ |
|
600 |
+ LOG(L_CRIT, "BUG: process_lumps: unknown proto %d\n", \ |
|
601 |
+ send_sock->proto); \ |
|
602 |
+ } \ |
|
603 |
+ }else{ \ |
|
604 |
+ /*FIXME*/ \ |
|
605 |
+ LOG(L_CRIT, "FIXME: process_lumps: called with null" \ |
|
606 |
+ " send_sock \n"); \ |
|
607 |
+ }; \ |
|
608 |
+ break; \ |
|
609 |
+ default: \ |
|
610 |
+ LOG(L_CRIT, "BUG: process_lumps: unknown subst type %d\n", \ |
|
611 |
+ (subst_l)->u.subst); \ |
|
612 |
+ } \ |
|
613 |
+ \ |
|
614 |
+ |
|
615 |
+ |
|
438 | 616 |
|
617 |
+ orig=msg->buf; |
|
439 | 618 |
offset=*new_buf_offs; |
440 | 619 |
s_offset=*orig_offs; |
441 | 620 |
|
442 |
- for (t=l;t;t=t->next){ |
|
621 |
+ for (t=msg->add_rm;t;t=t->next){ |
|
443 | 622 |
switch(t->op){ |
444 | 623 |
case LUMP_ADD: |
624 |
+ case LUMP_ADD_SUBST: |
|
445 | 625 |
/* just add it here! */ |
446 | 626 |
/* process before */ |
447 | 627 |
for(r=t->before;r;r=r->before){ |
... | ... |
@@ -451,6 +631,9 @@ static inline void process_lumps( struct lump* l, char* new_buf, |
451 | 631 |
memcpy(new_buf+offset, r->u.value, r->len); |
452 | 632 |
offset+=r->len; |
453 | 633 |
break; |
634 |
+ case LUMP_ADD_SUBST: |
|
635 |
+ SUBST_LUMP(r); |
|
636 |
+ break; |
|
454 | 637 |
default: |
455 | 638 |
/* only ADD allowed for before/after */ |
456 | 639 |
LOG(L_CRIT, "BUG:process_lumps: " |
... | ... |
@@ -458,8 +641,12 @@ static inline void process_lumps( struct lump* l, char* new_buf, |
458 | 641 |
} |
459 | 642 |
} |
460 | 643 |
/* copy "main" part */ |
461 |
- memcpy(new_buf+offset, t->u.value, t->len); |
|
462 |
- offset+=t->len; |
|
644 |
+ if(t->op==LUMP_ADD){ |
|
645 |
+ memcpy(new_buf+offset, t->u.value, t->len); |
|
646 |
+ offset+=t->len; |
|
647 |
+ }else{ |
|
648 |
+ SUBST_LUMP(t); |
|
649 |
+ } |
|
463 | 650 |
/* process after */ |
464 | 651 |
for(r=t->after;r;r=r->after){ |
465 | 652 |
switch (r->op){ |
... | ... |
@@ -468,6 +655,9 @@ static inline void process_lumps( struct lump* l, char* new_buf, |
468 | 655 |
memcpy(new_buf+offset, r->u.value, r->len); |
469 | 656 |
offset+=r->len; |
470 | 657 |
break; |
658 |
+ case LUMP_ADD_SUBST: |
|
659 |
+ SUBST_LUMP(r); |
|
660 |
+ break; |
|
471 | 661 |
default: |
472 | 662 |
/* only ADD allowed for before/after */ |
473 | 663 |
LOG(L_CRIT, "BUG:process_lumps: " |
... | ... |
@@ -499,6 +689,9 @@ static inline void process_lumps( struct lump* l, char* new_buf, |
499 | 689 |
memcpy(new_buf+offset, r->u.value, r->len); |
500 | 690 |
offset+=r->len; |
501 | 691 |
break; |
692 |
+ case LUMP_ADD_SUBST: |
|
693 |
+ SUBST_LUMP(r); |
|
694 |
+ break; |
|
502 | 695 |
default: |
503 | 696 |
/* only ADD allowed for before/after */ |
504 | 697 |
LOG(L_CRIT, "BUG:process_lumps: " |
... | ... |
@@ -518,6 +711,9 @@ static inline void process_lumps( struct lump* l, char* new_buf, |
518 | 711 |
memcpy(new_buf+offset, r->u.value, r->len); |
519 | 712 |
offset+=r->len; |
520 | 713 |
break; |
714 |
+ case LUMP_ADD_SUBST: |
|
715 |
+ SUBST_LUMP(r); |
|
716 |
+ break; |
|
521 | 717 |
default: |
522 | 718 |
/* only ADD allowed for before/after */ |
523 | 719 |
LOG(L_CRIT, "BUG:process_lumps: " |
... | ... |
@@ -686,7 +882,7 @@ skip_clen: |
686 | 882 |
#endif |
687 | 883 |
|
688 | 884 |
/* compute new msg len and fix overlapping zones*/ |
689 |
- new_len=len+lumps_len(msg->add_rm); |
|
885 |
+ new_len=len+lumps_len(msg, send_sock); |
|
690 | 886 |
|
691 | 887 |
if (msg->new_uri.s){ |
692 | 888 |
uri_len=msg->new_uri.len; |
... | ... |
@@ -713,7 +909,7 @@ skip_clen: |
713 | 909 |
} |
714 | 910 |
new_buf[new_len]=0; |
715 | 911 |
/* copy msg adding/removing lumps */ |
716 |
- process_lumps(msg->add_rm, new_buf, &offset, buf, &s_offset); |
|
912 |
+ process_lumps(msg, new_buf, &offset, &s_offset, send_sock); |
|
717 | 913 |
/* copy the rest of the message */ |
718 | 914 |
memcpy(new_buf+offset, buf+s_offset, len-s_offset); |
719 | 915 |
new_buf[new_len]=0; |
... | ... |
@@ -802,7 +998,7 @@ skip_clen: |
802 | 998 |
#endif |
803 | 999 |
|
804 | 1000 |
/* remove the first via*/ |
805 |
- if (del_lump( &(msg->repl_add_rm), via_offset, via_len, HDR_VIA)==0){ |
|
1001 |
+ if (del_lump( &(msg->add_rm), via_offset, via_len, HDR_VIA)==0){ |
|
806 | 1002 |
LOG(L_ERR, "build_res_buf_from_sip_res: error trying to remove first" |
807 | 1003 |
"via\n"); |
808 | 1004 |
goto error; |
... | ... |
@@ -812,7 +1008,7 @@ skip_clen: |
812 | 1008 |
if (clen_len){ |
813 | 1009 |
/* msg->unparsed should point just before the final crlf, |
814 | 1010 |
* parse_headers is called from clen_builder */ |
815 |
- anchor=anchor_lump(&(msg->repl_add_rm), msg->unparsed-buf, 0, |
|
1011 |
+ anchor=anchor_lump(&(msg->add_rm), msg->unparsed-buf, 0, |
|
816 | 1012 |
HDR_CONTENTLENGTH); |
817 | 1013 |
DBG("build_res_from_sip_res: adding content-length: %.*s\n", |
818 | 1014 |
(int)clen_len, clen_buf); |
... | ... |
@@ -822,8 +1018,8 @@ skip_clen: |
822 | 1018 |
goto error_clen; /* free clen_buf*/ |
823 | 1019 |
} |
824 | 1020 |
#endif |
825 |
- new_len=len+lumps_len(msg->repl_add_rm); |
|
826 |
- |
|
1021 |
+ new_len=len+lumps_len(msg, 0); /*FIXME: we don't know the send sock */ |
|
1022 |
+ |
|
827 | 1023 |
DBG(" old size: %d, new size: %d\n", len, new_len); |
828 | 1024 |
new_buf=(char*)pkg_malloc(new_len+1); /* +1 is for debugging |
829 | 1025 |
(\0 to print it )*/ |
... | ... |
@@ -833,9 +1029,7 @@ skip_clen: |
833 | 1029 |
} |
834 | 1030 |
new_buf[new_len]=0; /* debug: print the message */ |
835 | 1031 |
offset=s_offset=0; |
836 |
- process_lumps(msg->repl_add_rm, new_buf, &offset, |
|
837 |
- buf, |
|
838 |
- &s_offset); |
|
1032 |
+ process_lumps(msg, new_buf, &offset, &s_offset, 0); /*FIXME: no send sock*/ |
|
839 | 1033 |
/* copy the rest of the message */ |
840 | 1034 |
memcpy(new_buf+offset, |
841 | 1035 |
buf+s_offset, |
... | ... |
@@ -29,9 +29,10 @@ |
29 | 29 |
* |
30 | 30 |
* History: |
31 | 31 |
* --------- |
32 |
- * 2003-02-28 scratchpad compatibility abandoned (jiri) |
|
33 |
- * 2003-01-29 scrathcpad removed (jiri) |
|
34 |
- * 2003-01-27 next baby-step to removing ZT - PRESERVE_ZT (jiri) |
|
32 |
+ * 2003-02-28 scratchpad compatibility abandoned (jiri) |
|
33 |
+ * 2003-01-29 scrathcpad removed (jiri) |
|
34 |
+ * 2003-01-27 next baby-step to removing ZT - PRESERVE_ZT (jiri) |
|
35 |
+ * 2003-03-31 removed msg->repl_add_rm (andrei) |
|
35 | 36 |
*/ |
36 | 37 |
|
37 | 38 |
|
... | ... |
@@ -553,7 +554,6 @@ void free_sip_msg(struct sip_msg* msg) |
553 | 554 |
if (msg->new_uri.s) { pkg_free(msg->new_uri.s); msg->new_uri.len=0; } |
554 | 555 |
if (msg->headers) free_hdr_field_lst(msg->headers); |
555 | 556 |
if (msg->add_rm) free_lump_list(msg->add_rm); |
556 |
- if (msg->repl_add_rm) free_lump_list(msg->repl_add_rm); |
|
557 | 557 |
if (msg->reply_lump) free_reply_lump(msg->reply_lump); |
558 | 558 |
/* don't free anymore -- now a pointer to a static buffer */ |
559 | 559 |
# ifdef DYN_BUF |
... | ... |
@@ -26,10 +26,11 @@ |
26 | 26 |
* |
27 | 27 |
* History |
28 | 28 |
* ------- |
29 |
- * 2003-03-06 enum_request_method changed to begin with 1; |
|
30 |
- * 0 reserved for invalid values; (jiri) |
|
31 |
- * 2003-02-28 scratchpad compatibility abandoned (jiri) |
|
32 |
- * 2003-01-28 removed scratchpad (jiri) |
|
29 |
+ * 2003-03-06 enum_request_method changed to begin with 1; |
|
30 |
+ * 0 reserved for invalid values; (jiri) |
|
31 |
+ * 2003-02-28 scratchpad compatibility abandoned (jiri) |
|
32 |
+ * 2003-01-28 removed scratchpad (jiri) |
|
33 |
+ * 2003-03-31 removed sip_msg->repl_add_rm (andrei) |
|
33 | 34 |
*/ |
34 | 35 |
|
35 | 36 |
|
... | ... |
@@ -141,8 +142,7 @@ struct sip_msg { |
141 | 142 |
int parsed_uri_ok; /* 1 if parsed_uri is valid, 0 if not */ |
142 | 143 |
struct sip_uri parsed_uri; /* speed-up > keep here the parsed uri*/ |
143 | 144 |
|
144 |
- struct lump* add_rm; /* used for all the forwarded requests */ |
|
145 |
- struct lump* repl_add_rm; /* used for all the forwarded replies */ |
|
145 |
+ struct lump* add_rm; /* used for all the forwarded requests/replies */ |
|
146 | 146 |
struct lump_rpl *reply_lump; /* only for localy generated replies !!!*/ |
147 | 147 |
|
148 | 148 |
/* str add_to_branch; |
... | ... |
@@ -34,7 +34,10 @@ |
34 | 34 |
* 2003-02-25 Nagle is disabled if -DDISABLE_NAGLE (andrei) |
35 | 35 |
* 2003-03-29 SO_REUSEADDR before calling bind to allow |
36 | 36 |
* server restart, Nagle set on the (hopefuly) |
37 |
- * correct socket |
|
37 |
+ * correct socket (jiri) |
|
38 |
+ * 2003-03-31 always try to find the corresponding tcp listen socket for |
|
39 |
+ * a temp. socket and store in in *->bind_address: added |
|
40 |
+ * find_tcp_si, modified tcpconn_connect (andrei) |
|
38 | 41 |
*/ |
39 | 42 |
|
40 | 43 |
|
... | ... |
@@ -149,9 +152,28 @@ error: |
149 | 152 |
|
150 | 153 |
|
151 | 154 |
|
155 |
+ |
|
156 |
+struct socket_info* find_tcp_si(union sockaddr_union* s) |
|
157 |
+{ |
|
158 |
+ int r; |
|
159 |
+ struct ip_addr ip; |
|
160 |
+ |
|
161 |
+ su2ip_addr(&ip, s); |
|
162 |
+ for (r=0; r<sock_no; r++) |
|
163 |
+ if (ip_addr_cmp(&ip, &tcp_info[r].address)){ |
|
164 |
+ /* found it, we use first match */ |
|
165 |
+ return &tcp_info[r]; |
|
166 |
+ } |
|
167 |
+ return 0; /* no match */ |
|
168 |
+} |
|
169 |
+ |
|
170 |
+ |
|
152 | 171 |
struct tcp_connection* tcpconn_connect(union sockaddr_union* server) |
153 | 172 |
{ |
154 | 173 |
int s; |
174 |
+ struct socket_info* si; |
|
175 |
+ union sockaddr_union my_name; |
|
176 |
+ int my_name_len; |
|
155 | 177 |
#ifdef DISABLE_NAGLE |
156 | 178 |
int flag; |
157 | 179 |
#endif |
... | ... |
@@ -179,7 +201,22 @@ struct tcp_connection* tcpconn_connect(union sockaddr_union* server) |
179 | 201 |
errno, strerror(errno)); |
180 | 202 |
goto error; |
181 | 203 |
} |
182 |
- return tcpconn_new(s, server, 0); /*FIXME: set sock idx! */ |
|
204 |
+ my_name_len=sizeof(my_name); |
|
205 |
+ if (getsockname(s, &my_name.s, &my_name_len)!=0){ |
|
206 |
+ LOG(L_ERR, "ERROR: tcp_connect: getsockname failed: %s(%d)\n", |
|
207 |
+ strerror(errno), errno); |
|
208 |
+ si=0; /* try to go on */ |
|
209 |
+ } |
|
210 |
+ si=find_tcp_si(&my_name); |
|
211 |
+ if (si==0){ |
|
212 |
+ LOG(L_ERR, "ERROR: tcp_connect: could not find coresponding" |
|
213 |
+ " listening socket, using default...\n"); |
|
214 |
+ if (server->s.sa_family==AF_INET) si=sendipv4_tcp; |
|
215 |
+#ifdef USE_IPV6 |
|
216 |
+ else si=sendipv6_tcp; |
|
217 |
+#endif |
|
218 |
+ } |
|
219 |
+ return tcpconn_new(s, server, si); /*FIXME: set sock idx! */ |
|
183 | 220 |
error: |
184 | 221 |
return 0; |
185 | 222 |
} |