Browse code

core: support to asign names to listen sockets

- full format:
listen=proto:address:port advertise address:port name string
- example:
listen=udp:10.0.0.10:5060 advertise 1.2.3.4:5060 name "sock1"
- the value for the name has to be enclosed in quotes
- name can be provided also when advertise is not needed

Daniel-Constantin Mierla authored on 02/04/2020 09:35:00
Showing 5 changed files
... ...
@@ -297,6 +297,7 @@ XAVPVIAPARAMS	xavp_via_params
297 297
 XAVPVIAFIELDS	xavp_via_fields
298 298
 LISTEN		listen
299 299
 ADVERTISE	advertise|ADVERTISE
300
+STRNAME		name|NAME
300 301
 ALIAS		alias
301 302
 SR_AUTO_ALIASES	auto_aliases
302 303
 DNS		 dns
... ...
@@ -711,6 +712,7 @@ IMPORTFILE      "import_file"
711 712
 <INITIAL>{XAVPVIAFIELDS}	{ yylval.strval=yytext; return XAVPVIAFIELDS; }
712 713
 <INITIAL>{LISTEN}	{ count(); yylval.strval=yytext; return LISTEN; }
713 714
 <INITIAL>{ADVERTISE}	{ count(); yylval.strval=yytext; return ADVERTISE; }
715
+<INITIAL>{STRNAME}	{ count(); yylval.strval=yytext; return STRNAME; }
714 716
 <INITIAL>{ALIAS}	{ count(); yylval.strval=yytext; return ALIAS; }
715 717
 <INITIAL>{SR_AUTO_ALIASES}	{ count(); yylval.strval=yytext;
716 718
 									return SR_AUTO_ALIASES; }
... ...
@@ -325,6 +325,7 @@ extern char *default_routename;
325 325
 %token XAVPVIAFIELDS
326 326
 %token LISTEN
327 327
 %token ADVERTISE
328
+%token STRNAME
328 329
 %token ALIAS
329 330
 %token SR_AUTO_ALIASES
330 331
 %token DNS
... ...
@@ -1454,6 +1455,18 @@ assign_stm:
1454 1455
 		}
1455 1456
 		free_socket_id_lst($3);
1456 1457
 	}
1458
+	| LISTEN EQUAL id_lst STRNAME STRING {
1459
+		for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next) {
1460
+			if (add_listen_iface_name(lst_tmp->addr_lst->name,
1461
+									lst_tmp->addr_lst->next,
1462
+									lst_tmp->port, lst_tmp->proto, $5,
1463
+									lst_tmp->flags)!=0) {
1464
+				LM_CRIT("cfg. parser: failed to add listen address\n");
1465
+				break;
1466
+			}
1467
+		}
1468
+		free_socket_id_lst($3);
1469
+	}
1457 1470
 	| LISTEN EQUAL id_lst ADVERTISE listen_id COLON NUMBER {
1458 1471
 		for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next) {
1459 1472
 			if (add_listen_advertise_iface(	lst_tmp->addr_lst->name,
... ...
@@ -1467,6 +1480,19 @@ assign_stm:
1467 1480
 		}
1468 1481
 		free_socket_id_lst($3);
1469 1482
 	}
1483
+	| LISTEN EQUAL id_lst ADVERTISE listen_id COLON NUMBER STRNAME STRING {
1484
+		for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next) {
1485
+			if (add_listen_advertise_iface_name(lst_tmp->addr_lst->name,
1486
+									lst_tmp->addr_lst->next,
1487
+									lst_tmp->port, lst_tmp->proto,
1488
+									$5, $7, $9,
1489
+									lst_tmp->flags)!=0) {
1490
+				LM_CRIT("cfg. parser: failed to add listen address\n");
1491
+				break;
1492
+			}
1493
+		}
1494
+		free_socket_id_lst($3);
1495
+	}
1470 1496
 	| LISTEN EQUAL id_lst ADVERTISE listen_id {
1471 1497
 		for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next) {
1472 1498
 			if (add_listen_advertise_iface(	lst_tmp->addr_lst->name,
... ...
@@ -1480,6 +1506,19 @@ assign_stm:
1480 1506
 		}
1481 1507
 		free_socket_id_lst($3);
1482 1508
 	}
1509
+	| LISTEN EQUAL id_lst ADVERTISE listen_id STRNAME STRING {
1510
+		for(lst_tmp=$3; lst_tmp; lst_tmp=lst_tmp->next) {
1511
+			if (add_listen_advertise_iface_name(lst_tmp->addr_lst->name,
1512
+									lst_tmp->addr_lst->next,
1513
+									lst_tmp->port, lst_tmp->proto,
1514
+									$5, 0, $7,
1515
+									lst_tmp->flags)!=0) {
1516
+				LM_CRIT("cfg. parser: failed to add listen address\n");
1517
+				break;
1518
+			}
1519
+		}
1520
+		free_socket_id_lst($3);
1521
+	}
1483 1522
 	| LISTEN EQUAL  error { yyerror("ip address, interface name or"
1484 1523
 									" hostname expected"); }
1485 1524
 	| ALIAS EQUAL  id_lst {
... ...
@@ -116,6 +116,7 @@ typedef struct socket_info {
116 116
 	struct addr_info* addr_info_lst; /* extra addresses (e.g. SCTP mh) */
117 117
 	int workers; /* number of worker processes for this socket */
118 118
 	int workers_tcpidx; /* index of workers in tcp children array */
119
+	str sockname; /* socket name given in config listen value */
119 120
 	struct advertise_info useinfo; /* details to be used in SIP msg */
120 121
 #ifdef USE_MCAST
121 122
 	str mcast; /* name of interface that should join multicast group*/
... ...
@@ -289,13 +289,13 @@ static inline struct socket_info* new_sock_info(	char* name,
289 289
 								struct name_lst* addr_l,
290 290
 								unsigned short port, unsigned short proto,
291 291
 								char *usename, unsigned short useport,
292
-								enum si_flags flags)
292
+								char *sockname, enum si_flags flags)
293 293
 {
294 294
 	struct socket_info* si;
295 295
 	struct name_lst* n;
296 296
 	struct hostent* he;
297 297
 	char *p;
298
-	
298
+
299 299
 	si=(struct socket_info*) pkg_malloc(sizeof(struct socket_info));
300 300
 	if (si==0) goto error;
301 301
 	memset(si, 0, sizeof(struct socket_info));
... ...
@@ -315,6 +315,12 @@ static inline struct socket_info* new_sock_info(	char* name,
315 315
 			goto error;
316 316
 		}
317 317
 	}
318
+	if(sockname!=NULL) {
319
+		si->sockname.len = strlen(sockname);
320
+		si->sockname.s=(char*)pkg_malloc(si->sockname.len+1); /* include \0 */
321
+		if (si->sockname.s==0) { goto error; }
322
+		memcpy(si->sockname.s, sockname, si->sockname.len+1);
323
+	}
318 324
 	if(usename!=NULL)
319 325
 	{
320 326
 		si->useinfo.name.len=strlen(usename);
... ...
@@ -356,8 +362,12 @@ static inline struct socket_info* new_sock_info(	char* name,
356 362
 error:
357 363
 	PKG_MEM_ERROR;
358 364
 	if (si) {
359
-		if(si->name.s)
365
+		if(si->name.s) {
360 366
 			pkg_free(si->name.s);
367
+		}
368
+		if(si->sockname.s) {
369
+			pkg_free(si->sockname.s);
370
+		}
361 371
 		pkg_free(si);
362 372
 	}
363 373
 	return 0;
... ...
@@ -374,6 +384,7 @@ static void free_sock_info(struct socket_info* si)
374 384
 		if(si->port_no_str.s) pkg_free(si->port_no_str.s);
375 385
 		if(si->addr_info_lst) free_addr_info_lst(&si->addr_info_lst);
376 386
 		if(si->sock_str.s) pkg_free(si->sock_str.s);
387
+		if(si->sockname.s) pkg_free(si->sockname.s);
377 388
 		if(si->useinfo.name.s) pkg_free(si->useinfo.name.s);
378 389
 		if(si->useinfo.port_no_str.s) pkg_free(si->useinfo.port_no_str.s);
379 390
 		if(si->useinfo.sock_str.s) pkg_free(si->useinfo.sock_str.s);
... ...
@@ -767,12 +778,13 @@ static struct socket_info* new_sock2list(char* name, struct name_lst* addr_l,
767 778
 									unsigned short port,
768 779
 									unsigned short proto,
769 780
 									char *usename, unsigned short useport,
781
+									char *sockname,
770 782
 									enum si_flags flags,
771 783
 									struct socket_info** list)
772 784
 {
773 785
 	struct socket_info* si;
774 786
 	/* allocates si and si->name in new pkg memory */
775
-	si=new_sock_info(name, addr_l, port, proto, usename, useport, flags);
787
+	si=new_sock_info(name, addr_l, port, proto, usename, useport, sockname, flags);
776 788
 	if (si==0){
777 789
 		LM_ERR("new_sock_info failed\n");
778 790
 		goto error;
... ...
@@ -811,12 +823,13 @@ static struct socket_info* new_sock2list_after(char* name,
811 823
 									unsigned short proto,
812 824
 									char *usename,
813 825
 									unsigned short useport,
826
+									char *sockname,
814 827
 									enum si_flags flags,
815 828
 									struct socket_info* after)
816 829
 {
817 830
 	struct socket_info* si;
818
-	
819
-	si=new_sock_info(name, addr_l, port, proto, usename, useport, flags);
831
+
832
+	si=new_sock_info(name, addr_l, port, proto, usename, useport, sockname, flags);
820 833
 	if (si==0){
821 834
 		LM_ERR("new_sock_info failed\n");
822 835
 		goto error;
... ...
@@ -831,22 +844,22 @@ error:
831 844
 
832 845
 /* adds a sock_info structure to the corresponding proto list
833 846
  * return  0 on success, -1 on error */
834
-int add_listen_advertise_iface(char* name, struct name_lst* addr_l,
847
+int add_listen_advertise_iface_name(char* name, struct name_lst* addr_l,
835 848
 						unsigned short port, unsigned short proto,
836
-						char *usename, unsigned short useport,
849
+						char *usename, unsigned short useport, char *sockname,
837 850
 						enum si_flags flags)
838 851
 {
839 852
 	struct socket_info** list;
840 853
 	unsigned short c_proto;
841 854
 	struct name_lst* a_l;
842 855
 	unsigned short c_port;
843
-	
856
+
844 857
 	c_proto=(proto!=PROTO_NONE)?proto:PROTO_UDP;
845 858
 	do{
846 859
 		list=get_sock_info_list(c_proto);
847 860
 		if (list==0) /* disabled or unknown protocol */
848 861
 			continue;
849
-		
862
+
850 863
 		if (port==0){ /* use default port */
851 864
 			c_port=
852 865
 #ifdef USE_TLS
... ...
@@ -865,15 +878,15 @@ int add_listen_advertise_iface(char* name, struct name_lst* addr_l,
865 878
 		}
866 879
 		if (c_proto!=PROTO_SCTP){
867 880
 			if (new_sock2list(name, 0, c_port, c_proto, usename, useport,
868
-								flags & ~SI_IS_MHOMED, list)==0){
881
+								sockname, flags & ~SI_IS_MHOMED, list)==0){
869 882
 				LM_ERR("new_sock2list failed\n");
870 883
 				goto error;
871 884
 			}
872 885
 			/* add the other addresses in the list as separate sockets
873 886
 			 * since only SCTP can bind to multiple addresses */
874 887
 			for (a_l=addr_l; a_l; a_l=a_l->next){
875
-				if (new_sock2list(a_l->name, 0, c_port, 
876
-									c_proto, usename, useport,
888
+				if (new_sock2list(a_l->name, 0, c_port,
889
+									c_proto, usename, useport, sockname,
877 890
 									flags & ~SI_IS_MHOMED, list)==0){
878 891
 					LM_ERR("new_sock2list failed\n");
879 892
 					goto error;
... ...
@@ -881,7 +894,7 @@ int add_listen_advertise_iface(char* name, struct name_lst* addr_l,
881 894
 			}
882 895
 		}else{
883 896
 			if (new_sock2list(name, addr_l, c_port, c_proto, usename, useport,
884
-						flags, list)==0){
897
+						sockname, flags, list)==0){
885 898
 				LM_ERR("new_sock2list failed\n");
886 899
 				goto error;
887 900
 			}
... ...
@@ -892,14 +905,37 @@ error:
892 905
 	return -1;
893 906
 }
894 907
 
908
+/* adds a sock_info structure to the corresponding proto list
909
+ * return  0 on success, -1 on error */
910
+int add_listen_advertise_iface(char* name, struct name_lst* addr_l,
911
+						unsigned short port, unsigned short proto,
912
+						char *usename, unsigned short useport,
913
+						enum si_flags flags)
914
+{
915
+	return add_listen_advertise_iface_name(name, addr_l, port, proto,
916
+						usename, useport, NULL, flags);
917
+}
918
+
895 919
 /* adds a sock_info structure to the corresponding proto list
896 920
  * return  0 on success, -1 on error */
897 921
 int add_listen_iface(char* name, struct name_lst* addr_l,
898 922
 						unsigned short port, unsigned short proto,
899 923
 						enum si_flags flags)
900 924
 {
901
-	return add_listen_advertise_iface(name, addr_l, port, proto, 0, 0, flags);
925
+	return add_listen_advertise_iface_name(name, addr_l, port, proto, 0, 0, 0,
926
+			flags);
927
+}
928
+
929
+/* adds a sock_info structure to the corresponding proto list
930
+ * return  0 on success, -1 on error */
931
+int add_listen_iface_name(char* name, struct name_lst* addr_l,
932
+						unsigned short port, unsigned short proto, char *sockname,
933
+						enum si_flags flags)
934
+{
935
+	return add_listen_advertise_iface_name(name, addr_l, port, proto, 0, 0,
936
+			sockname, flags);
902 937
 }
938
+
903 939
 #ifdef __OS_linux
904 940
 
905 941
 #include "linux/types.h"
... ...
@@ -1433,14 +1469,14 @@ error:
1433 1469
  */
1434 1470
 static int addr_info_to_si_lst(struct addr_info* ai_lst, unsigned short port,
1435 1471
 								char proto, char *usename,
1436
-								unsigned short useport,
1472
+								unsigned short useport, char *sockname,
1437 1473
 								enum si_flags flags,
1438 1474
 								struct socket_info** list)
1439 1475
 {
1440 1476
 	struct addr_info* ail;
1441
-	
1477
+
1442 1478
 	for (ail=ai_lst; ail; ail=ail->next){
1443
-		if(new_sock2list(ail->name.s, 0, port, proto, usename, useport,
1479
+		if(new_sock2list(ail->name.s, 0, port, proto, usename, useport, sockname,
1444 1480
 					ail->flags | flags, list)==0)
1445 1481
 			return -1;
1446 1482
 	}
... ...
@@ -1449,7 +1485,7 @@ static int addr_info_to_si_lst(struct addr_info* ai_lst, unsigned short port,
1449 1485
 
1450 1486
 
1451 1487
 
1452
-/* insert new elements to a socket_info list after "el", 
1488
+/* insert new elements to a socket_info list after "el",
1453 1489
  * each element is created from addr_info_lst + port, * protocol and flags
1454 1490
  * return 0 on succes, -1 on error
1455 1491
  */
... ...
@@ -1458,15 +1494,17 @@ static int addr_info_to_si_lst_after(struct addr_info* ai_lst,
1458 1494
 										char proto,
1459 1495
 										char *usename,
1460 1496
 										unsigned short useport,
1497
+										char *sockname,
1461 1498
 										enum si_flags flags,
1462 1499
 										struct socket_info* el)
1463 1500
 {
1464 1501
 	struct addr_info* ail;
1465 1502
 	struct socket_info* new_si;
1466
-	
1503
+
1467 1504
 	for (ail=ai_lst; ail; ail=ail->next){
1468 1505
 		if((new_si=new_sock2list_after(ail->name.s, 0, port, proto,
1469
-								usename, useport, ail->flags | flags, el))==0)
1506
+								usename, useport, sockname,
1507
+								ail->flags | flags, el))==0)
1470 1508
 			return -1;
1471 1509
 		el=new_si;
1472 1510
 	}
... ...
@@ -1475,7 +1513,7 @@ static int addr_info_to_si_lst_after(struct addr_info* ai_lst,
1475 1513
 
1476 1514
 
1477 1515
 
1478
-/* fixes a socket list => resolve addresses, 
1516
+/* fixes a socket list => resolve addresses,
1479 1517
  * interface names, fills missing members, remove duplicates
1480 1518
  * fills type_flags if not null with SOCKET_T_IPV4 and/or SOCKET_T_IPV6*/
1481 1519
 static int fix_socket_list(struct socket_info **list, int* type_flags)
... ...
@@ -1507,7 +1545,7 @@ static int fix_socket_list(struct socket_info **list, int* type_flags)
1507 1545
 			if (si->flags & SI_IS_MHOMED){
1508 1546
 				if((new_si=new_sock2list_after(ai_lst->name.s, 0, si->port_no,
1509 1547
 											si->proto, si->useinfo.name.s,
1510
-											si->useinfo.port_no,
1548
+											si->useinfo.port_no, si->sockname.s,
1511 1549
 											ai_lst->flags|si->flags, si))==0)
1512 1550
 					break;
1513 1551
 				ail=ai_lst;
... ...
@@ -1527,12 +1565,11 @@ static int fix_socket_list(struct socket_info **list, int* type_flags)
1527 1565
 					new_si->addr_info_lst=ail;
1528 1566
 					si->addr_info_lst=0; /* detached and moved to new_si */
1529 1567
 				}
1530
-				
1531 1568
 			}else{
1532 1569
 				/* add all addr. as separate  interfaces */
1533 1570
 				if (addr_info_to_si_lst_after(ai_lst, si->port_no, si->proto,
1534 1571
 							si->useinfo.name.s, si->useinfo.port_no,
1535
-							si->flags, si)!=0)
1572
+							si->sockname.s, si->flags, si)!=0)
1536 1573
 					goto error;
1537 1574
 				/* ai_lst not needed anymore */
1538 1575
 				free_addr_info_lst(&ai_lst);
... ...
@@ -1546,7 +1583,7 @@ static int fix_socket_list(struct socket_info **list, int* type_flags)
1546 1583
 			new_si=si;
1547 1584
 			ail=si->addr_info_lst;
1548 1585
 		}
1549
-		
1586
+
1550 1587
 		if (ail){
1551 1588
 			if (new_si && (new_si->flags & SI_IS_MHOMED)){
1552 1589
 				ai_lst=0;
... ...
@@ -1592,7 +1629,7 @@ static int fix_socket_list(struct socket_info **list, int* type_flags)
1592 1629
 		}
1593 1630
 		strncpy(si->port_no_str.s, tmp, len+1);
1594 1631
 		si->port_no_str.len=len;
1595
-		
1632
+
1596 1633
 		if (fix_hostname(&si->name, &si->address, &si->address_str,
1597 1634
 						&si->flags, type_flags, si) !=0 )
1598 1635
 			goto error;
... ...
@@ -1604,9 +1641,9 @@ static int fix_socket_list(struct socket_info **list, int* type_flags)
1604 1641
 		}
1605 1642
 
1606 1643
 		if (fix_sock_str(si) < 0) goto error;
1607
-		
1644
+
1608 1645
 #ifdef EXTRA_DEBUG
1609
-		printf("              %.*s [%s]:%s%s\n", si->name.len, 
1646
+		printf("              %.*s [%s]:%s%s\n", si->name.len,
1610 1647
 				si->name.s, si->address_str.s, si->port_no_str.s,
1611 1648
 		                si->flags & SI_IS_MCAST ? " mcast" : "");
1612 1649
 #endif
... ...
@@ -1669,7 +1706,7 @@ static int fix_socket_list(struct socket_info **list, int* type_flags)
1669 1706
 		/* check  for & remove internal duplicates: */
1670 1707
 		for (ail=si->addr_info_lst; ail;){
1671 1708
 			ail_next=ail->next;
1672
-			/* 1. check if the extra addresses contain a duplicate for the 
1709
+			/* 1. check if the extra addresses contain a duplicate for the
1673 1710
 			 * main  one */
1674 1711
 			if ((ail->address.af==si->address.af) &&
1675 1712
 				(memcmp(ail->address.u.addr, si->address.u.addr,
... ...
@@ -1778,7 +1815,7 @@ static int fix_socket_list(struct socket_info **list, int* type_flags)
1778 1815
 			){
1779 1816
 			if (si->flags & SI_IS_MCAST){
1780 1817
 				LM_WARN("removing entry %s:%s [%s]:%s\n",
1781
-					get_valid_proto_name(si->proto), si->name.s, 
1818
+					get_valid_proto_name(si->proto), si->name.s,
1782 1819
 					si->address_str.s, si->port_no_str.s);
1783 1820
 				l = si;
1784 1821
 				si=si->next;
... ...
@@ -1790,7 +1827,7 @@ static int fix_socket_list(struct socket_info **list, int* type_flags)
1790 1827
 					if (ail->flags & SI_IS_MCAST){
1791 1828
 						LM_WARN("removing mh entry %s:%s"
1792 1829
 								" [%s]:%s\n",
1793
-								get_valid_proto_name(si->proto), ail->name.s, 
1830
+								get_valid_proto_name(si->proto), ail->name.s,
1794 1831
 								ail->address_str.s, si->port_no_str.s);
1795 1832
 						tmp_ail=ail;
1796 1833
 						ail=ail->next;
... ...
@@ -1822,9 +1859,9 @@ int fix_all_socket_lists()
1822 1859
 	struct utsname myname;
1823 1860
 	int flags;
1824 1861
 	struct addr_info* ai_lst;
1825
-	
1862
+
1826 1863
 	ai_lst=0;
1827
-	
1864
+
1828 1865
 	if ((udp_listen==0)
1829 1866
 #ifdef USE_TCP
1830 1867
 			&& (tcp_listen==0)
... ...
@@ -1843,7 +1880,7 @@ int fix_all_socket_lists()
1843 1880
 #else
1844 1881
 		&& ( !auto_bind_ipv6 || add_interfaces(0, AF_INET6, 0,  PROTO_UDP, &ai_lst) ==0 ) /* add_interface does not work for IPv6 on Linux */
1845 1882
 #endif /* __OS_linux */
1846
-			 ) && (addr_info_to_si_lst(ai_lst, 0, PROTO_UDP, 0, 0, 0, &udp_listen)==0)){
1883
+			 ) && (addr_info_to_si_lst(ai_lst, 0, PROTO_UDP, 0, 0, 0, 0, &udp_listen)==0)){
1847 1884
 			free_addr_info_lst(&ai_lst);
1848 1885
 			ai_lst=0;
1849 1886
 			/* if ok, try to add the others too */
... ...
@@ -1855,7 +1892,7 @@ int fix_all_socket_lists()
1855 1892
 #else
1856 1893
 				|| (auto_bind_ipv6 && add_interfaces(0, AF_INET6, 0,  PROTO_TCP, &ai_lst) !=0 )
1857 1894
 #endif /* __OS_linux */
1858
-				) || (addr_info_to_si_lst(ai_lst, 0, PROTO_TCP, 0, 0, 0,
1895
+				) || (addr_info_to_si_lst(ai_lst, 0, PROTO_TCP, 0, 0, 0, 0,
1859 1896
 										 				&tcp_listen)!=0))
1860 1897
 					goto error;
1861 1898
 				free_addr_info_lst(&ai_lst);
... ...
@@ -1869,7 +1906,7 @@ int fix_all_socket_lists()
1869 1906
 #else
1870 1907
 				|| (auto_bind_ipv6 && add_interfaces(0, AF_INET6, 0,  PROTO_TLS, &ai_lst)!=0)
1871 1908
 #endif /* __OS_linux */
1872
-					) || (addr_info_to_si_lst(ai_lst, 0, PROTO_TLS, 0, 0, 0,
1909
+					) || (addr_info_to_si_lst(ai_lst, 0, PROTO_TLS, 0, 0, 0, 0,
1873 1910
 										 				&tls_listen)!=0))
1874 1911
 						goto error;
1875 1912
 				}
... ...
@@ -1886,7 +1923,7 @@ int fix_all_socket_lists()
1886 1923
 #else
1887 1924
 				|| (auto_bind_ipv6 && add_interfaces(0, AF_INET6, 0,  PROTO_SCTP, &ai_lst) != 0)
1888 1925
 #endif /* __OS_linux */
1889
-					) || (addr_info_to_si_lst(ai_lst, 0, PROTO_SCTP, 0, 0, 0,
1926
+					) || (addr_info_to_si_lst(ai_lst, 0, PROTO_SCTP, 0, 0, 0, 0,
1890 1927
 							 				&sctp_listen)!=0))
1891 1928
 					goto error;
1892 1929
 				free_addr_info_lst(&ai_lst);
... ...
@@ -1972,8 +2009,7 @@ void print_all_socket_lists()
1972 2009
 	struct socket_info** list;
1973 2010
 	struct addr_info* ai;
1974 2011
 	unsigned short proto;
1975
-	
1976
-	
2012
+
1977 2013
 	proto=PROTO_UDP;
1978 2014
 	do{
1979 2015
 		list=get_sock_info_list(proto);
... ...
@@ -1982,24 +2018,30 @@ void print_all_socket_lists()
1982 2018
 				printf("             %s: (%s",
1983 2019
 						get_valid_proto_name(proto),
1984 2020
 						si->address_str.s);
1985
-				for (ai=si->addr_info_lst; ai; ai=ai->next)
2021
+				for (ai=si->addr_info_lst; ai; ai=ai->next) {
1986 2022
 					printf(", %s", ai->address_str.s);
2023
+				}
1987 2024
 				printf("):%s%s%s\n",
1988
-						si->port_no_str.s, 
2025
+						si->port_no_str.s,
1989 2026
 						si->flags & SI_IS_MCAST ? " mcast" : "",
1990 2027
 						si->flags & SI_IS_MHOMED? " mhomed" : "");
1991 2028
 			}else{
1992 2029
 				printf("             %s: %s",
1993 2030
 						get_valid_proto_name(proto),
1994 2031
 						si->name.s);
1995
-				if (!(si->flags & SI_IS_IP))
2032
+				if (!(si->flags & SI_IS_IP)) {
1996 2033
 					printf(" [%s]", si->address_str.s);
2034
+				}
1997 2035
 				printf( ":%s%s%s",
1998
-						si->port_no_str.s, 
2036
+						si->port_no_str.s,
1999 2037
 						si->flags & SI_IS_MCAST ? " mcast" : "",
2000 2038
 						si->flags & SI_IS_MHOMED? " mhomed" : "");
2001
-				if (si->useinfo.name.s)
2039
+				if (si->sockname.s) {
2040
+					printf(" name %s", si->sockname.s);
2041
+				}
2042
+				if (si->useinfo.name.s) {
2002 2043
 					printf(" advertise %s:%d", si->useinfo.name.s, si->useinfo.port_no);
2044
+				}
2003 2045
 				printf("\n");
2004 2046
 			}
2005 2047
 		}
... ...
@@ -2011,13 +2053,15 @@ void print_aliases()
2011 2053
 {
2012 2054
 	struct host_alias* a;
2013 2055
 
2014
-	for(a=aliases; a; a=a->next) 
2015
-		if (a->port)
2016
-			printf("             %s: %.*s:%d\n", get_valid_proto_name(a->proto), 
2056
+	for(a=aliases; a; a=a->next) {
2057
+		if (a->port) {
2058
+			printf("             %s: %.*s:%d\n", get_valid_proto_name(a->proto),
2017 2059
 					a->alias.len, a->alias.s, a->port);
2018
-		else
2019
-			printf("             %s: %.*s:*\n", get_valid_proto_name(a->proto), 
2060
+		} else {
2061
+			printf("             %s: %.*s:*\n", get_valid_proto_name(a->proto),
2020 2062
 					a->alias.len, a->alias.s);
2063
+		}
2064
+	}
2021 2065
 }
2022 2066
 
2023 2067
 
... ...
@@ -2025,7 +2069,7 @@ void print_aliases()
2025 2069
 void init_proto_order()
2026 2070
 {
2027 2071
 	int r;
2028
-	
2072
+
2029 2073
 	/* fix proto list  (remove disabled protocols)*/
2030 2074
 #ifdef USE_TCP
2031 2075
 	if (tcp_disable)
... ...
@@ -82,10 +82,17 @@ void init_proto_order(void);
82 82
 int add_listen_iface(char* name, struct name_lst* nlst,
83 83
 						unsigned short port, unsigned short proto,
84 84
 						enum si_flags flags);
85
+int add_listen_iface_name(char* name, struct name_lst* addr_l,
86
+						unsigned short port, unsigned short proto, char *sockname,
87
+						enum si_flags flags);
85 88
 int add_listen_advertise_iface(char* name, struct name_lst* nlst,
86 89
 						unsigned short port, unsigned short proto,
87 90
 						char *useaddr, unsigned short useport,
88 91
 						enum si_flags flags);
92
+int add_listen_advertise_iface_name(char* name, struct name_lst* nlst,
93
+						unsigned short port, unsigned short proto,
94
+						char *useaddr, unsigned short useport, char *sockname,
95
+						enum si_flags flags);
89 96
 int fix_all_socket_lists(void);
90 97
 void print_all_socket_lists(void);
91 98
 void print_aliases(void);