... | ... |
@@ -79,9 +79,12 @@ |
79 | 79 |
#define CRLF "\r\n" |
80 | 80 |
#define CRLF_LEN 2 |
81 | 81 |
|
82 |
-#define RECEIVED ";received=" |
|
82 |
+#define RECEIVED ";received=" |
|
83 | 83 |
#define RECEIVED_LEN 10 |
84 | 84 |
|
85 |
+#define TRANSPORT_PARAM ";transport=" |
|
86 |
+#define TRANSPORT_PARAM_LEN 11 |
|
87 |
+ |
|
85 | 88 |
#define TOTAG_TOKEN ";tag=" |
86 | 89 |
#define TOTAG_TOKEN_LEN (sizeof(TOTAG_TOKEN)-1) |
87 | 90 |
|
... | ... |
@@ -31,6 +31,9 @@ |
31 | 31 |
* 2003-01-29 s/int/enum ... more convenient for gdb (jiri) |
32 | 32 |
* 2003-03-31 added subst lumps -- they expand in ip addr, port a.s.o (andrei) |
33 | 33 |
* 2003-04-01 added opt (condition) lumps (andrei) |
34 |
+ * 2003-04-02 added more subst lumps: SUBST_{SND,RCV}_ALL |
|
35 |
+ * => ip:port;transport=proto (andrei) |
|
36 |
+ * |
|
34 | 37 |
*/ |
35 | 38 |
|
36 | 39 |
|
... | ... |
@@ -42,12 +45,15 @@ enum lump_op { LUMP_NOP=0, LUMP_DEL, LUMP_ADD, LUMP_ADD_SUBST, LUMP_ADD_OPT }; |
42 | 45 |
enum lump_subst{ SUBST_NOP=0, /* do nothing */ |
43 | 46 |
SUBST_RCV_IP, SUBST_SND_IP, /* add ip address */ |
44 | 47 |
SUBST_RCV_PORT, SUBST_SND_PORT, /* add port no */ |
45 |
- SUBST_RCV_PROTO, SUBST_SND_PROTO /* add protocol */ |
|
48 |
+ SUBST_RCV_PROTO, SUBST_SND_PROTO,/* add protocol(udp,tcp,tls)*/ |
|
49 |
+ SUBST_RCV_ALL, SUBST_SND_ALL /* ip:port;transport=proto */ |
|
46 | 50 |
}; |
47 | 51 |
/* Where: |
48 | 52 |
SND = sending, e.g the src ip of the outgoing message |
49 | 53 |
RCV = received e.g the dst ip of the original incoming msg, |
50 | 54 |
or the ip of the ser socket on which the msg was received |
55 |
+ For SUBST_{RCV,SND}_ALL, :port is added only if port!=5060 |
|
56 |
+ and transport=proto only if proto!=udp |
|
51 | 57 |
*/ |
52 | 58 |
|
53 | 59 |
enum lump_conditions { COND_FALSE, /* always false */ |
... | ... |
@@ -44,6 +44,8 @@ |
44 | 44 |
* 2003-03-18 killed the build_warning snprintf (andrei) |
45 | 45 |
* 2003-03-31 added subst lump support (andrei) |
46 | 46 |
* 2003-04-01 added opt (conditional) lump support (andrei) |
47 |
+ * 2003-04-02 added more subst lumps: SUBST_{SND,RCV}_ALL |
|
48 |
+ * => ip:port;transport=proto (andrei) |
|
47 | 49 |
* |
48 | 50 |
*/ |
49 | 51 |
|
... | ... |
@@ -453,7 +455,25 @@ static inline int lumps_len(struct sip_msg* msg, struct socket_info* send_sock) |
453 | 455 |
break; \ |
454 | 456 |
case SUBST_RCV_PROTO: \ |
455 | 457 |
if (msg->rcv.bind_address){ \ |
456 |
- new_len+=send_sock->port_no_str.len; \ |
|
458 |
+ new_len+=3; \ |
|
459 |
+ }else{ \ |
|
460 |
+ /* FIXME */ \ |
|
461 |
+ LOG(L_CRIT, "FIXME: null bind_address\n"); \ |
|
462 |
+ }; \ |
|
463 |
+ break; \ |
|
464 |
+ case SUBST_RCV_ALL: \ |
|
465 |
+ if (msg->rcv.bind_address){ \ |
|
466 |
+ new_len+=msg->rcv.bind_address->address_str.len; \ |
|
467 |
+ if (msg->rcv.bind_address->address.af!=AF_INET) \ |
|
468 |
+ new_len+=2; \ |
|
469 |
+ if (msg->rcv.bind_address->port_no!=SIP_PORT){ \ |
|
470 |
+ /* add :port_no */ \ |
|
471 |
+ new_len+=1+msg->rcv.bind_address->port_no_str.len; \ |
|
472 |
+ }\ |
|
473 |
+ if(msg->rcv.bind_address->proto!=PROTO_UDP) {\ |
|
474 |
+ /*add;transport=xxx*/ \ |
|
475 |
+ new_len+=TRANSPORT_PARAM_LEN+3; \ |
|
476 |
+ }\ |
|
457 | 477 |
}else{ \ |
458 | 478 |
/* FIXME */ \ |
459 | 479 |
LOG(L_CRIT, "FIXME: null bind_address\n"); \ |
... | ... |
@@ -485,6 +505,25 @@ static inline int lumps_len(struct sip_msg* msg, struct socket_info* send_sock) |
485 | 505 |
" null send_sock\n"); \ |
486 | 506 |
}; \ |
487 | 507 |
break; \ |
508 |
+ case SUBST_SND_ALL: \ |
|
509 |
+ if (send_sock){ \ |
|
510 |
+ new_len+=send_sock->address_str.len; \ |
|
511 |
+ if (send_sock->address.af!=AF_INET) \ |
|
512 |
+ new_len+=2; \ |
|
513 |
+ if (send_sock->port_no!=SIP_PORT){ \ |
|
514 |
+ /* add :port_no */ \ |
|
515 |
+ new_len+=1+send_sock->port_no_str.len; \ |
|
516 |
+ }\ |
|
517 |
+ if(send_sock->proto!=PROTO_UDP) {\ |
|
518 |
+ /*add;transport=xxx*/ \ |
|
519 |
+ new_len+=TRANSPORT_PARAM_LEN+3; \ |
|
520 |
+ }\ |
|
521 |
+ }else{ \ |
|
522 |
+ /* FIXME */ \ |
|
523 |
+ LOG(L_CRIT, "FIXME: lumps_len called with" \ |
|
524 |
+ " null send_sock\n"); \ |
|
525 |
+ }; \ |
|
526 |
+ break; \ |
|
488 | 527 |
case SUBST_NOP: /* do nothing */ \ |
489 | 528 |
break; \ |
490 | 529 |
default: \ |
... | ... |
@@ -626,6 +665,53 @@ static inline void process_lumps( struct sip_msg* msg, |
626 | 665 |
LOG(L_CRIT, "FIXME: process_lumps: null bind_address\n"); \ |
627 | 666 |
}; \ |
628 | 667 |
break; \ |
668 |
+ case SUBST_RCV_ALL: \ |
|
669 |
+ if (msg->rcv.bind_address){ \ |
|
670 |
+ /* address */ \ |
|
671 |
+ if (msg->rcv.bind_address->address.af!=AF_INET){\ |
|
672 |
+ new_buf[offset]='['; offset++; \ |
|
673 |
+ }\ |
|
674 |
+ memcpy(new_buf+offset, msg->rcv.bind_address->address_str.s, \ |
|
675 |
+ msg->rcv.bind_address->address_str.len); \ |
|
676 |
+ offset+=msg->rcv.bind_address->address_str.len; \ |
|
677 |
+ if (msg->rcv.bind_address->address.af!=AF_INET){\ |
|
678 |
+ new_buf[offset]=']'; offset++; \ |
|
679 |
+ }\ |
|
680 |
+ /* :port */ \ |
|
681 |
+ if (msg->rcv.bind_address->port_no!=SIP_PORT){ \ |
|
682 |
+ new_buf[offset]=':'; offset++; \ |
|
683 |
+ memcpy(new_buf+offset, \ |
|
684 |
+ msg->rcv.bind_address->port_no_str.s, \ |
|
685 |
+ msg->rcv.bind_address->port_no_str.len); \ |
|
686 |
+ offset+=msg->rcv.bind_address->port_no_str.len; \ |
|
687 |
+ }\ |
|
688 |
+ switch(msg->rcv.bind_address->proto){ \ |
|
689 |
+ case PROTO_NONE: \ |
|
690 |
+ case PROTO_UDP: \ |
|
691 |
+ break; /* nothing to do, udp is default*/ \ |
|
692 |
+ case PROTO_TCP: \ |
|
693 |
+ memcpy(new_buf+offset, TRANSPORT_PARAM, \ |
|
694 |
+ TRANSPORT_PARAM_LEN); \ |
|
695 |
+ offset+=TRANSPORT_PARAM_LEN; \ |
|
696 |
+ memcpy(new_buf+offset, "tcp", 3); \ |
|
697 |
+ offset+=3; \ |
|
698 |
+ break; \ |
|
699 |
+ case PROTO_TLS: \ |
|
700 |
+ memcpy(new_buf+offset, TRANSPORT_PARAM, \ |
|
701 |
+ TRANSPORT_PARAM_LEN); \ |
|
702 |
+ offset+=TRANSPORT_PARAM_LEN; \ |
|
703 |
+ memcpy(new_buf+offset, "tls", 3); \ |
|
704 |
+ offset+=3; \ |
|
705 |
+ break; \ |
|
706 |
+ default: \ |
|
707 |
+ LOG(L_CRIT, "BUG: process_lumps: unknown proto %d\n", \ |
|
708 |
+ msg->rcv.bind_address->proto); \ |
|
709 |
+ } \ |
|
710 |
+ }else{ \ |
|
711 |
+ /*FIXME*/ \ |
|
712 |
+ LOG(L_CRIT, "FIXME: process_lumps: null bind_address\n"); \ |
|
713 |
+ }; \ |
|
714 |
+ break; \ |
|
629 | 715 |
case SUBST_SND_IP: \ |
630 | 716 |
if (send_sock){ \ |
631 | 717 |
if (send_sock->address.af!=AF_INET){\ |
... | ... |
@@ -654,6 +740,52 @@ static inline void process_lumps( struct sip_msg* msg, |
654 | 740 |
" null send_sock\n"); \ |
655 | 741 |
}; \ |
656 | 742 |
break; \ |
743 |
+ case SUBST_SND_ALL: \ |
|
744 |
+ if (send_sock){ \ |
|
745 |
+ /* address */ \ |
|
746 |
+ if (send_sock->address.af!=AF_INET){\ |
|
747 |
+ new_buf[offset]='['; offset++; \ |
|
748 |
+ }\ |
|
749 |
+ memcpy(new_buf+offset, send_sock->address_str.s, \ |
|
750 |
+ send_sock->address_str.len); \ |
|
751 |
+ offset+=send_sock->address_str.len; \ |
|
752 |
+ if (send_sock->address.af!=AF_INET){\ |
|
753 |
+ new_buf[offset]=']'; offset++; \ |
|
754 |
+ }\ |
|
755 |
+ /* :port */ \ |
|
756 |
+ if (send_sock->port_no!=SIP_PORT){ \ |
|
757 |
+ new_buf[offset]=':'; offset++; \ |
|
758 |
+ memcpy(new_buf+offset, send_sock->port_no_str.s, \ |
|
759 |
+ send_sock->port_no_str.len); \ |
|
760 |
+ offset+=send_sock->port_no_str.len; \ |
|
761 |
+ }\ |
|
762 |
+ switch(send_sock->proto){ \ |
|
763 |
+ case PROTO_NONE: \ |
|
764 |
+ case PROTO_UDP: \ |
|
765 |
+ break; /* nothing to do, udp is default*/ \ |
|
766 |
+ case PROTO_TCP: \ |
|
767 |
+ memcpy(new_buf+offset, TRANSPORT_PARAM, \ |
|
768 |
+ TRANSPORT_PARAM_LEN); \ |
|
769 |
+ offset+=TRANSPORT_PARAM_LEN; \ |
|
770 |
+ memcpy(new_buf+offset, "tcp", 3); \ |
|
771 |
+ offset+=3; \ |
|
772 |
+ break; \ |
|
773 |
+ case PROTO_TLS: \ |
|
774 |
+ memcpy(new_buf+offset, TRANSPORT_PARAM, \ |
|
775 |
+ TRANSPORT_PARAM_LEN); \ |
|
776 |
+ offset+=TRANSPORT_PARAM_LEN; \ |
|
777 |
+ memcpy(new_buf+offset, "tls", 3); \ |
|
778 |
+ offset+=3; \ |
|
779 |
+ break; \ |
|
780 |
+ default: \ |
|
781 |
+ LOG(L_CRIT, "BUG: process_lumps: unknown proto %d\n", \ |
|
782 |
+ send_sock->proto); \ |
|
783 |
+ } \ |
|
784 |
+ }else{ \ |
|
785 |
+ /*FIXME*/ \ |
|
786 |
+ LOG(L_CRIT, "FIXME: process_lumps: null bind_address\n"); \ |
|
787 |
+ }; \ |
|
788 |
+ break; \ |
|
657 | 789 |
case SUBST_RCV_PROTO: \ |
658 | 790 |
if (msg->rcv.bind_address){ \ |
659 | 791 |
switch(msg->rcv.bind_address->proto){ \ |
... | ... |
@@ -676,7 +808,8 @@ static inline void process_lumps( struct sip_msg* msg, |
676 | 808 |
} \ |
677 | 809 |
}else{ \ |
678 | 810 |
/*FIXME*/ \ |
679 |
- LOG(L_CRIT, "FIXME: process lumps: null bind_address\n"); \ |
|
811 |
+ LOG(L_CRIT, "FIXME: process_lumps: called with null" \ |
|
812 |
+ " send_sock \n"); \ |
|
680 | 813 |
}; \ |
681 | 814 |
break; \ |
682 | 815 |
case SUBST_SND_PROTO: \ |
... | ... |
@@ -1589,12 +1722,12 @@ char* via_builder( unsigned int *len, |
1589 | 1722 |
|
1590 | 1723 |
via_len=MY_VIA_LEN+send_sock->address_str.len; /*space included in MY_VIA*/ |
1591 | 1724 |
|
1592 |
- memcpy(line_buf, MY_VIA, MY_VIA_LEN-4); /* without "UPD " */ |
|
1593 |
- if (proto==PROTO_UDP) |
|
1594 |
- memcpy(line_buf+MY_VIA_LEN-4, "UDP ", 4); |
|
1595 |
- else if (proto==PROTO_TCP) |
|
1725 |
+ memcpy(line_buf, MY_VIA, MY_VIA_LEN); |
|
1726 |
+ if (proto==PROTO_UDP){ |
|
1727 |
+ /* dop nothing */ |
|
1728 |
+ }else if (proto==PROTO_TCP){ |
|
1596 | 1729 |
memcpy(line_buf+MY_VIA_LEN-4, "TCP ", 4); |
1597 |
- else{ |
|
1730 |
+ }else{ |
|
1598 | 1731 |
LOG(L_CRIT, "BUG: via_builder: unknown proto %d\n", proto); |
1599 | 1732 |
return 0; |
1600 | 1733 |
} |