From 6a4965ebe15d40983df1ecab83cf110a4e51cc37 Mon Sep 17 00:00:00 2001 From: "7u83@mail.ru" <7u83@mail.ru@noemail.net> Date: Sun, 20 Mar 2016 14:04:00 +0000 Subject: [PATCH] Creates data ports now. FossilOrigin-Name: 1538ce3f4d795558870b39afdb406f1dadd2014e03a58147b68dd88a8cbc53d4 --- src/ac/socklist.c | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/src/ac/socklist.c b/src/ac/socklist.c index 16d61b40..5667daf9 100644 --- a/src/ac/socklist.c +++ b/src/ac/socklist.c @@ -300,7 +300,7 @@ int socklist_add_multicast(const char *addr, const char *port, int ac_proto) int rfd = find_reply_socket(sa, 0); socklist[socklist_len].sockfd = sockfd; - socklist[socklist_len].reply_sockfd = rfd; +// socklist[socklist_len].reply_sockfd = rfd; socklist[socklist_len].type = SOCKLIST_BCASTMCAST_SOCKET; socklist[socklist_len].family = sa->sa_family; socklist[socklist_len].ac_proto = ac_proto; @@ -365,6 +365,7 @@ int socklist_add_unicast(const char *addr, const char *port, int ac_proto) continue; } + /* Bind the control port */ struct sockaddr *sa = res->ai_addr; int sockfd = socket(res->ai_addr->sa_family, SOCK_DGRAM, 0); /* create socket */ @@ -384,12 +385,16 @@ int socklist_add_unicast(const char *addr, const char *port, int ac_proto) socklist[socklist_len].sockfd = sockfd; - socklist[socklist_len].reply_sockfd = sockfd; +// socklist[socklist_len].reply_sockfd = sockfd; socklist[socklist_len].family = sa->sa_family; socklist[socklist_len].type = SOCKLIST_UNICAST_SOCKET; socklist[socklist_len].ac_proto = ac_proto; + + + + if (res->ai_addr->sa_family == AF_INET) { memcpy(&socklist[socklist_len].netmask, &netmask, sock_addrlen(&netmask)); @@ -402,6 +407,33 @@ int socklist_add_unicast(const char *addr, const char *port, int ac_proto) cw_log(LOG_INFO, "Bound to: [%s]:%s (%i) on interface %s", addr, port, sockfd, ifname); } + + + /* Bind the data port */ + sa = res->ai_addr; + + /* XXX data port is currently hard coded */ + sock_setport(sa,5247); + + sockfd = socket(res->ai_addr->sa_family, SOCK_DGRAM, 0); + /* create socket */ + if (sockfd == -1) { + cw_log(LOG_ERR, "Can't create unicast socket: %s", + strerror(errno)); + continue; + } + + /* bind address */ + if (bind(sockfd, sa, sock_addrlen(sa)) < 0) { + close(sockfd); + cw_log(LOG_ERR, "Can't bind unicast socket %s: %s", addr, + strerror(errno)); + continue; + } + + + socklist[socklist_len].data_sockfd = sockfd; + socklist_len++; } @@ -468,7 +500,7 @@ int socklist_add_broadcast(const char *addr, const char *port, int ac_proto) int rfd = find_reply_socket(sa, 1); socklist[socklist_len].sockfd = sockfd; - socklist[socklist_len].reply_sockfd = rfd; +// socklist[socklist_len].reply_sockfd = rfd; socklist[socklist_len].type = SOCKLIST_BCASTMCAST_SOCKET; socklist[socklist_len].family = sa->sa_family; socklist[socklist_len].ac_proto = ac_proto;