- build conditional uri adding socket name in 'sn' param
... | ... |
@@ -108,6 +108,9 @@ |
108 | 108 |
#define COMP_PARAM ";comp=" |
109 | 109 |
#define COMP_PARAM_LEN (sizeof(COMP_PARAM)-1) |
110 | 110 |
|
111 |
+#define SOCKNAME_PARAM ";sn=" |
|
112 |
+#define SOCKNAME_PARAM_LEN (sizeof(SOCKNAME_PARAM)-1) |
|
113 |
+ |
|
111 | 114 |
#define SIGCOMP_NAME "sigcomp" |
112 | 115 |
#define SIGCOMP_NAME_LEN (sizeof(SIGCOMP_NAME)-1) |
113 | 116 |
|
... | ... |
@@ -35,11 +35,12 @@ |
35 | 35 |
|
36 | 36 |
|
37 | 37 |
enum lump_op { LUMP_NOP=0, LUMP_DEL, LUMP_ADD, LUMP_ADD_SUBST, LUMP_ADD_OPT }; |
38 |
-enum lump_subst{ SUBST_NOP=0, /* do nothing */ |
|
39 |
- SUBST_RCV_IP, SUBST_SND_IP, /* add ip address */ |
|
40 |
- SUBST_RCV_PORT, SUBST_SND_PORT, /* add port no */ |
|
41 |
- SUBST_RCV_PROTO, SUBST_SND_PROTO,/* add protocol(udp,tcp,tls)*/ |
|
42 |
- SUBST_RCV_ALL, SUBST_SND_ALL /* ip:port;transport=proto */ |
|
38 |
+enum lump_subst{ SUBST_NOP=0, /* do nothing */ |
|
39 |
+ SUBST_RCV_IP, SUBST_SND_IP, /* add ip address */ |
|
40 |
+ SUBST_RCV_PORT, SUBST_SND_PORT, /* add port no */ |
|
41 |
+ SUBST_RCV_PROTO, SUBST_SND_PROTO, /* add protocol(udp,tcp,tls)*/ |
|
42 |
+ SUBST_RCV_ALL, SUBST_SND_ALL, /* ip:port;transport=proto */ |
|
43 |
+ SUBST_RCV_ALL_EX, SUBST_SND_ALL_EX /* ip:port;transport=proto;sn=xyz */ |
|
43 | 44 |
}; |
44 | 45 |
/* Where: |
45 | 46 |
SND = sending, e.g the src ip of the outgoing message |
... | ... |
@@ -592,7 +592,7 @@ static inline int lumps_len(struct sip_msg* msg, struct lump* lumps, |
592 | 592 |
#define RCVCOMP_LUMP_LEN |
593 | 593 |
#define SENDCOMP_LUMP_LEN |
594 | 594 |
#endif /*USE_COMP */ |
595 |
- |
|
595 |
+ |
|
596 | 596 |
#define SUBST_LUMP_LEN(subst_l) \ |
597 | 597 |
switch((subst_l)->u.subst){ \ |
598 | 598 |
case SUBST_RCV_IP: \ |
... | ... |
@@ -644,6 +644,7 @@ static inline int lumps_len(struct sip_msg* msg, struct lump* lumps, |
644 | 644 |
}; \ |
645 | 645 |
break; \ |
646 | 646 |
case SUBST_RCV_ALL: \ |
647 |
+ case SUBST_RCV_ALL_EX: \ |
|
647 | 648 |
if (msg->rcv.bind_address){ \ |
648 | 649 |
new_len+=recv_address_str->len; \ |
649 | 650 |
if ((msg->rcv.bind_address->address.af==AF_INET6)\ |
... | ... |
@@ -679,6 +680,11 @@ static inline int lumps_len(struct sip_msg* msg, struct lump* lumps, |
679 | 680 |
LM_CRIT("unknown proto %d\n", \ |
680 | 681 |
msg->rcv.bind_address->proto); \ |
681 | 682 |
}\ |
683 |
+ if((subst_l)->u.subst==SUBST_RCV_ALL_EX \ |
|
684 |
+ && msg->rcv.bind_address->sockname.len>0) { \ |
|
685 |
+ new_len+=SOCKNAME_PARAM_LEN \ |
|
686 |
+ + msg->rcv.bind_address->sockname.len; \ |
|
687 |
+ } \ |
|
682 | 688 |
RCVCOMP_LUMP_LEN \ |
683 | 689 |
}else{ \ |
684 | 690 |
/* FIXME */ \ |
... | ... |
@@ -732,6 +738,7 @@ static inline int lumps_len(struct sip_msg* msg, struct lump* lumps, |
732 | 738 |
}; \ |
733 | 739 |
break; \ |
734 | 740 |
case SUBST_SND_ALL: \ |
741 |
+ case SUBST_SND_ALL_EX: \ |
|
735 | 742 |
if (send_sock){ \ |
736 | 743 |
new_len+=send_address_str->len; \ |
737 | 744 |
if ((send_sock->address.af==AF_INET6) && \ |
... | ... |
@@ -767,6 +774,11 @@ static inline int lumps_len(struct sip_msg* msg, struct lump* lumps, |
767 | 774 |
default: \ |
768 | 775 |
LM_CRIT("unknown proto %d\n", send_sock->proto); \ |
769 | 776 |
}\ |
777 |
+ if((subst_l)->u.subst==SUBST_SND_ALL_EX \ |
|
778 |
+ && send_sock->sockname.len>0) { \ |
|
779 |
+ new_len+=SOCKNAME_PARAM_LEN \ |
|
780 |
+ + send_sock->sockname.len; \ |
|
781 |
+ } \ |
|
770 | 782 |
SENDCOMP_LUMP_LEN \ |
771 | 783 |
}else{ \ |
772 | 784 |
/* FIXME */ \ |
... | ... |
@@ -1003,6 +1015,7 @@ void process_lumps( struct sip_msg* msg, |
1003 | 1015 |
}; \ |
1004 | 1016 |
break; \ |
1005 | 1017 |
case SUBST_RCV_ALL: \ |
1018 |
+ case SUBST_RCV_ALL_EX: \ |
|
1006 | 1019 |
if (msg->rcv.bind_address){ \ |
1007 | 1020 |
/* address */ \ |
1008 | 1021 |
if ((msg->rcv.bind_address->address.af==AF_INET6)\ |
... | ... |
@@ -1066,6 +1079,15 @@ void process_lumps( struct sip_msg* msg, |
1066 | 1079 |
default: \ |
1067 | 1080 |
LM_CRIT("unknown proto %d\n", msg->rcv.bind_address->proto); \ |
1068 | 1081 |
} \ |
1082 |
+ if((subst_l)->u.subst==SUBST_RCV_ALL_EX \ |
|
1083 |
+ && msg->rcv.bind_address->sockname.len>0) { \ |
|
1084 |
+ memcpy(new_buf+offset, SOCKNAME_PARAM, \ |
|
1085 |
+ SOCKNAME_PARAM_LEN); \ |
|
1086 |
+ offset+=SOCKNAME_PARAM_LEN; \ |
|
1087 |
+ memcpy(new_buf+offset, msg->rcv.bind_address->sockname.s, \ |
|
1088 |
+ msg->rcv.bind_address->sockname.len); \ |
|
1089 |
+ offset+=msg->rcv.bind_address->sockname.len; \ |
|
1090 |
+ } \ |
|
1069 | 1091 |
RCVCOMP_PARAM_ADD \ |
1070 | 1092 |
}else{ \ |
1071 | 1093 |
/*FIXME*/ \ |
... | ... |
@@ -1101,6 +1123,7 @@ void process_lumps( struct sip_msg* msg, |
1101 | 1123 |
}; \ |
1102 | 1124 |
break; \ |
1103 | 1125 |
case SUBST_SND_ALL: \ |
1126 |
+ case SUBST_SND_ALL_EX: \ |
|
1104 | 1127 |
if (send_sock){ \ |
1105 | 1128 |
/* address */ \ |
1106 | 1129 |
if ((send_sock->address.af==AF_INET6)\ |
... | ... |
@@ -1164,6 +1187,15 @@ void process_lumps( struct sip_msg* msg, |
1164 | 1187 |
default: \ |
1165 | 1188 |
LM_CRIT("unknown proto %d\n", send_sock->proto); \ |
1166 | 1189 |
} \ |
1190 |
+ if((subst_l)->u.subst==SUBST_SND_ALL_EX \ |
|
1191 |
+ && send_sock->sockname.len>0) { \ |
|
1192 |
+ memcpy(new_buf+offset, SOCKNAME_PARAM, \ |
|
1193 |
+ SOCKNAME_PARAM_LEN); \ |
|
1194 |
+ offset+=SOCKNAME_PARAM_LEN; \ |
|
1195 |
+ memcpy(new_buf+offset, send_sock->sockname.s, \ |
|
1196 |
+ send_sock->sockname.len); \ |
|
1197 |
+ offset+=send_sock->sockname.len; \ |
|
1198 |
+ } \ |
|
1167 | 1199 |
SENDCOMP_PARAM_ADD \ |
1168 | 1200 |
}else{ \ |
1169 | 1201 |
/*FIXME*/ \ |