Browse code

rr: new function rr_next_hop_route()

- return 1 (true) if there is a route header for next hop address

Daniel-Constantin Mierla authored on 13/12/2019 15:09:03
Showing 2 changed files
... ...
@@ -893,6 +893,7 @@ static inline int after_loose(struct sip_msg* _m, int preloaded)
893 893
 					uri.len, ZSW(uri.s));
894 894
 			return RR_ERROR;
895 895
 		}
896
+		_m->msg_flags |= FL_ROUTE_ADDR;
896 897
 	} else {
897 898
 #ifdef ENABLE_USER_CHECK
898 899
 		/* check if it the ignored user */
... ...
@@ -80,6 +80,7 @@ static int w_add_rr_param(struct sip_msg *,char *, char *);
80 80
 static int w_check_route_param(struct sip_msg *,char *, char *);
81 81
 static int w_is_direction(struct sip_msg *,char *, char *);
82 82
 static int w_remove_record_route(sip_msg_t*, char*, char*);
83
+static int w_rr_next_hop_route(sip_msg_t *, char *, char *);
83 84
 /* PV functions */
84 85
 static int pv_get_route_uri_f(struct sip_msg *, pv_param_t *, pv_value_t *);
85 86
 static int pv_get_from_tag_initial(sip_msg_t *msg, pv_param_t *param,
... ...
@@ -113,6 +114,8 @@ static cmd_export_t cmds[] = {
113 114
 			REQUEST_ROUTE},
114 115
 	{"remove_record_route",  w_remove_record_route, 0, 0, 0,
115 116
 			REQUEST_ROUTE|FAILURE_ROUTE},
117
+	{"rr_next_hop_route",    (cmd_function)w_rr_next_hop_route,		0, 0, 0,
118
+			ANY_ROUTE},
116 119
 	{"load_rr",              (cmd_function)load_rr, 				0, 0, 0, 0},
117 120
 	{0, 0, 0, 0, 0, 0}
118 121
 };
... ...
@@ -756,6 +759,26 @@ static int pv_get_rdir(sip_msg_t *msg, pv_param_t *param, pv_value_t *res)
756 759
 	}
757 760
 }
758 761
 
762
+
763
+/**
764
+ *
765
+ */
766
+static int ki_rr_next_hop_route(sip_msg_t *msg)
767
+{
768
+	if(msg->msg_flags & FL_ROUTE_ADDR) {
769
+		return 1;
770
+	}
771
+	return -1;
772
+}
773
+
774
+/**
775
+ *
776
+ */
777
+static int w_rr_next_hop_route(sip_msg_t *msg, char *p1, char *p2)
778
+{
779
+	return ki_rr_next_hop_route(msg);
780
+}
781
+
759 782
 /**
760 783
  *
761 784
  */
... ...
@@ -806,6 +829,11 @@ static sr_kemi_t sr_kemi_rr_exports[] = {
806 829
 		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
807 830
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
808 831
 	},
832
+	{ str_init("rr"), str_init("next_hop_route"),
833
+		SR_KEMIP_INT, ki_rr_next_hop_route,
834
+		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
835
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
836
+	},
809 837
 	{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
810 838
 };
811 839
 /* clang-format on */