mirror of
				https://github.com/Telecominfraproject/wlan-ap.git
				synced 2025-10-31 18:38:10 +00:00 
			
		
		
		
	Compare commits
	
		
			8 Commits
		
	
	
		
			v1.1.0-rc1
			...
			v1.1.0-rc2
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | acc7a24464 | ||
|   | 327b85b44a | ||
|   | 811f5e60aa | ||
|   | 93baf6d334 | ||
|   | 63f602a136 | ||
|   | 49383f1c01 | ||
|   | 7ac036af0a | ||
|   | 666e740e0b | 
| @@ -253,6 +253,10 @@ static void check_timer_handler(struct uloop_timeout *timeout) | |||||||
| 		if (CheckIp && (MyIpAddr != CheckIp)) | 		if (CheckIp && (MyIpAddr != CheckIp)) | ||||||
| 		{ | 		{ | ||||||
| 			printf("IP address changed from %x to %x - restart APC election\n", 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); | 			exit(0); | ||||||
| 		} | 		} | ||||||
| 		 | 		 | ||||||
| @@ -266,6 +270,9 @@ static void check_timer_handler(struct uloop_timeout *timeout) | |||||||
|  |  | ||||||
| static void handle_signal(int signo) | 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"); | 	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; | 	callback cb = receive_from_socket; | ||||||
|  |  | ||||||
| 	if (interap_recv(IAC_APC_ELECTION_PORT, cb, 1000, | 	if (interap_recv(IAC_APC_ELECTION_PORT, cb, 1000, | ||||||
| 			 NULL, NULL) < 0) | 			 NULL, NULL) < 0) { | ||||||
| 		printf("Error: Failed InterAP receive"); | 		printf("Error: Failed InterAP receive"); | ||||||
|  | 		return 1; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  |  | ||||||
| 	memset(Timers, 0, sizeof(Timers)); | 	memset(Timers, 0, sizeof(Timers)); | ||||||
| @@ -351,6 +360,7 @@ int main(int argc, char *const* argv) | |||||||
| 	uloop_run(); | 	uloop_run(); | ||||||
| 	uloop_done(); | 	uloop_done(); | ||||||
| 	ubus_done(); | 	ubus_done(); | ||||||
|  | 	interap_rcv_close(); | ||||||
|  |  | ||||||
| 	return(1); | 	return(1); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -189,8 +189,11 @@ void apc_send_hello(struct apc_iface * ifa, int kind ) | |||||||
| 			else | 			else | ||||||
| 				ApcSpec.FloatIp = ApcSpecSaved.FloatIp; | 				ApcSpec.FloatIp = ApcSpecSaved.FloatIp; | ||||||
| 		} | 		} | ||||||
| 		else | 		else if (ApcSpec.IsApc == I_AM_BAPC ) | ||||||
| 		{ | 		{ | ||||||
|  | 			ifa->priority = 0x12; | ||||||
|  | 		} | ||||||
|  | 		else { | ||||||
| 			ifa->priority = 0x11; | 			ifa->priority = 0x11; | ||||||
| 			if ((ApcSpecSaved.IsApc == I_AM_APC) || BackingUpRadius ) | 			if ((ApcSpecSaved.IsApc == I_AM_APC) || BackingUpRadius ) | ||||||
| 			{ | 			{ | ||||||
|   | |||||||
| @@ -482,10 +482,13 @@ static void inactivity_timer_hook(struct _timer * tmr) | |||||||
| 			n_neigh += 1; | 			n_neigh += 1; | ||||||
| 			//Radius stuff | 			//Radius stuff | ||||||
| 			BackingUpRadius = 1; | 			BackingUpRadius = 1; | ||||||
|  | 			apc_ifa->priority = 0x33; | ||||||
| 		} | 		} | ||||||
|  | 		else | ||||||
|  | 			apc_ifa->priority = 0x11; | ||||||
|  |  | ||||||
|  |  | ||||||
| 		apc_ifa->drip = MyIpAddr; | 		apc_ifa->drip = MyIpAddr; | ||||||
| 		apc_ifa->priority = 0x11; |  | ||||||
| 		apc_ifa->bdrip = 0; | 		apc_ifa->bdrip = 0; | ||||||
| 		memset(&ApcSpec, 0, sizeof(struct apc_spec)); | 		memset(&ApcSpec, 0, sizeof(struct apc_spec)); | ||||||
| 		WaitingToReelect = 12; | 		WaitingToReelect = 12; | ||||||
|   | |||||||
| @@ -17,7 +17,7 @@ static struct blob_buf nb; | |||||||
| static const char *ubus_path; | static const char *ubus_path; | ||||||
| timer *notify_timer; | timer *notify_timer; | ||||||
| extern struct apc_iface * apc_ifa; | extern struct apc_iface * apc_ifa; | ||||||
| #define APC_NOTIFY_INTERVAL 30 | #define APC_NOTIFY_INTERVAL 10 | ||||||
|  |  | ||||||
| struct apc_state { | struct apc_state { | ||||||
| 	char mode[4]; | 	char mode[4]; | ||||||
| @@ -94,7 +94,7 @@ apc_info_handle(struct ubus_context *ctx, struct ubus_object *obj, | |||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| static char apc_mode[APC_MAX_MODE][8] = {"DOWN", "LOOP", "WAITING", "PTP", "OR", "BDR", "DR"}; | static char apc_mode[APC_MAX_MODE][8] = {"DOWN", "LOOP", "WT", "PTP", "OR", "BDR", "DR"}; | ||||||
| void apc_update_state() | void apc_update_state() | ||||||
| { | { | ||||||
| 	struct in_addr dr_addr; | 	struct in_addr dr_addr; | ||||||
| @@ -112,8 +112,12 @@ void apc_update_state() | |||||||
| 			 "%s", inet_ntoa(dr_addr)); | 			 "%s", inet_ntoa(dr_addr)); | ||||||
| 		snprintf(state.bdr_addr, sizeof(state.bdr_addr), | 		snprintf(state.bdr_addr, sizeof(state.bdr_addr), | ||||||
| 			 "%s", inet_ntoa(bdr_addr)); | 			 "%s", inet_ntoa(bdr_addr)); | ||||||
| 	} | 	} else if (apc_ifa->state == APC_IS_WAITING) { | ||||||
| 	else { | 		snprintf(state.mode, sizeof(state.mode), "%s", | ||||||
|  | 			 &apc_mode[apc_ifa->state][0]); | ||||||
|  | 		snprintf(state.dr_addr, sizeof(state.dr_addr), "0.0.0.0"); | ||||||
|  | 		snprintf(state.bdr_addr, sizeof(state.bdr_addr), "0.0.0.0"); | ||||||
|  | 	} else { | ||||||
| 		snprintf(state.mode, sizeof(state.mode), "NC"); | 		snprintf(state.mode, sizeof(state.mode), "NC"); | ||||||
| 		snprintf(state.dr_addr, sizeof(state.dr_addr), "0.0.0.0"); | 		snprintf(state.dr_addr, sizeof(state.dr_addr), "0.0.0.0"); | ||||||
| 		snprintf(state.bdr_addr, sizeof(state.bdr_addr), "0.0.0.0"); | 		snprintf(state.bdr_addr, sizeof(state.bdr_addr), "0.0.0.0"); | ||||||
|   | |||||||
| @@ -30,5 +30,8 @@ endef | |||||||
| define Package/libinterapcomm/install | define Package/libinterapcomm/install | ||||||
| 	$(INSTALL_DIR) $(1)/usr/lib | 	$(INSTALL_DIR) $(1)/usr/lib | ||||||
| 	$(INSTALL_DATA) $(PKG_BUILD_DIR)/libinterapcomm.so $(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 | endef | ||||||
| $(eval $(call BuildPackage,libinterapcomm)) | $(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), | int interap_recv(unsigned short port, int (*recv_cb)(void *, ssize_t), | ||||||
| 		 unsigned int len, struct ev_loop *loop, | 		 unsigned int len, struct ev_loop *loop, | ||||||
| 		 ev_io *io); | 		 ev_io *io); | ||||||
|  | void interap_rcv_close(void); | ||||||
|  |  | ||||||
| typedef int (*callback)(void *, ssize_t); | typedef int (*callback)(void *, ssize_t); | ||||||
| typedef struct recv_arg { | 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); | 	recv_data = malloc(ra.len); | ||||||
| 	memset(recv_data, 0, ra.len); | 	memset(recv_data, 0, ra.len); | ||||||
| 	if ((recv_data_len = recvfrom(recv_sock, recv_data, ra.len, | 	if ((recv_data_len = recvfrom(recv_sock, recv_data, ra.len, | ||||||
| 				      0, NULL, 0)) < 0) | 				      0, NULL, 0)) < 0) { | ||||||
| 		printf("recvfrom() failed"); | 		printf("recvfrom() failed"); | ||||||
|  | 		return; | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	ra.cb(recv_data, recv_data_len); | 	ra.cb(recv_data, recv_data_len); | ||||||
| 	free(recv_data); | 	free(recv_data); | ||||||
| @@ -99,6 +101,11 @@ int interap_recv(unsigned short port, int (*recv_cb)(void *, ssize_t), | |||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void interap_rcv_close(void) | ||||||
|  | { | ||||||
|  | 	close(recv_sock); | ||||||
|  | } | ||||||
|  |  | ||||||
| int interap_send(unsigned short port, char *dst_ip, void *data, | int interap_send(unsigned short port, char *dst_ip, void *data, | ||||||
| 		 unsigned int len) | 		 unsigned int len) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -2,7 +2,7 @@ Index: opensync-2.0.5.0/interfaces/opensync.ovsschema | |||||||
| =================================================================== | =================================================================== | ||||||
| --- opensync-2.0.5.0.orig/interfaces/opensync.ovsschema | --- opensync-2.0.5.0.orig/interfaces/opensync.ovsschema | ||||||
| +++ opensync-2.0.5.0/interfaces/opensync.ovsschema | +++ opensync-2.0.5.0/interfaces/opensync.ovsschema | ||||||
| @@ -9368,6 +9368,68 @@ | @@ -9368,6 +9368,69 @@ | ||||||
|              } |              } | ||||||
|         }, |         }, | ||||||
|        "isRoot": true |        "isRoot": true | ||||||
| @@ -57,6 +57,7 @@ Index: opensync-2.0.5.0/interfaces/opensync.ovsschema | |||||||
| +                  "DR", | +                  "DR", | ||||||
| +                  "BDR", | +                  "BDR", | ||||||
| +                  "OR", | +                  "OR", | ||||||
|  | +                  "WT", | ||||||
| +                  "NC" | +                  "NC" | ||||||
| +                ] | +                ] | ||||||
| +              ] | +              ] | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| --- a/interfaces/opensync.ovsschema | --- a/interfaces/opensync.ovsschema | ||||||
| +++ b/interfaces/opensync.ovsschema | +++ b/interfaces/opensync.ovsschema | ||||||
| @@ -9439,6 +9439,110 @@ | @@ -9492,6 +9492,137 @@ | ||||||
|        }, |        }, | ||||||
|        "isRoot": true, |        "isRoot": true, | ||||||
|        "maxRows": 1 |        "maxRows": 1 | ||||||
| @@ -52,6 +52,33 @@ | |||||||
| +                "max": 1 | +                "max": 1 | ||||||
| +              } | +              } | ||||||
| +            }, | +            }, | ||||||
|  | +            "acct_server": { | ||||||
|  | +                "type": { | ||||||
|  | +                "key": { | ||||||
|  | +                  "type": "string" | ||||||
|  | +                }, | ||||||
|  | +                "min": 0, | ||||||
|  | +                "max": 1 | ||||||
|  | +              } | ||||||
|  | +            }, | ||||||
|  | +            "acct_port": { | ||||||
|  | +              "type": { | ||||||
|  | +                "key": { | ||||||
|  | +                  "type": "integer" | ||||||
|  | +                }, | ||||||
|  | +                "min": 0, | ||||||
|  | +                "max": 1 | ||||||
|  | +              } | ||||||
|  | +            }, | ||||||
|  | +            "acct_secret": { | ||||||
|  | +                "type": { | ||||||
|  | +                "key": { | ||||||
|  | +                  "type": "string" | ||||||
|  | +                }, | ||||||
|  | +                "min": 0, | ||||||
|  | +                "max": 1 | ||||||
|  | +              } | ||||||
|  | +            }, | ||||||
| +            "ca_cert": { | +            "ca_cert": { | ||||||
| +                "type": { | +                "type": { | ||||||
| +                    "key": { | +                    "key": { | ||||||
|   | |||||||
| @@ -215,6 +215,7 @@ pid_t cmd_handler_tcpdump_wifi(struct task *task) | |||||||
| 	char *argv[] = { "/usr/sbin/tcpdump", "-c", "1000", "-G", duration, "-W", "1", "-w", pcap, "-i", phy, NULL }; | 	char *argv[] = { "/usr/sbin/tcpdump", "-c", "1000", "-G", duration, "-W", "1", "-w", pcap, "-i", phy, NULL }; | ||||||
| 	char iw[128]; | 	char iw[128]; | ||||||
| 	pid_t pid; | 	pid_t pid; | ||||||
|  | 	int ret = 0; | ||||||
|  |  | ||||||
| 	task->arg = SCHEMA_KEY_VAL(task->conf.payload, "wifi"); | 	task->arg = SCHEMA_KEY_VAL(task->conf.payload, "wifi"); | ||||||
| 	if (!task->arg) { | 	if (!task->arg) { | ||||||
| @@ -225,15 +226,23 @@ pid_t cmd_handler_tcpdump_wifi(struct task *task) | |||||||
|  |  | ||||||
| 	blob_buf_init(&b, 0); | 	blob_buf_init(&b, 0); | ||||||
| 	uci = uci_alloc_context(); | 	uci = uci_alloc_context(); | ||||||
| 	uci_load(uci, "wireless", &p); |  | ||||||
|  | 	ret = uci_load(uci, "wireless", &p); | ||||||
|  | 	if (ret) { | ||||||
|  | 		LOGE("%s: uci_load() failed with rc %d", __func__, ret); | ||||||
|  | 		uci_free_context(uci); | ||||||
|  | 		return -1; | ||||||
|  | 	} | ||||||
| 	s = uci_lookup_section(uci, p, task->arg); | 	s = uci_lookup_section(uci, p, task->arg); | ||||||
| 	if (!s) { | 	if (!s) { | ||||||
| 		task_status(task, TASK_FAILED, "unknown wifi"); | 		task_status(task, TASK_FAILED, "unknown wifi"); | ||||||
|  | 		uci_unload(uci, p); | ||||||
| 		uci_free_context(uci); | 		uci_free_context(uci); | ||||||
| 		return -1; | 		return -1; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	uci_to_blob(&b, s, &phy_param); | 	uci_to_blob(&b, s, &phy_param); | ||||||
|  | 	uci_unload(uci, p); | ||||||
| 	uci_free_context(uci); | 	uci_free_context(uci); | ||||||
|  |  | ||||||
| 	blobmsg_parse(phy_policy, __PHY_ATTR_MAX, tb, blob_data(b.head), blob_len(b.head)); | 	blobmsg_parse(phy_policy, __PHY_ATTR_MAX, tb, blob_data(b.head), blob_len(b.head)); | ||||||
|   | |||||||
| @@ -88,9 +88,14 @@ static void syslog_state(int config) | |||||||
| 	struct uci_element *e = NULL; | 	struct uci_element *e = NULL; | ||||||
| 	struct uci_section *s = NULL; | 	struct uci_section *s = NULL; | ||||||
| 	char val[128]; | 	char val[128]; | ||||||
|  | 	int ret = 0; | ||||||
|  |  | ||||||
| 	blob_buf_init(&b, 0); | 	blob_buf_init(&b, 0); | ||||||
| 	uci_load(uci, "system", &system); | 	ret = uci_load(uci, "system", &system); | ||||||
|  | 	if (ret) { | ||||||
|  | 		LOGE("%s: uci_load() failed with rc %d", __func__, ret); | ||||||
|  | 		return; | ||||||
|  | 	} | ||||||
| 	uci_foreach_element(&system->sections, e) { | 	uci_foreach_element(&system->sections, e) { | ||||||
| 		s = uci_to_section(e); | 		s = uci_to_section(e); | ||||||
| 		if (!strcmp(s->type, "system")) | 		if (!strcmp(s->type, "system")) | ||||||
| @@ -179,14 +184,20 @@ static void ntp_state(int config) | |||||||
|         struct uci_section *s; |         struct uci_section *s; | ||||||
| 	struct blob_attr *cur = NULL; | 	struct blob_attr *cur = NULL; | ||||||
| 	char val[128] = {}; | 	char val[128] = {}; | ||||||
| 	int first = 1, rem = 0; | 	int first = 1, rem = 0, ret = 0; | ||||||
|  |  | ||||||
| 	blob_buf_init(&b, 0); | 	blob_buf_init(&b, 0); | ||||||
| 	uci_load(uci, "system", &p); | 	ret = uci_load(uci, "system", &p); | ||||||
|  | 	if (ret) { | ||||||
|  | 		LOGE("%s: uci_load() failed with rc %d", __func__, ret); | ||||||
|  | 		return; | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	s = uci_lookup_section(uci, p, "ntp"); | 	s = uci_lookup_section(uci, p, "ntp"); | ||||||
| 	if (!s) | 	if (!s) { | ||||||
|  | 		uci_unload(uci, p); | ||||||
| 		return; | 		return; | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	uci_to_blob(&b, s, &ntp_param); | 	uci_to_blob(&b, s, &ntp_param); | ||||||
| 	blobmsg_parse(ntp_policy, __NTP_ATTR_MAX, tb, blob_data(b.head), blob_len(b.head)); | 	blobmsg_parse(ntp_policy, __NTP_ATTR_MAX, tb, blob_data(b.head), blob_len(b.head)); | ||||||
|   | |||||||
| @@ -501,25 +501,30 @@ void opennds_parameters(char *ifname) | |||||||
| void opennds_section_del(char *section_name) | void opennds_section_del(char *section_name) | ||||||
| { | { | ||||||
| 	struct uci_package *opennds; | 	struct uci_package *opennds; | ||||||
|  | 	struct uci_context *nds_ctx; | ||||||
| 	struct uci_element *e = NULL, *tmp = NULL; | 	struct uci_element *e = NULL, *tmp = NULL; | ||||||
| 	int ret = 0; | 	int ret = 0; | ||||||
|  |  | ||||||
| 	ret= uci_load(uci, "opennds", &opennds); | 	nds_ctx = uci_alloc_context(); | ||||||
|  | 	ret = uci_load(nds_ctx, "opennds", &opennds); | ||||||
| 	if (ret) { | 	if (ret) { | ||||||
| 		LOGD("%s: uci_load() failed with rc %d", section_name, ret); | 		LOGE("%s: %s uci_load() failed with rc %d", section_name, __func__, ret); | ||||||
|  | 		uci_free_context(nds_ctx); | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 	uci_foreach_element_safe(&opennds->sections, tmp, e) { | 	uci_foreach_element_safe(&opennds->sections, tmp, e) { | ||||||
| 		struct uci_section *s = uci_to_section(e); | 		struct uci_section *s = uci_to_section(e); | ||||||
| 		if (!strcmp(s->e.name, section_name)) { | 		if (!strcmp(s->e.name, section_name)) { | ||||||
| 			uci_section_del(uci, "vif", "opennds", (char *)s->e.name, section_name); | 			uci_section_del(nds_ctx, "vif", "opennds", (char *)s->e.name, section_name); | ||||||
| 		} | 		} | ||||||
| 		else { | 		else { | ||||||
| 			continue; | 			continue; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	uci_commit(uci, &opennds, false); |  | ||||||
| 	uci_unload(uci, opennds); | 	uci_commit(nds_ctx, &opennds, false); | ||||||
|  | 	uci_unload(nds_ctx, opennds); | ||||||
|  | 	uci_free_context(nds_ctx); | ||||||
| 	reload_config = 1; | 	reload_config = 1; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -34,7 +34,7 @@ ovsdb_table_t table_Hotspot20_Icon_Config; | |||||||
|  |  | ||||||
| ovsdb_table_t table_APC_Config; | ovsdb_table_t table_APC_Config; | ||||||
| ovsdb_table_t table_APC_State; | ovsdb_table_t table_APC_State; | ||||||
| unsigned int radproxy_apc; | unsigned int radproxy_apc = 0; | ||||||
|  |  | ||||||
| static struct uci_package *wireless; | static struct uci_package *wireless; | ||||||
| struct uci_context *uci; | struct uci_context *uci; | ||||||
| @@ -445,6 +445,7 @@ static void periodic_task(void *arg) | |||||||
| { | { | ||||||
| 	static int counter = 0; | 	static int counter = 0; | ||||||
| 	struct uci_element *e = NULL, *tmp = NULL; | 	struct uci_element *e = NULL, *tmp = NULL; | ||||||
|  | 	int ret = 0; | ||||||
|  |  | ||||||
| 	if ((counter % 15) && !reload_config) | 	if ((counter % 15) && !reload_config) | ||||||
| 		goto done; | 		goto done; | ||||||
| @@ -468,9 +469,12 @@ static void periodic_task(void *arg) | |||||||
| 		system("reload_config"); | 		system("reload_config"); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	LOGT("periodic: start state update "); | 	LOGD("periodic: start state update "); | ||||||
|  | 	ret = uci_load(uci, "wireless", &wireless); | ||||||
| 	uci_load(uci, "wireless", &wireless); | 	if (ret) { | ||||||
|  | 		LOGE("%s: uci_load() failed with rc %d", __func__, ret); | ||||||
|  | 		return; | ||||||
|  | 	} | ||||||
| 	uci_foreach_element_safe(&wireless->sections, tmp, e) { | 	uci_foreach_element_safe(&wireless->sections, tmp, e) { | ||||||
| 		struct uci_section *s = uci_to_section(e); | 		struct uci_section *s = uci_to_section(e); | ||||||
|  |  | ||||||
| @@ -485,7 +489,7 @@ static void periodic_task(void *arg) | |||||||
| 			vif_state_update(s, NULL); | 			vif_state_update(s, NULL); | ||||||
| 	} | 	} | ||||||
| 	uci_unload(uci, wireless); | 	uci_unload(uci, wireless); | ||||||
| 	LOGT("periodic: stop state update "); | 	LOGD("periodic: stop state update "); | ||||||
|  |  | ||||||
| done: | done: | ||||||
| 	counter++; | 	counter++; | ||||||
| @@ -691,43 +695,34 @@ const struct uci_blob_param_list apc_param = { | |||||||
|  |  | ||||||
| void APC_config_update(struct schema_APC_Config *conf) | void APC_config_update(struct schema_APC_Config *conf) | ||||||
| { | { | ||||||
| 	struct uci_package *apc; |  | ||||||
| 	struct blob_buf apcb = { }; | 	struct blob_buf apcb = { }; | ||||||
| 	int rc = 0; | 	struct uci_context *apc_uci; | ||||||
|  |  | ||||||
| 	LOGD("APC: APC_config_update"); | 	apc_uci = uci_alloc_context(); | ||||||
|  |  | ||||||
| 	rc = uci_load(uci, "apc", &apc); |  | ||||||
| 	if (rc) |  | ||||||
| 	{ |  | ||||||
| 		LOGD("%s: uci_load failed with rc %d", __func__, rc); |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	blob_buf_init(&apcb, 0); | 	blob_buf_init(&apcb, 0); | ||||||
|  | 	if (conf && conf->enabled == true) { | ||||||
|  	if (conf->enabled_changed) { |  | ||||||
| 		if (conf->enabled == true) { |  | ||||||
| 		blobmsg_add_bool(&apcb, "enabled", 1); | 		blobmsg_add_bool(&apcb, "enabled", 1); | ||||||
| 		system("/etc/init.d/apc start"); | 		system("/etc/init.d/apc start"); | ||||||
| 		} | 	} else { | ||||||
| 		else { |  | ||||||
| 		blobmsg_add_bool(&apcb, "enabled", 0); | 		blobmsg_add_bool(&apcb, "enabled", 0); | ||||||
| 		system("/etc/init.d/apc stop"); | 		system("/etc/init.d/apc stop"); | ||||||
| 	} | 	} | ||||||
| 	} |  | ||||||
|  |  | ||||||
|         blob_to_uci_section(uci, "apc", "apc", "apc", | 	blob_to_uci_section(apc_uci, "apc", "apc", "apc", | ||||||
| 			apcb.head, &apc_param, NULL); | 			apcb.head, &apc_param, NULL); | ||||||
|  |  | ||||||
| 	uci_commit(uci, &apc, false); | 	uci_commit_all(apc_uci); | ||||||
| 	uci_unload(uci, apc); | 	uci_free_context(apc_uci); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void callback_APC_Config(ovsdb_update_monitor_t *mon, | static void callback_APC_Config(ovsdb_update_monitor_t *mon, | ||||||
|                                 struct schema_APC_Config *old, |                                 struct schema_APC_Config *old, | ||||||
|                                 struct schema_APC_Config *conf) |                                 struct schema_APC_Config *conf) | ||||||
| { | { | ||||||
| 	if (mon->mon_type != OVSDB_UPDATE_DEL) | 	if (mon->mon_type == OVSDB_UPDATE_DEL) | ||||||
|  | 		APC_config_update(NULL); | ||||||
|  | 	else | ||||||
| 		APC_config_update(conf); | 		APC_config_update(conf); | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -47,8 +47,10 @@ enum { | |||||||
|  |  | ||||||
| enum { | enum { | ||||||
| 	RADIUS_PROXY_SERVER_NAME, | 	RADIUS_PROXY_SERVER_NAME, | ||||||
|  | 	RADIUS_PROXY_SERVER_HOST, | ||||||
| 	RADIUS_PROXY_SERVER_TYPE, | 	RADIUS_PROXY_SERVER_TYPE, | ||||||
| 	RADIUS_PROXY_SERVER_SECRET, | 	RADIUS_PROXY_SERVER_SECRET, | ||||||
|  | 	RADIUS_PROXY_SERVER_PORT, | ||||||
| 	RADIUS_PROXY_SERVER_STATUS, | 	RADIUS_PROXY_SERVER_STATUS, | ||||||
| 	RADIUS_PROXY_SERVER_TLS, | 	RADIUS_PROXY_SERVER_TLS, | ||||||
| 	RADIUS_PROXY_SERVER_CERT_NAME_CHECK, | 	RADIUS_PROXY_SERVER_CERT_NAME_CHECK, | ||||||
| @@ -92,8 +94,10 @@ static const struct blobmsg_policy radius_proxy_tls_policy[__RADIUS_PROXY_TLS_MA | |||||||
|  |  | ||||||
| static const struct blobmsg_policy radius_proxy_server_policy[__RADIUS_PROXY_SERVER_MAX] = { | static const struct blobmsg_policy radius_proxy_server_policy[__RADIUS_PROXY_SERVER_MAX] = { | ||||||
| 		[RADIUS_PROXY_SERVER_NAME] = { .name = "name", BLOBMSG_TYPE_STRING }, | 		[RADIUS_PROXY_SERVER_NAME] = { .name = "name", BLOBMSG_TYPE_STRING }, | ||||||
|  | 		[RADIUS_PROXY_SERVER_HOST] = { .name = "host", BLOBMSG_TYPE_STRING }, | ||||||
| 		[RADIUS_PROXY_SERVER_TYPE] = { .name = "type", BLOBMSG_TYPE_STRING }, | 		[RADIUS_PROXY_SERVER_TYPE] = { .name = "type", BLOBMSG_TYPE_STRING }, | ||||||
| 		[RADIUS_PROXY_SERVER_SECRET] = { .name = "secret", BLOBMSG_TYPE_STRING }, | 		[RADIUS_PROXY_SERVER_SECRET] = { .name = "secret", BLOBMSG_TYPE_STRING }, | ||||||
|  | 		[RADIUS_PROXY_SERVER_PORT] = { .name = "port", BLOBMSG_TYPE_INT32 }, | ||||||
| 		[RADIUS_PROXY_SERVER_STATUS] = { .name = "statusServer", BLOBMSG_TYPE_BOOL }, | 		[RADIUS_PROXY_SERVER_STATUS] = { .name = "statusServer", BLOBMSG_TYPE_BOOL }, | ||||||
| 		[RADIUS_PROXY_SERVER_TLS] = { .name = "tls", BLOBMSG_TYPE_STRING }, | 		[RADIUS_PROXY_SERVER_TLS] = { .name = "tls", BLOBMSG_TYPE_STRING }, | ||||||
| 		[RADIUS_PROXY_SERVER_CERT_NAME_CHECK] = { .name = "certificateNameCheck", BLOBMSG_TYPE_BOOL }, | 		[RADIUS_PROXY_SERVER_CERT_NAME_CHECK] = { .name = "certificateNameCheck", BLOBMSG_TYPE_BOOL }, | ||||||
| @@ -140,17 +144,27 @@ static bool radsec_download_cert(char *cert_name, char *dir_name, char *cert_url | |||||||
| { | { | ||||||
| 	CURL *curl; | 	CURL *curl; | ||||||
| 	FILE *fp; | 	FILE *fp; | ||||||
| 	CURLcode res; | 	CURLcode curl_ret; | ||||||
| 	char path[200]; | 	char path[200]; | ||||||
|  | 	char dir_path[200]; | ||||||
| 	char name[32]; | 	char name[32]; | ||||||
| 	char dir[32]; | 	char dir[32]; | ||||||
| 	char *gw_clientcert = "/usr/opensync/certs/client.pem"; | 	char *gw_clientcert = "/usr/opensync/certs/client.pem"; | ||||||
| 	char *gw_clientkey = "/usr/opensync/certs/client_dec.key"; | 	char *gw_clientkey = "/usr/opensync/certs/client_dec.key"; | ||||||
|  | 	struct stat stat_buf; | ||||||
|  |  | ||||||
| 	strcpy(name, cert_name); | 	strcpy(name, cert_name); | ||||||
| 	strcpy(dir, dir_name); | 	strcpy(dir, dir_name); | ||||||
|  | 	sprintf(dir_path, "/tmp/radsec/certs/%s", dir); | ||||||
| 	sprintf(path, "/tmp/radsec/certs/%s/%s", dir, name); | 	sprintf(path, "/tmp/radsec/certs/%s/%s", dir, name); | ||||||
|  |  | ||||||
|  | 	if (stat(dir_path, &stat_buf) == -1) | ||||||
|  | 	{ | ||||||
|  | 		char cmd[200]; | ||||||
|  | 		sprintf(cmd, "mkdir -p %s", dir_path); | ||||||
|  | 		system(cmd); | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	curl = curl_easy_init(); | 	curl = curl_easy_init(); | ||||||
| 	if (curl) | 	if (curl) | ||||||
| 	{ | 	{ | ||||||
| @@ -177,10 +191,19 @@ static bool radsec_download_cert(char *cert_name, char *dir_name, char *cert_url | |||||||
| 		curl_easy_setopt(curl, CURLOPT_URL, cert_url); | 		curl_easy_setopt(curl, CURLOPT_URL, cert_url); | ||||||
| 		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, file_write); | 		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, file_write); | ||||||
| 		curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); | 		curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); | ||||||
| 		res = curl_easy_perform(curl); | 		curl_ret = curl_easy_perform(curl); | ||||||
|  |  | ||||||
|  | 		if (curl_ret != CURLE_OK) | ||||||
|  | 		{ | ||||||
|  | 			LOGE("radsec: certificate download failed %s", curl_easy_strerror(curl_ret)); | ||||||
|  | 			curl_easy_cleanup(curl); | ||||||
|  | 			fclose(fp); | ||||||
|  | 			remove(path); | ||||||
|  | 			return false; | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 		curl_easy_cleanup(curl); | 		curl_easy_cleanup(curl); | ||||||
| 		fclose(fp); | 		fclose(fp); | ||||||
| 		return res; |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	return true; | 	return true; | ||||||
| @@ -191,6 +214,9 @@ static bool radius_proxy_config_set(struct schema_Radius_Proxy_Config *conf ) | |||||||
| 	int i=0; | 	int i=0; | ||||||
| 	char path[200]; | 	char path[200]; | ||||||
| 	char name[256]; | 	char name[256]; | ||||||
|  | 	char server_name[256] = {}; | ||||||
|  | 	char acct_server_name[256] = {}; | ||||||
|  | 	char tls_name[256] = {}; | ||||||
| 	struct schema_APC_State apc_conf; | 	struct schema_APC_State apc_conf; | ||||||
|  |  | ||||||
| 	/* Configure only if APC selects this as master AP (DR) */ | 	/* Configure only if APC selects this as master AP (DR) */ | ||||||
| @@ -226,6 +252,9 @@ static bool radius_proxy_config_set(struct schema_Radius_Proxy_Config *conf ) | |||||||
| 			uci_buf.head, &radius_proxy_client_param, NULL); | 			uci_buf.head, &radius_proxy_client_param, NULL); | ||||||
|  |  | ||||||
| 	/* Configure TLS/non-TLS and server blocks */ | 	/* Configure TLS/non-TLS and server blocks */ | ||||||
|  | 	sprintf(server_name, "%s%s", conf->radius_config_name, "server"); | ||||||
|  | 	sprintf(acct_server_name, "%s%s", conf->radius_config_name, "Acctserver"); | ||||||
|  | 	sprintf(tls_name, "%s%s", conf->radius_config_name, "tls"); | ||||||
| 	if (conf->radsec) | 	if (conf->radsec) | ||||||
| 	{ | 	{ | ||||||
| 		blob_buf_init(&uci_buf, 0); | 		blob_buf_init(&uci_buf, 0); | ||||||
| @@ -236,7 +265,7 @@ static bool radius_proxy_config_set(struct schema_Radius_Proxy_Config *conf ) | |||||||
| 		radsec_download_cert("clientdec.key", | 		radsec_download_cert("clientdec.key", | ||||||
| 				conf->radius_config_name, conf->client_key); | 				conf->radius_config_name, conf->client_key); | ||||||
|  |  | ||||||
| 		blobmsg_add_string(&uci_buf, "name", conf->server); | 		blobmsg_add_string(&uci_buf, "name", tls_name); | ||||||
|  |  | ||||||
| 		memset(path, '\0', sizeof(path)); | 		memset(path, '\0', sizeof(path)); | ||||||
| 		sprintf(path, "/tmp/radsec/certs/%s/cacert.pem", | 		sprintf(path, "/tmp/radsec/certs/%s/cacert.pem", | ||||||
| @@ -256,34 +285,49 @@ static bool radius_proxy_config_set(struct schema_Radius_Proxy_Config *conf ) | |||||||
| 		if (strlen(conf->passphrase) > 0) | 		if (strlen(conf->passphrase) > 0) | ||||||
| 			blobmsg_add_string(&uci_buf, "certificateKeyPassword", conf->passphrase); | 			blobmsg_add_string(&uci_buf, "certificateKeyPassword", conf->passphrase); | ||||||
|  |  | ||||||
| 		memset(name, '\0', sizeof(name)); | 		blob_to_uci_section(uci, "radsecproxy", tls_name, | ||||||
| 		sprintf(name, "%s%s", conf->radius_config_name, "tls"); |  | ||||||
| 		blob_to_uci_section(uci, "radsecproxy", name, |  | ||||||
| 				"tls", uci_buf.head, &radius_proxy_tls_param, NULL); | 				"tls", uci_buf.head, &radius_proxy_tls_param, NULL); | ||||||
|  |  | ||||||
| 		blob_buf_init(&uci_buf, 0); | 		blob_buf_init(&uci_buf, 0); | ||||||
| 		blobmsg_add_string(&uci_buf, "name", conf->server); | 		blobmsg_add_string(&uci_buf, "name", server_name); | ||||||
|  | 		blobmsg_add_string(&uci_buf, "host", conf->server); | ||||||
| 		blobmsg_add_string(&uci_buf, "type", "tls"); | 		blobmsg_add_string(&uci_buf, "type", "tls"); | ||||||
| 		blobmsg_add_string(&uci_buf, "tls", conf->server); | 		blobmsg_add_string(&uci_buf, "tls", tls_name); | ||||||
|  | 		blobmsg_add_u32(&uci_buf, "port", conf->port); | ||||||
| 		blobmsg_add_string(&uci_buf, "secret", "radsec"); | 		blobmsg_add_string(&uci_buf, "secret", "radsec"); | ||||||
| 		blobmsg_add_bool(&uci_buf, "statusServer", 0); | 		blobmsg_add_bool(&uci_buf, "statusServer", 0); | ||||||
| 		blobmsg_add_bool(&uci_buf, "certificateNameCheck", 0); | 		blobmsg_add_bool(&uci_buf, "certificateNameCheck", 0); | ||||||
| 		memset(name, '\0', sizeof(name)); | 		blob_to_uci_section(uci, "radsecproxy", server_name, "server", | ||||||
| 		sprintf(name, "%s%s", conf->radius_config_name, "server"); |  | ||||||
| 		blob_to_uci_section(uci, "radsecproxy", name, "server", |  | ||||||
| 				uci_buf.head, &radius_proxy_server_param, NULL); | 				uci_buf.head, &radius_proxy_server_param, NULL); | ||||||
| 	} | 	} | ||||||
| 	else /* non-TLS block */ | 	else /* non-TLS block */ | ||||||
| 	{ | 	{ | ||||||
|  | 		/* Authentication server */ | ||||||
| 		blob_buf_init(&uci_buf, 0); | 		blob_buf_init(&uci_buf, 0); | ||||||
| 		blobmsg_add_string(&uci_buf, "name", conf->server); | 		blobmsg_add_string(&uci_buf, "name", server_name); | ||||||
|  | 		blobmsg_add_string(&uci_buf, "host", conf->server); | ||||||
| 		blobmsg_add_string(&uci_buf, "type", "udp"); | 		blobmsg_add_string(&uci_buf, "type", "udp"); | ||||||
| 		if (strlen(conf->secret) > 0) | 		if (strlen(conf->secret) > 0) | ||||||
| 			blobmsg_add_string(&uci_buf, "secret", conf->secret); | 			blobmsg_add_string(&uci_buf, "secret", conf->secret); | ||||||
| 		memset(name, '\0', sizeof(name)); | 		if (conf->port > 0) | ||||||
| 		sprintf(name, "%s%s", conf->radius_config_name, "server"); | 			blobmsg_add_u32(&uci_buf, "port", conf->port); | ||||||
| 		blob_to_uci_section(uci, "radsecproxy", name, "server", | 		blob_to_uci_section(uci, "radsecproxy", server_name, "server", | ||||||
| 				uci_buf.head, &radius_proxy_server_param, NULL); | 				uci_buf.head, &radius_proxy_server_param, NULL); | ||||||
|  |  | ||||||
|  | 		/* Accounting server */ | ||||||
|  | 		if (strlen(conf->acct_server) > 0) | ||||||
|  | 		{ | ||||||
|  | 			blob_buf_init(&uci_buf, 0); | ||||||
|  | 			blobmsg_add_string(&uci_buf, "name", acct_server_name); | ||||||
|  | 			blobmsg_add_string(&uci_buf, "host", conf->acct_server); | ||||||
|  | 			blobmsg_add_string(&uci_buf, "type", "udp"); | ||||||
|  | 			if (strlen(conf->secret) > 0) | ||||||
|  | 				blobmsg_add_string(&uci_buf, "secret", conf->acct_secret); | ||||||
|  | 			if (conf->acct_port > 0) | ||||||
|  | 				blobmsg_add_u32(&uci_buf, "port", conf->acct_port); | ||||||
|  | 			blob_to_uci_section(uci, "radsecproxy", acct_server_name, "server", | ||||||
|  | 								uci_buf.head, &radius_proxy_server_param, NULL); | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/* Configure realm block */ | 	/* Configure realm block */ | ||||||
| @@ -292,11 +336,20 @@ static bool radius_proxy_config_set(struct schema_Radius_Proxy_Config *conf ) | |||||||
| 		blob_buf_init(&uci_buf, 0); | 		blob_buf_init(&uci_buf, 0); | ||||||
| 		blobmsg_add_string(&uci_buf, "name", conf->realm[i]); | 		blobmsg_add_string(&uci_buf, "name", conf->realm[i]); | ||||||
| 		n = blobmsg_open_array(&uci_buf,"server"); | 		n = blobmsg_open_array(&uci_buf,"server"); | ||||||
| 		blobmsg_add_string(&uci_buf, NULL, conf->server); | 		blobmsg_add_string(&uci_buf, NULL, server_name); | ||||||
| 		blobmsg_close_array(&uci_buf, n); | 		blobmsg_close_array(&uci_buf, n); | ||||||
|  | 		if (conf->radsec) | ||||||
|  | 		{ /* Accounting server same as auth server */ | ||||||
| 			n = blobmsg_open_array(&uci_buf, "accountingServer"); | 			n = blobmsg_open_array(&uci_buf, "accountingServer"); | ||||||
| 		blobmsg_add_string(&uci_buf, NULL, conf->server); | 			blobmsg_add_string(&uci_buf, NULL, server_name); | ||||||
| 			blobmsg_close_array(&uci_buf, n); | 			blobmsg_close_array(&uci_buf, n); | ||||||
|  | 		} | ||||||
|  | 		else if (strlen(conf->acct_server) > 0) | ||||||
|  | 		{ /* non-TLS case where accounting server is configured */ | ||||||
|  | 			n = blobmsg_open_array(&uci_buf, "accountingServer"); | ||||||
|  | 			blobmsg_add_string(&uci_buf, NULL, acct_server_name); | ||||||
|  | 			blobmsg_close_array(&uci_buf, n); | ||||||
|  | 		} | ||||||
| 		memset(name, '\0', sizeof(name)); | 		memset(name, '\0', sizeof(name)); | ||||||
| 		sprintf(name, "%s%s%d", conf->radius_config_name, "realm", i); | 		sprintf(name, "%s%s%d", conf->radius_config_name, "realm", i); | ||||||
| 		blob_to_uci_section(uci, "radsecproxy", name, "realm", | 		blob_to_uci_section(uci, "radsecproxy", name, "realm", | ||||||
| @@ -310,22 +363,27 @@ static bool radius_proxy_config_set(struct schema_Radius_Proxy_Config *conf ) | |||||||
| static bool radius_proxy_config_delete() | static bool radius_proxy_config_delete() | ||||||
| { | { | ||||||
| 	struct uci_package *radsecproxy; | 	struct uci_package *radsecproxy; | ||||||
|  | 	struct uci_context *rad_uci; | ||||||
| 	struct uci_element *e = NULL, *tmp = NULL; | 	struct uci_element *e = NULL, *tmp = NULL; | ||||||
| 	int ret = 0; | 	int ret = 0; | ||||||
|  |  | ||||||
| 	ret= uci_load(uci, "radsecproxy", &radsecproxy); | 	rad_uci = uci_alloc_context(); | ||||||
|  |  | ||||||
|  | 	ret = uci_load(rad_uci, "radsecproxy", &radsecproxy); | ||||||
| 	if (ret) { | 	if (ret) { | ||||||
| 		LOGD("%s: uci_load() failed with rc %d", __func__, ret); | 		LOGE("%s: uci_load() failed with rc %d", __func__, ret); | ||||||
|  | 		uci_free_context(rad_uci); | ||||||
| 		return false; | 		return false; | ||||||
| 	} | 	} | ||||||
| 	uci_foreach_element_safe(&radsecproxy->sections, tmp, e) { | 	uci_foreach_element_safe(&radsecproxy->sections, tmp, e) { | ||||||
| 		struct uci_section *s = uci_to_section(e); | 		struct uci_section *s = uci_to_section(e); | ||||||
| 		if ((s == NULL) || (s->type == NULL)) continue; | 		if ((s == NULL) || (s->type == NULL)) continue; | ||||||
| 		uci_section_del(uci, "radsecproxy", "radsecproxy", | 		uci_section_del(rad_uci, "radsecproxy", "radsecproxy", | ||||||
| 				(char *)s->e.name, s->type); | 				(char *)s->e.name, s->type); | ||||||
| 	} | 	} | ||||||
| 	uci_commit(uci, &radsecproxy, false); | 	uci_commit(rad_uci, &radsecproxy, false); | ||||||
| 	uci_unload(uci, radsecproxy); | 	uci_unload(rad_uci, radsecproxy); | ||||||
|  | 	uci_free_context(rad_uci); | ||||||
| 	reload_config = 1; | 	reload_config = 1; | ||||||
| 	return true; | 	return true; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -47,8 +47,19 @@ void rrm_config_vif(struct blob_buf *b, struct blob_buf *del, const char * freq_ | |||||||
| 		blobmsg_add_u32(b, "rssi_ignore_probe_request", conf.probe_resp_threshold); | 		blobmsg_add_u32(b, "rssi_ignore_probe_request", conf.probe_resp_threshold); | ||||||
| 		blobmsg_add_u32(b, "signal_connect", conf.client_disconnect_threshold); | 		blobmsg_add_u32(b, "signal_connect", conf.client_disconnect_threshold); | ||||||
| 		blobmsg_add_u32(b, "signal_stay", conf.client_disconnect_threshold); | 		blobmsg_add_u32(b, "signal_stay", conf.client_disconnect_threshold); | ||||||
| 		blobmsg_add_u32(b, "bcn_rate", conf.beacon_rate); |  | ||||||
| 		blobmsg_add_u32(b, "mcast_rate", conf.mcast_rate); | 		blobmsg_add_u32(b, "mcast_rate", conf.mcast_rate); | ||||||
|  |  | ||||||
|  | 		if (conf.beacon_rate == 0) { | ||||||
|  | 			// Default to the lowest possible bit rate for each frequency band | ||||||
|  | 			if (!strcmp(freq_band, "2.4G")) { | ||||||
|  | 				blobmsg_add_u32(b, "bcn_rate", 10); | ||||||
|  | 			} else { | ||||||
|  | 				blobmsg_add_u32(b, "bcn_rate", 60); | ||||||
|  | 			} | ||||||
|  | 		} else { | ||||||
|  | 			blobmsg_add_u32(b, "bcn_rate", conf.beacon_rate); | ||||||
|  | 		} | ||||||
|  | 		 | ||||||
| 	} | 	} | ||||||
| 	return; | 	return; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -210,8 +210,10 @@ int uci_section_to_blob(struct uci_context *uci, char *package, char *section, | |||||||
|  |  | ||||||
| 	if (uci_load(uci, package, &p)) | 	if (uci_load(uci, package, &p)) | ||||||
| 		p = uci_lookup_package(uci, package); | 		p = uci_lookup_package(uci, package); | ||||||
| 	if (!p) | 	if (!p) { | ||||||
|  | 		uci_unload(uci, p); | ||||||
| 		return -1; | 		return -1; | ||||||
|  | 	} | ||||||
| 	s = uci_lookup_section(uci, p, section); | 	s = uci_lookup_section(uci, p, section); | ||||||
| 	if (!s) | 	if (!s) | ||||||
| 		goto out; | 		goto out; | ||||||
|   | |||||||
| @@ -1020,30 +1020,31 @@ size_t write_file(void *ptr, size_t size, size_t nmemb, FILE *stream) { | |||||||
|  |  | ||||||
| void vif_section_del(char *section_name) | void vif_section_del(char *section_name) | ||||||
| { | { | ||||||
|  |  | ||||||
| 	struct uci_package *wireless; | 	struct uci_package *wireless; | ||||||
|  | 	struct uci_context *sec_ctx; | ||||||
| 	struct uci_element *e = NULL, *tmp = NULL; | 	struct uci_element *e = NULL, *tmp = NULL; | ||||||
| 	int ret=0; | 	int ret=0; | ||||||
|  | 	sec_ctx = uci_alloc_context(); | ||||||
| 	ret= uci_load(uci, "wireless", &wireless); | 	ret= uci_load(sec_ctx, "wireless", &wireless); | ||||||
| 	if (ret) { | 	if (ret) { | ||||||
| 		LOGD("%s: uci_load() failed with rc %d", section_name, ret); | 		LOGE("%s: %s uci_load() failed with rc %d", section_name, __func__, ret); | ||||||
|  | 		uci_free_context(sec_ctx); | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 	uci_foreach_element_safe(&wireless->sections, tmp, e) { | 	uci_foreach_element_safe(&wireless->sections, tmp, e) { | ||||||
| 		struct uci_section *s = uci_to_section(e); | 		struct uci_section *s = uci_to_section(e); | ||||||
| 		if ((s == NULL) || (s->type == NULL)) continue; | 		if ((s == NULL) || (s->type == NULL)) continue; | ||||||
| 		if (!strcmp(s->type, section_name)) { | 		if (!strcmp(s->type, section_name)) { | ||||||
| 			uci_section_del(uci, "vif", "wireless", (char *)s->e.name, section_name); | 			uci_section_del(sec_ctx, "vif", "wireless", (char *)s->e.name, section_name); | ||||||
| 		} | 		} | ||||||
| 		else { | 		else { | ||||||
| 			continue; | 			continue; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	uci_commit(uci, &wireless, false); | 	uci_commit(sec_ctx, &wireless, false); | ||||||
| 	uci_unload(uci, wireless); | 	uci_unload(sec_ctx, wireless); | ||||||
|  | 	uci_free_context(sec_ctx); | ||||||
| 	reload_config = 1; | 	reload_config = 1; | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| static void vif_check_radius_proxy() | static void vif_check_radius_proxy() | ||||||
| @@ -1063,12 +1064,10 @@ static void vif_check_radius_proxy() | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	uci_ctx = uci_alloc_context(); | 	uci_ctx = uci_alloc_context(); | ||||||
|  |  | ||||||
| 	rc = uci_load(uci_ctx, "wireless", &wireless); | 	rc = uci_load(uci_ctx, "wireless", &wireless); | ||||||
|  |  | ||||||
| 	if (rc) | 	if (rc) { | ||||||
| 	{ | 		LOGE("%s: uci_load() failed with rc %d", __func__, rc); | ||||||
| 		LOGD("%s: uci_load() failed with rc %d", __func__, rc); |  | ||||||
| 		goto free; | 		goto free; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -1334,14 +1333,17 @@ static void hs20_vif_config(struct blob_buf *b, | |||||||
| bool target_vif_config_del(const struct schema_Wifi_VIF_Config *vconf) | bool target_vif_config_del(const struct schema_Wifi_VIF_Config *vconf) | ||||||
| { | { | ||||||
| 	struct uci_package *wireless; | 	struct uci_package *wireless; | ||||||
|  | 	struct uci_context *vif_ctx; | ||||||
| 	struct uci_element *e = NULL, *tmp = NULL; | 	struct uci_element *e = NULL, *tmp = NULL; | ||||||
| 	const char *ifname; | 	const char *ifname; | ||||||
| 	int ret = 0; | 	int ret = 0; | ||||||
|  |  | ||||||
| 	vlan_del((char *)vconf->if_name); | 	vlan_del((char *)vconf->if_name); | ||||||
| 	ret= uci_load(uci, "wireless", &wireless); | 	vif_ctx = uci_alloc_context(); | ||||||
|  | 	ret= uci_load(vif_ctx, "wireless", &wireless); | ||||||
| 	if (ret) { | 	if (ret) { | ||||||
| 		LOGD("%s: uci_load() failed with rc %d", vconf->if_name, ret); | 		LOGE("%s: %s uci_load() failed with rc %d", vconf->if_name, __func__, ret); | ||||||
|  | 		uci_free_context(vif_ctx); | ||||||
| 		return false; | 		return false; | ||||||
| 	} | 	} | ||||||
| 	uci_foreach_element_safe(&wireless->sections, tmp, e) { | 	uci_foreach_element_safe(&wireless->sections, tmp, e) { | ||||||
| @@ -1349,14 +1351,15 @@ bool target_vif_config_del(const struct schema_Wifi_VIF_Config *vconf) | |||||||
| 		if ((s == NULL) || (s->type == NULL)) continue;  | 		if ((s == NULL) || (s->type == NULL)) continue;  | ||||||
| 		if (strcmp(s->type, "wifi-iface")) continue; | 		if (strcmp(s->type, "wifi-iface")) continue; | ||||||
|  |  | ||||||
| 		ifname = uci_lookup_option_string( uci, s, "ifname" ); | 		ifname = uci_lookup_option_string( vif_ctx, s, "ifname" ); | ||||||
| 		if (!strcmp(ifname,vconf->if_name)) { | 		if (!strcmp(ifname,vconf->if_name)) { | ||||||
| 			uci_section_del(uci, "vif", "wireless", (char *)s->e.name, "wifi-iface"); | 			uci_section_del(vif_ctx, "vif", "wireless", (char *)s->e.name, "wifi-iface"); | ||||||
| 			break; | 			break; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	uci_commit(uci, &wireless, false); | 	uci_commit(vif_ctx, &wireless, false); | ||||||
| 	uci_unload(uci, wireless); | 	uci_unload(vif_ctx, wireless); | ||||||
|  | 	uci_free_context(vif_ctx); | ||||||
| 	reload_config = 1; | 	reload_config = 1; | ||||||
| 	return true; | 	return true; | ||||||
| } | } | ||||||
| @@ -1549,7 +1552,6 @@ static int ap_vif_config_set(const struct schema_Wifi_Radio_Config *rconf, | |||||||
|  |  | ||||||
| 	blob_buf_init(&b, 0); | 	blob_buf_init(&b, 0); | ||||||
| 	blob_buf_init(&del,0); | 	blob_buf_init(&del,0); | ||||||
|  |  | ||||||
| 	blobmsg_add_string(&b, "ifname", vconf->if_name); | 	blobmsg_add_string(&b, "ifname", vconf->if_name); | ||||||
| 	blobmsg_add_string(&b, "device", rconf->if_name); | 	blobmsg_add_string(&b, "device", rconf->if_name); | ||||||
| 	blobmsg_add_string(&b, "mode", "ap"); | 	blobmsg_add_string(&b, "mode", "ap"); | ||||||
|   | |||||||
| @@ -275,8 +275,10 @@ int main(int argc, char ** argv) | |||||||
| 	callback cb = recv_process; | 	callback cb = recv_process; | ||||||
| 	LOGI("Call interap_recv"); | 	LOGI("Call interap_recv"); | ||||||
| 	if( interap_recv(IAC_VOIP_PORT, cb, sizeof(struct voip_session), | 	if( interap_recv(IAC_VOIP_PORT, cb, sizeof(struct voip_session), | ||||||
| 			 loop, &iac_io) < 0) | 			 loop, &iac_io) < 0) { | ||||||
| 		LOGI("Error: Failed InterAP receive"); | 		LOGI("Error: Failed InterAP receive"); | ||||||
|  | 		return 1; | ||||||
|  | 	} | ||||||
|  |  | ||||||
| //	task_init(); | //	task_init(); | ||||||
| 	netlink_listen(loop); | 	netlink_listen(loop); | ||||||
| @@ -291,6 +293,7 @@ int main(int argc, char ** argv) | |||||||
| #endif | #endif | ||||||
| 	ev_default_destroy(); | 	ev_default_destroy(); | ||||||
|  |  | ||||||
|  | 	interap_rcv_close(); | ||||||
| 	LOGN("Exiting UCCM"); | 	LOGN("Exiting UCCM"); | ||||||
|  |  | ||||||
| 	return 0; | 	return 0; | ||||||
|   | |||||||
							
								
								
									
										156
									
								
								patches/0053-ipq807x-fix-edgecore-eap102.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										156
									
								
								patches/0053-ipq807x-fix-edgecore-eap102.patch
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,156 @@ | |||||||
|  | From 4a5ac0aa04a5e6cf9316ce7c16843f0f4a4128ce Mon Sep 17 00:00:00 2001 | ||||||
|  | From: John Crispin <john@phrozen.org> | ||||||
|  | Date: Wed, 12 May 2021 07:00:18 +0200 | ||||||
|  | Subject: [PATCH] ipq807x: fix edgecore eap102 | ||||||
|  |  | ||||||
|  | * import the fixes for the update hardware revision | ||||||
|  |  | ||||||
|  | Signed-off-by: John Crispin <john@phrozen.org> | ||||||
|  | --- | ||||||
|  |  target/linux/ipq807x/base-files/etc/board.d/02_network    | 5 +---- | ||||||
|  |  target/linux/ipq807x/base-files/etc/init.d/bootcount      | 3 ++- | ||||||
|  |  target/linux/ipq807x/base-files/lib/upgrade/platform.sh   | 4 ++-- | ||||||
|  |  .../arch/arm64/boot/dts/qcom/qcom-ipq807x-eap102.dts      | 8 ++++---- | ||||||
|  |  target/linux/ipq807x/image/ipq60xx.mk                     | 6 +++--- | ||||||
|  |  target/linux/ipq807x/image/ipq807x.mk                     | 2 +- | ||||||
|  |  6 files changed, 13 insertions(+), 15 deletions(-) | ||||||
|  |  | ||||||
|  | diff --git a/target/linux/ipq807x/base-files/etc/board.d/02_network b/target/linux/ipq807x/base-files/etc/board.d/02_network | ||||||
|  | index f23a9f3eac..e90a73f7bf 100755 | ||||||
|  | --- a/target/linux/ipq807x/base-files/etc/board.d/02_network | ||||||
|  | +++ b/target/linux/ipq807x/base-files/etc/board.d/02_network | ||||||
|  | @@ -28,6 +28,7 @@ qcom_setup_interfaces() | ||||||
|  |                  ucidef_set_interface_wan "eth0" | ||||||
|  |                  ;; | ||||||
|  |  	cig,wf194c|\ | ||||||
|  | +	edgecore,eap102|\ | ||||||
|  |  	sercomm,wallaby) | ||||||
|  |  		ucidef_set_interface_lan "eth0" | ||||||
|  |  		ucidef_set_interface_wan "eth1" | ||||||
|  | @@ -36,10 +37,6 @@ qcom_setup_interfaces() | ||||||
|  |  		ucidef_set_interface_lan "eth1 eth2" | ||||||
|  |  		ucidef_set_interface_wan "eth0" | ||||||
|  |  		;; | ||||||
|  | -	edgecore,eap102) | ||||||
|  | -		ucidef_set_interface_lan "eth1" | ||||||
|  | -		ucidef_set_interface_wan "eth0" | ||||||
|  | -		;; | ||||||
|  |  	esac | ||||||
|  |  } | ||||||
|  |   | ||||||
|  | diff --git a/target/linux/ipq807x/base-files/etc/init.d/bootcount b/target/linux/ipq807x/base-files/etc/init.d/bootcount | ||||||
|  | index ac345d6d4a..a24f27353e 100755 | ||||||
|  | --- a/target/linux/ipq807x/base-files/etc/init.d/bootcount | ||||||
|  | +++ b/target/linux/ipq807x/base-files/etc/init.d/bootcount | ||||||
|  | @@ -4,7 +4,8 @@ START=99 | ||||||
|  |   | ||||||
|  |  boot() { | ||||||
|  |  	case "$(board_name)" in | ||||||
|  | -	edgecore,eap101) | ||||||
|  | +	edgecore,eap101|\ | ||||||
|  | +	edgecore,eap102) | ||||||
|  |  		fw_setenv bootcount 0 | ||||||
|  |  		;; | ||||||
|  |  	esac | ||||||
|  | diff --git a/target/linux/ipq807x/base-files/lib/upgrade/platform.sh b/target/linux/ipq807x/base-files/lib/upgrade/platform.sh | ||||||
|  | index 59d1578925..a520df40d7 100755 | ||||||
|  | --- a/target/linux/ipq807x/base-files/lib/upgrade/platform.sh | ||||||
|  | +++ b/target/linux/ipq807x/base-files/lib/upgrade/platform.sh | ||||||
|  | @@ -48,7 +48,6 @@ platform_do_upgrade() { | ||||||
|  |  		;; | ||||||
|  |  	cig,wf188n|\ | ||||||
|  |  	cig,wf194c|\ | ||||||
|  | -	edgecore,eap102|\ | ||||||
|  |  	qcom,ipq6018-cp01|\ | ||||||
|  |  	qcom,ipq807x-hk01|\ | ||||||
|  |  	sercomm,wallaby|\ | ||||||
|  | @@ -56,7 +55,8 @@ platform_do_upgrade() { | ||||||
|  |  	tplink,ex227) | ||||||
|  |  		nand_upgrade_tar "$1" | ||||||
|  |  		;; | ||||||
|  | -	edgecore,eap101) | ||||||
|  | +	edgecore,eap101|\ | ||||||
|  | +	edgecore,eap102) | ||||||
|  |  		CI_UBIPART="rootfs1" | ||||||
|  |  		nand_upgrade_tar "$1" | ||||||
|  |  		;; | ||||||
|  | diff --git a/target/linux/ipq807x/files/arch/arm64/boot/dts/qcom/qcom-ipq807x-eap102.dts b/target/linux/ipq807x/files/arch/arm64/boot/dts/qcom/qcom-ipq807x-eap102.dts | ||||||
|  | index e8157f5514..cf822c246e 100755 | ||||||
|  | --- a/target/linux/ipq807x/files/arch/arm64/boot/dts/qcom/qcom-ipq807x-eap102.dts | ||||||
|  | +++ b/target/linux/ipq807x/files/arch/arm64/boot/dts/qcom/qcom-ipq807x-eap102.dts | ||||||
|  | @@ -32,8 +32,8 @@ | ||||||
|  |  		 * Aliases as required by u-boot | ||||||
|  |  		 * to patch MAC addresses | ||||||
|  |  		 */ | ||||||
|  | -		ethernet0 = "/soc/dp5"; | ||||||
|  | -		ethernet1 = "/soc/dp6"; | ||||||
|  | +		ethernet0 = "/soc/dp6"; | ||||||
|  | +		ethernet1 = "/soc/dp5"; | ||||||
|  |   | ||||||
|  |  		led-boot = &led_power; | ||||||
|  |  		led-failsafe = &led_power; | ||||||
|  | @@ -593,7 +593,7 @@ | ||||||
|  |  		}; | ||||||
|  |  	}; | ||||||
|  |   | ||||||
|  | -	dp1 { | ||||||
|  | +/*	dp1 { | ||||||
|  |  		device_type = "network"; | ||||||
|  |  		compatible = "qcom,nss-dp"; | ||||||
|  |  		qcom,id = <1>; | ||||||
|  | @@ -639,7 +639,7 @@ | ||||||
|  |  		qcom,link-poll = <1>; | ||||||
|  |  		qcom,phy-mdio-addr = <3>; | ||||||
|  |  		phy-mode = "sgmii"; | ||||||
|  | -	}; | ||||||
|  | +	};*/ | ||||||
|  |   | ||||||
|  |  	dp5 { | ||||||
|  |  		device_type = "network"; | ||||||
|  | diff --git a/target/linux/ipq807x/image/ipq60xx.mk b/target/linux/ipq807x/image/ipq60xx.mk | ||||||
|  | index c536a174f8..201885a760 100644 | ||||||
|  | --- a/target/linux/ipq807x/image/ipq60xx.mk | ||||||
|  | +++ b/target/linux/ipq807x/image/ipq60xx.mk | ||||||
|  | @@ -7,7 +7,7 @@ define Device/cig_wf188 | ||||||
|  |    SUPPORTED_DEVICES := cig,wf188 | ||||||
|  |    IMAGES := sysupgrade.tar | ||||||
|  |    IMAGE/sysupgrade.tar/squashfs := append-rootfs | pad-rootfs | sysupgrade-tar rootfs=$$$$@ | append-metadata | ||||||
|  | -  DEVICE_PACKAGES := ath11k-wifi-cig-wf188 uboot-env | ||||||
|  | +  DEVICE_PACKAGES := ath11k-wifi-cig-wf188 uboot-envtools | ||||||
|  |  endef | ||||||
|  |  TARGET_DEVICES += cig_wf188 | ||||||
|  |   | ||||||
|  | @@ -16,7 +16,7 @@ define Device/cig_wf188n | ||||||
|  |    DEVICE_DTS := qcom-ipq6018-cig-wf188n | ||||||
|  |    DEVICE_DTS_CONFIG := config@cp03-c1 | ||||||
|  |    SUPPORTED_DEVICES := cig,wf188n | ||||||
|  | -  DEVICE_PACKAGES := ath11k-wifi-cig-wf188n uboot-env | ||||||
|  | +  DEVICE_PACKAGES := ath11k-wifi-cig-wf188n uboot-envtools | ||||||
|  |  endef | ||||||
|  |  TARGET_DEVICES += cig_wf188n | ||||||
|  |   | ||||||
|  | @@ -25,7 +25,7 @@ define Device/edgecore_eap101 | ||||||
|  |    DEVICE_DTS := qcom-ipq6018-edgecore-eap101 | ||||||
|  |    DEVICE_DTS_CONFIG := config@cp01-c1 | ||||||
|  |    SUPPORTED_DEVICES := edgecore,eap101 | ||||||
|  | -  DEVICE_PACKAGES := ath11k-wifi-edgecore-eap101 uboot-env | ||||||
|  | +  DEVICE_PACKAGES := ath11k-wifi-edgecore-eap101 uboot-envtools | ||||||
|  |  endef | ||||||
|  |  TARGET_DEVICES += edgecore_eap101 | ||||||
|  |   | ||||||
|  | diff --git a/target/linux/ipq807x/image/ipq807x.mk b/target/linux/ipq807x/image/ipq807x.mk | ||||||
|  | index 7081769407..000d2793c9 100644 | ||||||
|  | --- a/target/linux/ipq807x/image/ipq807x.mk | ||||||
|  | +++ b/target/linux/ipq807x/image/ipq807x.mk | ||||||
|  | @@ -41,7 +41,7 @@ define Device/edgecore_eap102 | ||||||
|  |    DEVICE_DTS := qcom-ipq807x-eap102 | ||||||
|  |    DEVICE_DTS_CONFIG=config@ac02 | ||||||
|  |    SUPPORTED_DEVICES := edgecore,eap102 | ||||||
|  | -  DEVICE_PACKAGES := ath11k-wifi-edgecore-eap102 kmod-usb3 kmod-usb2 | ||||||
|  | +  DEVICE_PACKAGES := ath11k-wifi-edgecore-eap102 kmod-usb2 uboot-envtools | ||||||
|  |  endef | ||||||
|  |  TARGET_DEVICES += edgecore_eap102 | ||||||
|  |  define Device/tplink_ex227 | ||||||
|  | --  | ||||||
|  | 2.25.1 | ||||||
|  |  | ||||||
		Reference in New Issue
	
	Block a user