If not set into wtp.conf the client bind to any port
This commit is contained in:
parent
16fe0bb6bd
commit
37e60bb755
15
src/ac/ac.c
15
src/ac/ac.c
@ -20,10 +20,11 @@ static int ac_init(void) {
|
|||||||
capwap_network_init(&g_ac.net);
|
capwap_network_init(&g_ac.net);
|
||||||
g_ac.mtu = CAPWAP_MTU_DEFAULT;
|
g_ac.mtu = CAPWAP_MTU_DEFAULT;
|
||||||
g_ac.binding = capwap_array_create(sizeof(unsigned short), 0);
|
g_ac.binding = capwap_array_create(sizeof(unsigned short), 0);
|
||||||
|
g_ac.net.bind_sock_ctrl_port = CAPWAP_CONTROL_PORT;
|
||||||
|
|
||||||
/* Standard name */
|
/* Standard name */
|
||||||
strcpy((char*)g_ac.acname.name, AC_STANDARD_NAME);
|
strcpy((char*)g_ac.acname.name, AC_STANDARD_NAME);
|
||||||
|
|
||||||
/* Descriptor */
|
/* Descriptor */
|
||||||
g_ac.descriptor.stationlimit = AC_DEFAULT_MAXSTATION;
|
g_ac.descriptor.stationlimit = AC_DEFAULT_MAXSTATION;
|
||||||
g_ac.descriptor.maxwtp = AC_DEFAULT_MAXSESSIONS;
|
g_ac.descriptor.maxwtp = AC_DEFAULT_MAXSESSIONS;
|
||||||
@ -477,6 +478,16 @@ static int ac_parsing_configuration_1_0(config_t* config) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set network port of WTP */
|
||||||
|
if (config_lookup_int(config, "application.network.port", &configLongInt) == CONFIG_TRUE) {
|
||||||
|
if ((configLongInt > 0) && (configLongInt < 65535)) {
|
||||||
|
g_ac.net.bind_sock_ctrl_port = (unsigned short)configLongInt;
|
||||||
|
} else {
|
||||||
|
capwap_logging_error("Invalid configuration file, invalid application.network.port value");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Set transport of AC */
|
/* Set transport of AC */
|
||||||
if (config_lookup_string(config, "application.network.transport", &configString) == CONFIG_TRUE) {
|
if (config_lookup_string(config, "application.network.transport", &configString) == CONFIG_TRUE) {
|
||||||
if (!strcmp(configString, "udp")) {
|
if (!strcmp(configString, "udp")) {
|
||||||
|
@ -625,7 +625,7 @@ void* ac_session_thread(void* param) {
|
|||||||
void ac_get_control_information(struct capwap_list* controllist) {
|
void ac_get_control_information(struct capwap_list* controllist) {
|
||||||
struct capwap_list* addrlist;
|
struct capwap_list* addrlist;
|
||||||
struct capwap_list_item* item;
|
struct capwap_list_item* item;
|
||||||
|
|
||||||
ASSERT(controllist != NULL);
|
ASSERT(controllist != NULL);
|
||||||
|
|
||||||
/* Detect local address */
|
/* Detect local address */
|
||||||
@ -646,22 +646,22 @@ void ac_get_control_information(struct capwap_list* controllist) {
|
|||||||
|
|
||||||
/* Add */
|
/* Add */
|
||||||
capwap_itemlist_insert_after(controllist, NULL, itemcontrol);
|
capwap_itemlist_insert_after(controllist, NULL, itemcontrol);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free local address list */
|
/* Free local address list */
|
||||||
capwap_list_free(addrlist);
|
capwap_list_free(addrlist);
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
capwap_lock_enter(&g_ac.sessionslock);
|
capwap_lock_enter(&g_ac.sessionslock);
|
||||||
|
|
||||||
/* Get wtp count from any local address */
|
/* Get wtp count from any local address */
|
||||||
for (item = controllist->first; item != NULL; item = item->next) {
|
for (item = controllist->first; item != NULL; item = item->next) {
|
||||||
struct capwap_list_item* search;
|
struct capwap_list_item* search;
|
||||||
struct ac_session_control* sessioncontrol = (struct ac_session_control*)item->item;
|
struct ac_session_control* sessioncontrol = (struct ac_session_control*)item->item;
|
||||||
|
|
||||||
for (search = g_ac.sessions->first; search != NULL; search = search->next) {
|
for (search = g_ac.sessions->first; search != NULL; search = search->next) {
|
||||||
struct ac_session_t* session = (struct ac_session_t*)search->item;
|
struct ac_session_t* session = (struct ac_session_t*)search->item;
|
||||||
|
|
||||||
if (!capwap_compare_ip(&session->acctrladdress, &sessioncontrol->localaddress)) {
|
if (!capwap_compare_ip(&session->acctrladdress, &sessioncontrol->localaddress)) {
|
||||||
sessioncontrol->count++;
|
sessioncontrol->count++;
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,6 @@ static int capwap_prepare_bind_socket(struct capwap_network* net, int socketfami
|
|||||||
struct sockaddr_storage bindaddr;
|
struct sockaddr_storage bindaddr;
|
||||||
|
|
||||||
ASSERT(net != NULL);
|
ASSERT(net != NULL);
|
||||||
ASSERT(net->bind_sock_ctrl_port != 0);
|
|
||||||
ASSERT((socketfamily == AF_INET) || (socketfamily == AF_INET6));
|
ASSERT((socketfamily == AF_INET) || (socketfamily == AF_INET6));
|
||||||
ASSERT((socketprotocol == IPPROTO_UDP) || (socketprotocol == IPPROTO_UDPLITE));
|
ASSERT((socketprotocol == IPPROTO_UDP) || (socketprotocol == IPPROTO_UDPLITE));
|
||||||
|
|
||||||
@ -170,7 +169,7 @@ static int capwap_prepare_bind_socket(struct capwap_network* net, int socketfami
|
|||||||
if (sock_data >= 0) {
|
if (sock_data >= 0) {
|
||||||
if (!capwap_configure_socket(sock_data, socketfamily, socketprotocol, 0, net->bind_interface, net->bind_data_flags)) {
|
if (!capwap_configure_socket(sock_data, socketfamily, socketprotocol, 0, net->bind_interface, net->bind_data_flags)) {
|
||||||
/* Bind address */
|
/* Bind address */
|
||||||
CAPWAP_SET_NETWORK_PORT(&bindaddr, net->bind_sock_ctrl_port + 1);
|
CAPWAP_SET_NETWORK_PORT(&bindaddr, (!net->bind_sock_ctrl_port ? 0 : net->bind_sock_ctrl_port + 1));
|
||||||
if (!bind(sock_data, (struct sockaddr*)&bindaddr, sizeof(struct sockaddr_storage))) {
|
if (!bind(sock_data, (struct sockaddr*)&bindaddr, sizeof(struct sockaddr_storage))) {
|
||||||
result = 1;
|
result = 1;
|
||||||
capwap_save_socket(net, socketfamily, socketprotocol, sock_ctrl, sock_data);
|
capwap_save_socket(net, socketfamily, socketprotocol, sock_ctrl, sock_data);
|
||||||
@ -453,8 +452,12 @@ void capwap_network_init(struct capwap_network* net) {
|
|||||||
|
|
||||||
ASSERT(net != NULL);
|
ASSERT(net != NULL);
|
||||||
|
|
||||||
|
/* */
|
||||||
|
memset(net, 0, sizeof(struct capwap_network));
|
||||||
|
|
||||||
|
/* */
|
||||||
net->sock_family = AF_UNSPEC;
|
net->sock_family = AF_UNSPEC;
|
||||||
net->bind_sock_ctrl_port = CAPWAP_CONTROL_PORT;
|
net->bind_sock_ctrl_port = INADDR_ANY;
|
||||||
for (i = 0; i < CAPWAP_MAX_SOCKETS; i++) {
|
for (i = 0; i < CAPWAP_MAX_SOCKETS; i++) {
|
||||||
net->sock_ctrl[i] = -1;
|
net->sock_ctrl[i] = -1;
|
||||||
net->sock_data[i] = -1;
|
net->sock_data[i] = -1;
|
||||||
@ -1211,13 +1214,14 @@ int capwap_get_localaddress_by_remoteaddress(struct sockaddr_storage* local, str
|
|||||||
void capwap_interface_list(struct capwap_network* net, struct capwap_list* list) {
|
void capwap_interface_list(struct capwap_network* net, struct capwap_list* list) {
|
||||||
struct ifaddrs* ifaddrlist;
|
struct ifaddrs* ifaddrlist;
|
||||||
struct ifaddrs* ifcurrentpos;
|
struct ifaddrs* ifcurrentpos;
|
||||||
|
|
||||||
ASSERT(net != NULL);
|
ASSERT(net != NULL);
|
||||||
ASSERT(list != NULL);
|
ASSERT(list != NULL);
|
||||||
|
|
||||||
/* Get interface list */
|
/* Get interface list */
|
||||||
if (getifaddrs(&ifaddrlist) != 0)
|
if (getifaddrs(&ifaddrlist) != 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
for (ifcurrentpos = ifaddrlist; ifcurrentpos != NULL; ifcurrentpos = ifcurrentpos->ifa_next) {
|
for (ifcurrentpos = ifaddrlist; ifcurrentpos != NULL; ifcurrentpos = ifcurrentpos->ifa_next) {
|
||||||
@ -1243,25 +1247,25 @@ void capwap_interface_list(struct capwap_network* net, struct capwap_list* list)
|
|||||||
if ((net->bind_interface[0] != 0) && (strcmp(net->bind_interface, ifcurrentpos->ifa_name) != 0)) {
|
if ((net->bind_interface[0] != 0) && (strcmp(net->bind_interface, ifcurrentpos->ifa_name) != 0)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add local address */
|
/* Add local address */
|
||||||
item = capwap_itemlist_create(sizeof(struct sockaddr_storage));
|
item = capwap_itemlist_create(sizeof(struct sockaddr_storage));
|
||||||
addr = (struct sockaddr_storage*)item->item;
|
addr = (struct sockaddr_storage*)item->item;
|
||||||
|
|
||||||
memset(addr, 0, sizeof(struct sockaddr_storage));
|
memset(addr, 0, sizeof(struct sockaddr_storage));
|
||||||
addr->ss_family = ifcurrentpos->ifa_addr->sa_family;
|
addr->ss_family = ifcurrentpos->ifa_addr->sa_family;
|
||||||
CAPWAP_SET_NETWORK_PORT(addr, net->bind_sock_ctrl_port);
|
CAPWAP_SET_NETWORK_PORT(addr, net->bind_sock_ctrl_port);
|
||||||
|
|
||||||
if (addr->ss_family == AF_INET) {
|
if (addr->ss_family == AF_INET) {
|
||||||
memcpy(&((struct sockaddr_in*)addr)->sin_addr, &((struct sockaddr_in*)ifcurrentpos->ifa_addr)->sin_addr, sizeof(struct in_addr));
|
memcpy(&((struct sockaddr_in*)addr)->sin_addr, &((struct sockaddr_in*)ifcurrentpos->ifa_addr)->sin_addr, sizeof(struct in_addr));
|
||||||
} else if (addr->ss_family == AF_INET6) {
|
} else if (addr->ss_family == AF_INET6) {
|
||||||
memcpy(&((struct sockaddr_in6*)addr)->sin6_addr, &((struct sockaddr_in6*)ifcurrentpos->ifa_addr)->sin6_addr, sizeof(struct in6_addr));
|
memcpy(&((struct sockaddr_in6*)addr)->sin6_addr, &((struct sockaddr_in6*)ifcurrentpos->ifa_addr)->sin6_addr, sizeof(struct in6_addr));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add address */
|
/* Add address */
|
||||||
capwap_itemlist_insert_after(list, NULL, item);
|
capwap_itemlist_insert_after(list, NULL, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free */
|
/* Free */
|
||||||
freeifaddrs(ifaddrlist);
|
freeifaddrs(ifaddrlist);
|
||||||
}
|
}
|
||||||
|
@ -753,7 +753,7 @@ static int wtp_parsing_configuration_1_0(config_t* config) {
|
|||||||
|
|
||||||
/* Set network port of WTP */
|
/* Set network port of WTP */
|
||||||
if (config_lookup_int(config, "application.network.port", &configLongInt) == CONFIG_TRUE) {
|
if (config_lookup_int(config, "application.network.port", &configLongInt) == CONFIG_TRUE) {
|
||||||
if ((configLongInt > 0) && (configLongInt < 65536)) {
|
if ((configLongInt > 0) && (configLongInt < 65535)) {
|
||||||
g_wtp.net.bind_sock_ctrl_port = (unsigned short)configLongInt;
|
g_wtp.net.bind_sock_ctrl_port = (unsigned short)configLongInt;
|
||||||
} else {
|
} else {
|
||||||
capwap_logging_error("Invalid configuration file, invalid application.network.port value");
|
capwap_logging_error("Invalid configuration file, invalid application.network.port value");
|
||||||
|
Loading…
Reference in New Issue
Block a user