Module: sip-router Branch: sr_3.0 Commit: 8fb1a2121ebe5c17681e7921cd96d3fe9a5dab80 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=8fb1a212...
Author: Andrei Pelinescu-Onciul andrei@iptel.org Committer: Andrei Pelinescu-Onciul andrei@iptel.org Date: Thu Nov 5 14:43:38 2009 +0100
core: extra flag when forcing a socket
- when forcing a socket set an extra send flag (SND_F_FORCE_SOCKET), so that later we can tell if the socket in the dst structure was forced or not (useful for forcing a specific source ip on tcp or for keeping the forced socket during dns failover in tm). - added set_force_socket(msg, sock) and reset_force_socket(msg) macros that should be used instead of directly setting msg->force_send_socket (they take care of any extra work, like setting/resetting flags).
---
action.c | 2 +- ip_addr.h | 1 + parser/msg_parser.h | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/action.c b/action.c index b8256a7..ddbf445 100644 --- a/action.c +++ b/action.c @@ -1201,7 +1201,7 @@ match_cleanup: ret=E_BUG; goto error; } - msg->force_send_socket=(struct socket_info*)a->val[0].u.data; + set_force_socket(msg, (struct socket_info*)a->val[0].u.data); ret=1; /* continue processing */ break;
diff --git a/ip_addr.h b/ip_addr.h index 355fc77..2983e46 100644 --- a/ip_addr.h +++ b/ip_addr.h @@ -140,6 +140,7 @@ struct receive_info{ /* send flags */ #define SND_F_FORCE_CON_REUSE 1 /* reuse an existing connection or fail */ #define SND_F_CON_CLOSE 2 /* close the connection after sending */ +#define SND_F_FORCE_SOCKET 4 /* send socket in dst is forced */
typedef unsigned char snd_flags_t;
diff --git a/parser/msg_parser.h b/parser/msg_parser.h index ce4c81d..adedddb 100644 --- a/parser/msg_parser.h +++ b/parser/msg_parser.h @@ -467,4 +467,23 @@ int set_path_vector(struct sip_msg* msg, str* path);
void reset_path_vector(struct sip_msg* msg);
+ +/** force a specific send socket for forwarding a request. + * @param msg - sip msg. + * @param fsocket - forced socket, pointer to struct socket_info, can be 0 (in + * which case it's equivalent to reset_force_socket()). + */ +#define set_force_socket(msg, fsocket) \ + do { \ + (msg)->force_send_socket=(fsocket); \ + if ((msg)->force_send_socket) \ + (msg)->fwd_send_flags |= SND_F_FORCE_SOCKET; \ + else \ + (msg)->fwd_send_flags &= ~SND_F_FORCE_SOCKET; \ + } while (0) + +/** reset a previously forced send socket. */ +#define reset_force_socket(msg) set_force_socket(msg, 0) + + #endif