Parcourir la source

registrar(s): by default trust contact received info

- by default trust contact received info (to maintain
  compatibility with old configs).
- the possible settings for the trust_received_flag modparam are:
   * -2 (default) - always trust contact received info (added when
      replicating REGISTERs)
   *  -1 - disable (never trust received info)
   *  >=0 - trust only the messages with the corresponding flag
             set (it can also be a flag name).
Andrei Pelinescu-Onciul il y a 15 ans
Parent
commit
d5b8c86bfa
2 fichiers modifiés avec 17 ajouts et 8 suppressions
  1. 5 2
      modules_s/registrar/reg_mod.c
  2. 12 6
      modules_s/registrar/save.c

+ 5 - 2
modules_s/registrar/reg_mod.c

@@ -67,9 +67,12 @@ int append_branches = 1;              /* If set to 1, lookup will put all contac
 int case_sensitive  = 0;              /* If set to 1, username in aor will be case sensitive */
 int save_nat_flag   = 4;              /* The contact will be marked as behind NAT if this flag is set before calling save */
 int load_nat_flag   = 4;              /* This flag will be set by lookup if a contact is behind NAT*/
-int trust_received_flag = -1;         /* if this flag is set, a contact
+int trust_received_flag = -2;         /* if this flag is set (>=0), a contact
 										 received param. will be trusted
-										 (otherwise it will be ignored) */
+										 (otherwise it will be ignored)
+										 -1 = disable
+										 -2 = trust all.
+									   */
 int min_expires     = 60;             /* Minimum expires the phones are allowed to use in seconds,
 			               * use 0 to switch expires checking off */
 int max_expires     = 0;              /* Minimum expires the phones are allowed to use in seconds,

+ 12 - 6
modules_s/registrar/save.c

@@ -420,8 +420,10 @@ static inline int insert(struct sip_msg* _m, str* aor, contact_t* _c, udomain_t*
 		}
 		
 		send_sock = 0;
-		if (_c->received && (trust_received_flag >=0) &&
-				(isflagset(_m, trust_received_flag) == 1)) {
+		if (_c->received &&
+				(((trust_received_flag >= 0) &&
+					(isflagset(_m, trust_received_flag) == 1)) ||
+				 (trust_received_flag == -2)) ) {
 			recv = &_c->received->body;
 			send_sock = find_send_socket(recv);
 		} else if (flags & FL_NAT && _m->first_line.type == SIP_REQUEST) {
@@ -591,8 +593,10 @@ static inline int update(struct sip_msg* _m, urecord_t* _r, str* aor, contact_t*
 				}
 				
 				send_sock = 0;
-				if (_c->received && (trust_received_flag >=0) &&
-						(isflagset(_m, trust_received_flag) == 1)) {
+				if (_c->received &&
+						(((trust_received_flag >=0 ) &&
+							(isflagset(_m, trust_received_flag) == 1)) ||
+						 (trust_received_flag == -2)) ) {
 					recv = &_c->received->body;
 					send_sock = find_send_socket(recv);
 				} else if (nated & FL_NAT && 
@@ -649,8 +653,10 @@ static inline int update(struct sip_msg* _m, urecord_t* _r, str* aor, contact_t*
 				}
 				
 				send_sock = 0;
-				if (_c->received && (trust_received_flag >=0) &&
-						(isflagset(_m, trust_received_flag) == 1)) {
+				if (_c->received &&
+						(((trust_received_flag >=0 ) &&
+							(isflagset(_m, trust_received_flag) == 1)) ||
+						 (trust_received_flag == -2)) ) {
 					recv = &_c->received->body;
 					send_sock = find_send_socket(recv);
 				} else if (nated & FL_NAT && _m->first_line.type == SIP_REQUEST) {