Browse code

uac: allow empty contact addr in rpc add command for uacreg

- it has to be set to .
- contact_addr parameter moved to be last, to be easier to just add to
existing commands

Daniel-Constantin Mierla authored on 09/09/2020 11:20:44
Showing 1 changed files
... ...
@@ -526,7 +526,7 @@ int reg_ht_add(reg_uac_t *reg)
526 526
 		return -1;
527 527
 	}
528 528
 
529
-	if (!reg->contact_addr.s || reg->contact_addr.len == 0) 
529
+	if (!reg->contact_addr.s || reg->contact_addr.len == 0)
530 530
 	{
531 531
 		reg->contact_addr=reg_contact_addr;
532 532
 	}
... ...
@@ -553,7 +553,7 @@ int reg_ht_add(reg_uac_t *reg)
553 553
 	memset(nr, 0, sizeof(reg_uac_t) + len);
554 554
 	nr->expires = reg->expires;
555 555
 	nr->flags   = reg->flags;
556
-	if (reg->reg_delay) 
556
+	if (reg->reg_delay)
557 557
 		nr->reg_delay = reg->reg_delay;
558 558
 	else if (reg_random_delay>0)
559 559
 		nr->reg_delay = kam_rand() % reg_random_delay;
... ...
@@ -594,9 +594,9 @@ int reg_ht_add(reg_uac_t *reg)
594 594
 }
595 595
 
596 596
 
597
- /**
598
-  *
599
-  */
597
+/**
598
+ *
599
+ */
600 600
 int reg_ht_rm(reg_uac_t *reg)
601 601
 {
602 602
 	unsigned int slot1, slot2;
... ...
@@ -2136,8 +2136,8 @@ static void rpc_uac_reg_add(rpc_t* rpc, void* ctx)
2136 2136
 				&reg.expires,
2137 2137
 				&reg.flags,
2138 2138
 				&reg.reg_delay,
2139
-				&reg.contact_addr,
2140
-				&reg.socket
2139
+				&reg.socket,
2140
+				&reg.contact_addr
2141 2141
 			)<1)
2142 2142
 	{
2143 2143
 		rpc->fault(ctx, 400, "Invalid Parameters");
... ...
@@ -2154,6 +2154,10 @@ static void rpc_uac_reg_add(rpc_t* rpc, void* ctx)
2154 2154
 		reg.auth_ha1.len = 0;
2155 2155
 	}
2156 2156
 
2157
+	if(reg.contact_addr.len==1 && reg.contact_addr.s[0] == '.') {
2158
+		reg.contact_addr = reg_contact_addr;
2159
+	}
2160
+
2157 2161
 	if(uac_reg_check_password(&reg) < 0) {
2158 2162
 		rpc->fault(ctx, 500, "Failed to add record - invalid password or ha1");
2159 2163
 		return;