mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-30 10:02:53 +00:00
apc:Fix AP not receiving hello packets
Fix firewall setting not being applied. return incase the interap socket fails. Clean up in failure conditions. Signed-off-by: Chaitanya Godavarthi <chaitanya.kiran@netexperience.com>
This commit is contained in:
committed by
Rick Sommerville
parent
63f602a136
commit
93baf6d334
@@ -253,6 +253,10 @@ static void check_timer_handler(struct uloop_timeout *timeout)
|
||||
if (CheckIp && (MyIpAddr != CheckIp))
|
||||
{
|
||||
printf("IP address changed from %x to %x - restart APC election\n", MyIpAddr, CheckIp);
|
||||
system("/usr/opensync/bin/ovsh u APC_State dr_addr:=0.0.0.0 bdr_addr:=0.0.0.0 enabled:=false mode:=NC");
|
||||
uloop_done();
|
||||
ubus_done();
|
||||
interap_rcv_close();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@@ -266,6 +270,9 @@ static void check_timer_handler(struct uloop_timeout *timeout)
|
||||
|
||||
static void handle_signal(int signo)
|
||||
{
|
||||
uloop_done();
|
||||
ubus_done();
|
||||
interap_rcv_close();
|
||||
system("/usr/opensync/bin/ovsh u APC_State dr_addr:=0.0.0.0 bdr_addr:=0.0.0.0 enabled:=false mode:=NC");
|
||||
}
|
||||
|
||||
@@ -327,8 +334,10 @@ int main(int argc, char *const* argv)
|
||||
callback cb = receive_from_socket;
|
||||
|
||||
if (interap_recv(IAC_APC_ELECTION_PORT, cb, 1000,
|
||||
NULL, NULL) < 0)
|
||||
NULL, NULL) < 0) {
|
||||
printf("Error: Failed InterAP receive");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
memset(Timers, 0, sizeof(Timers));
|
||||
@@ -351,6 +360,7 @@ int main(int argc, char *const* argv)
|
||||
uloop_run();
|
||||
uloop_done();
|
||||
ubus_done();
|
||||
interap_rcv_close();
|
||||
|
||||
return(1);
|
||||
}
|
||||
|
||||
@@ -30,5 +30,8 @@ endef
|
||||
define Package/libinterapcomm/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/libinterapcomm.so $(1)/usr/lib/
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/interap.init $(1)/etc/init.d/interap
|
||||
|
||||
endef
|
||||
$(eval $(call BuildPackage,libinterapcomm))
|
||||
|
||||
35
feeds/wlan-ap/interAPcomm/files/interap.init
Normal file
35
feeds/wlan-ap/interAPcomm/files/interap.init
Normal file
@@ -0,0 +1,35 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=12
|
||||
STOP=12
|
||||
|
||||
start() {
|
||||
apc=`cat /etc/config/firewall | grep Allow-APC`
|
||||
ucc=`cat /etc/config/firewall | grep Allow-UCC`
|
||||
|
||||
if [ -z "$apc" ]; then
|
||||
uci add firewall rule
|
||||
uci set firewall.@rule[-1].name='Allow-APC'
|
||||
uci set firewall.@rule[-1].src='wan'
|
||||
uci set firewall.@rule[-1].proto='udp'
|
||||
uci set firewall.@rule[-1].dst_port='50010'
|
||||
uci set firewall.@rule[-1].target='ACCEPT'
|
||||
uci set firewall.@rule[-1].family='ipv4'
|
||||
uci commit firewall
|
||||
fi
|
||||
|
||||
if [ -z "$ucc" ]; then
|
||||
uci add firewall rule
|
||||
uci set firewall.@rule[-1].name='Allow-UCC'
|
||||
uci set firewall.@rule[-1].src='wan'
|
||||
uci set firewall.@rule[-1].proto='udp'
|
||||
uci set firewall.@rule[-1].dst_port='50000'
|
||||
uci set firewall.@rule[-1].target='ACCEPT'
|
||||
uci set firewall.@rule[-1].family='ipv4'
|
||||
uci commit firewall
|
||||
fi
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo stop
|
||||
}
|
||||
@@ -5,6 +5,7 @@ int interap_send(unsigned short port, char *dst_ip,
|
||||
int interap_recv(unsigned short port, int (*recv_cb)(void *, ssize_t),
|
||||
unsigned int len, struct ev_loop *loop,
|
||||
ev_io *io);
|
||||
void interap_rcv_close(void);
|
||||
|
||||
typedef int (*callback)(void *, ssize_t);
|
||||
typedef struct recv_arg {
|
||||
|
||||
@@ -22,8 +22,10 @@ static void receive_data_uloop(struct uloop_fd *fd, unsigned int events)
|
||||
recv_data = malloc(ra.len);
|
||||
memset(recv_data, 0, ra.len);
|
||||
if ((recv_data_len = recvfrom(recv_sock, recv_data, ra.len,
|
||||
0, NULL, 0)) < 0)
|
||||
0, NULL, 0)) < 0) {
|
||||
printf("recvfrom() failed");
|
||||
return;
|
||||
}
|
||||
|
||||
ra.cb(recv_data, recv_data_len);
|
||||
free(recv_data);
|
||||
@@ -99,6 +101,11 @@ int interap_recv(unsigned short port, int (*recv_cb)(void *, ssize_t),
|
||||
return 0;
|
||||
}
|
||||
|
||||
void interap_rcv_close(void)
|
||||
{
|
||||
close(recv_sock);
|
||||
}
|
||||
|
||||
int interap_send(unsigned short port, char *dst_ip, void *data,
|
||||
unsigned int len)
|
||||
{
|
||||
|
||||
@@ -275,8 +275,10 @@ int main(int argc, char ** argv)
|
||||
callback cb = recv_process;
|
||||
LOGI("Call interap_recv");
|
||||
if( interap_recv(IAC_VOIP_PORT, cb, sizeof(struct voip_session),
|
||||
loop, &iac_io) < 0)
|
||||
loop, &iac_io) < 0) {
|
||||
LOGI("Error: Failed InterAP receive");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// task_init();
|
||||
netlink_listen(loop);
|
||||
@@ -291,6 +293,7 @@ int main(int argc, char ** argv)
|
||||
#endif
|
||||
ev_default_destroy();
|
||||
|
||||
interap_rcv_close();
|
||||
LOGN("Exiting UCCM");
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user