2
0
Эх сурвалжийг харах

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).
Andrei Pelinescu-Onciul 16 жил өмнө
parent
commit
8fb1a2121e
3 өөрчлөгдсөн 21 нэмэгдсэн , 1 устгасан
  1. 1 1
      action.c
  2. 1 0
      ip_addr.h
  3. 19 0
      parser/msg_parser.h

+ 1 - 1
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;
 

+ 1 - 0
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;
 

+ 19 - 0
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