mirror of
				https://github.com/Telecominfraproject/wlan-ap.git
				synced 2025-10-31 02:17:58 +00:00 
			
		
		
		
	Compare commits
	
		
			6 Commits
		
	
	
		
			v1.0.2
			...
			release/v1
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 7bcd7093d2 | ||
|   | f273ec572e | ||
|   | 5fd49f6b64 | ||
|   | f3fc398eac | ||
|   | 7aea689d9a | ||
|   | 7a634d80ed | 
| @@ -30,4 +30,9 @@ static inline timer * tm_new_set( void (*hook)(struct _timer *), void *data, uns | |||||||
|     return t; |     return t; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | static inline void tm_free(timer *t) | ||||||
|  | { | ||||||
|  |     free(t); | ||||||
|  | } | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
|   | |||||||
| @@ -27,6 +27,7 @@ static struct proto * apc_init(struct proto_config * c) | |||||||
| { | { | ||||||
| 	struct proto * P = mb_allocz(sizeof(struct apc_proto)); | 	struct proto * P = mb_allocz(sizeof(struct apc_proto)); | ||||||
|  |  | ||||||
|  | 	printf("apc_init\n"); | ||||||
| 	P->cf = c; | 	P->cf = c; | ||||||
| 	P->debug = c->debug; | 	P->debug = c->debug; | ||||||
| 	P->mrtdump = c->mrtdump; | 	P->mrtdump = c->mrtdump; | ||||||
|   | |||||||
| @@ -103,6 +103,7 @@ void apc_send_hello(struct apc_iface * ifa, int kind ) | |||||||
| 	struct apc_hello2_packet ps; | 	struct apc_hello2_packet ps; | ||||||
| 	unsigned int length, report = 0; | 	unsigned int length, report = 0; | ||||||
| 	struct apc_spec ApcSpec; | 	struct apc_spec ApcSpec; | ||||||
|  | 	char dst_ip[16]; | ||||||
| 	 | 	 | ||||||
| 	if (WaitingToReelect ) | 	if (WaitingToReelect ) | ||||||
| 		return; | 		return; | ||||||
| @@ -203,7 +204,6 @@ void apc_send_hello(struct apc_iface * ifa, int kind ) | |||||||
| 	length += i * sizeof(u32); | 	length += i * sizeof(u32); | ||||||
|  |  | ||||||
| 	printf("HELLO packet sent via  %s\n", ifa->ifname ); | 	printf("HELLO packet sent via  %s\n", ifa->ifname ); | ||||||
| 	char *dst_ip = malloc(16); |  | ||||||
| 	memset(dst_ip, 0, 16); | 	memset(dst_ip, 0, 16); | ||||||
| 	if ((get_current_ip(dst_ip, IAC_IFACE)) < 0) { | 	if ((get_current_ip(dst_ip, IAC_IFACE)) < 0) { | ||||||
| 		printf("Error: Cannot get IP for %s", IAC_IFACE); | 		printf("Error: Cannot get IP for %s", IAC_IFACE); | ||||||
|   | |||||||
| @@ -36,7 +36,7 @@ reset_lists(struct apc_proto *p, struct apc_neighbor *n) | |||||||
| struct apc_neighbor * apc_neighbor_new(struct apc_iface * ifa) | struct apc_neighbor * apc_neighbor_new(struct apc_iface * ifa) | ||||||
| { | { | ||||||
| 	struct apc_neighbor * n = mb_allocz(sizeof(struct apc_neighbor)); | 	struct apc_neighbor * n = mb_allocz(sizeof(struct apc_neighbor)); | ||||||
| 	 | 	printf("apc_new_neighbor\n");	 | ||||||
| 	n->ifa = ifa; | 	n->ifa = ifa; | ||||||
| 	add_tail(&ifa->neigh_list, NODE n); | 	add_tail(&ifa->neigh_list, NODE n); | ||||||
| 	n->adj = 0; | 	n->adj = 0; | ||||||
| @@ -58,6 +58,8 @@ static void apc_neigh_down(struct apc_neighbor * n) | |||||||
| 	rem_node(NODE n); | 	rem_node(NODE n); | ||||||
| 	 | 	 | ||||||
| 	printf("Neighbor %x on %s removed", n->rid, ifa->ifname ); | 	printf("Neighbor %x on %s removed", n->rid, ifa->ifname ); | ||||||
|  | 	tm_free(n->inactim); | ||||||
|  | 	mb_free(n); | ||||||
| } | } | ||||||
|  |  | ||||||
| /** | /** | ||||||
|   | |||||||
| @@ -26,6 +26,7 @@ static void receive_data_uloop(struct uloop_fd *fd, unsigned int events) | |||||||
| 		printf("recvfrom() failed"); | 		printf("recvfrom() failed"); | ||||||
|  |  | ||||||
| 	ra.cb(recv_data, recv_data_len); | 	ra.cb(recv_data, recv_data_len); | ||||||
|  | 	free(recv_data); | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -41,6 +42,7 @@ static void receive_data(struct ev_loop *ev, ev_io *io, int event) | |||||||
| 		printf("recvfrom() failed"); | 		printf("recvfrom() failed"); | ||||||
|  |  | ||||||
| 	ra.cb(recv_data, recv_data_len); | 	ra.cb(recv_data, recv_data_len); | ||||||
|  | 	free(recv_data); | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										4
									
								
								feeds/wlan-ap/opensync/files/bin/wlan_ap_factory_reset.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										4
									
								
								feeds/wlan-ap/opensync/files/bin/wlan_ap_factory_reset.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,4 @@ | |||||||
|  | #!/bin/sh | ||||||
|  |  | ||||||
|  | tar czf /sysupgrade.tgz /usr/opensync/certs/ | ||||||
|  | jffs2reset -r -y -k | ||||||
| @@ -1,12 +1,49 @@ | |||||||
| #!/bin/sh | #!/bin/sh | ||||||
|  |  | ||||||
| if [ $# -ne 1 ] ; then | AP_PRIVATE_KEY_FILE="/usr/opensync/certs/client_dec.key" | ||||||
| 	echo "Usage: $0 <redirector address>" >&2 | AP_CERTIFICATE_FILE="/usr/opensync/certs/client.pem" | ||||||
|  | AP_DEVICE_ID_FILE="/usr/opensync/certs/client_deviceid.txt" | ||||||
|  | DIGICERT_API_URI="clientauth.one.digicert.com" | ||||||
|  |  | ||||||
|  | if [ "$1" = "-h" ]; then | ||||||
|  |   echo "Usage: $0 [redirector address]" >&2 | ||||||
|   exit 1 |   exit 1 | ||||||
| fi | fi | ||||||
|  |  | ||||||
| redirector_addr=$1 | # Query DigiCert's API if redirector wasn't specified | ||||||
|  | if [ -z "$1" ]; then | ||||||
|  |   if [ ! -f "$AP_DEVICE_ID_FILE" ]; then | ||||||
|  |       echo "Device ID file $AP_DEVICE_ID_FILE does not exist. Make sure to create it or specify the redirector address manually." | ||||||
|  |       exit 1 | ||||||
|  |   fi | ||||||
|  |  | ||||||
|  |   digicert_device_id=`cat ${AP_DEVICE_ID_FILE}` | ||||||
|  |   device_data=`curl -s \ | ||||||
|  |     --retry 5 \ | ||||||
|  |     --show-error \ | ||||||
|  |     --key "${AP_PRIVATE_KEY_FILE}" \ | ||||||
|  |     --cert "${AP_CERTIFICATE_FILE}" \ | ||||||
|  |     "https://${DIGICERT_API_URI}/iot/api/v2/device/${digicert_device_id}"` | ||||||
|  |  | ||||||
|  |   controller_url=`echo ${device_data} | jsonfilter -e '@.fields[@.name="Redirector"].value'` | ||||||
|  |   if [ -z "$controller_url" ]; then | ||||||
|  |     echo "No redirector found for this device" | ||||||
|  |     exit 1 | ||||||
|  |   fi | ||||||
|  |   controller_port=`echo ${controller_url} | cut -s -d ":" -f2)` | ||||||
|  |   if [ -z "$controller_port" ]; then | ||||||
|  |     redirector_addr="ssl:${controller_url}:6643" | ||||||
|  |   else | ||||||
|  |     redirector_addr="ssl:${controller_url}" | ||||||
|  |   fi | ||||||
|  | else | ||||||
|  |   redirector_addr=$1 | ||||||
|  | fi | ||||||
|  |  | ||||||
|  | echo "${redirector_addr}" > /usr/opensync/certs/redirector.txt | ||||||
|  | /etc/init.d/uhttpd enable | ||||||
|  | /etc/init.d/uhttpd start | ||||||
| uci set system.tip.redirector="${redirector_addr}" | uci set system.tip.redirector="${redirector_addr}" | ||||||
|  | uci set system.tip.deployed=0 | ||||||
| uci commit system | uci commit system | ||||||
| /etc/init.d/opensync restart | /etc/init.d/opensync restart | ||||||
|   | |||||||
| @@ -37,6 +37,20 @@ start_service() { | |||||||
|     echo "Setting certificates" |     echo "Setting certificates" | ||||||
|     mkdir -p ${CERTS_DEST_PATH} |     mkdir -p ${CERTS_DEST_PATH} | ||||||
|     cp ${CERTS_SRC_PATH}/* ${CERTS_DEST_PATH}/ |     cp ${CERTS_SRC_PATH}/* ${CERTS_DEST_PATH}/ | ||||||
|  |     echo "Checking Redirector" | ||||||
|  |     redirector=$(uci get system.tip.redirector) | ||||||
|  |     if [ -z "$redirector" ]; then | ||||||
|  |         [[ -f /usr/opensync/certs/redirector.txt ]] && redirector=$(cat /usr/opensync/certs/redirector.txt | tr -d '\r\n') | ||||||
|  |         if [ -z "$redirector" ]; then | ||||||
|  |             logger -t opensync "Contacting DigiCert for redirector address" | ||||||
|  |             wlan_ap_redirector.sh | ||||||
|  |         else | ||||||
|  |             logger -t opensync "Restoring redirector ${redirector} after factory reset" | ||||||
|  |             wlan_ap_redirector.sh ${redirector} | ||||||
|  |         fi | ||||||
|  |     fi | ||||||
|  |     [[ -f /usr/opensync/certs/redirector.txt ]] || echo "${redirector}" > /usr/opensync/certs/redirector.txt | ||||||
|  |   | ||||||
|     echo "Starting OpenSync" |     echo "Starting OpenSync" | ||||||
|     procd_set_param command ${PROG} |     procd_set_param command ${PROG} | ||||||
|     procd_close_instance |     procd_close_instance | ||||||
|   | |||||||
| @@ -291,7 +291,7 @@ static void cb_osp_start_factory_reboot(EV_P_ ev_timer *w, int events) | |||||||
| 	if (!strcmp(upg_url, "reboot")) | 	if (!strcmp(upg_url, "reboot")) | ||||||
| 		system("reboot"); | 		system("reboot"); | ||||||
| 	else | 	else | ||||||
| 		system("jffs2reset -y -r"); | 		system("wlan_ap_factory_reset.sh"); | ||||||
|  |  | ||||||
| 	upg_running = false; | 	upg_running = false; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -130,6 +130,7 @@ static int rx_msg(struct nl_msg *msg, void* arg) | |||||||
| 	struct nlattr *attr[GENL_UCC_ATTR_MAX+1]; | 	struct nlattr *attr[GENL_UCC_ATTR_MAX+1]; | ||||||
|  |  | ||||||
| 	struct voip_session *data; | 	struct voip_session *data; | ||||||
|  | 	char dst_ip[16]; | ||||||
| 	genlmsg_parse(nlmsg_hdr(msg), 0, attr,  | 	genlmsg_parse(nlmsg_hdr(msg), 0, attr,  | ||||||
| 			GENL_UCC_ATTR_MAX, genl_ucc_policy); | 			GENL_UCC_ATTR_MAX, genl_ucc_policy); | ||||||
|  |  | ||||||
| @@ -140,7 +141,6 @@ static int rx_msg(struct nl_msg *msg, void* arg) | |||||||
| 		return NL_OK; | 		return NL_OK; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	char *dst_ip = malloc(16); |  | ||||||
| 	memset(dst_ip, 0, 16); | 	memset(dst_ip, 0, 16); | ||||||
| 	if((get_current_ip(dst_ip, IAC_IFACE)) < 0) { | 	if((get_current_ip(dst_ip, IAC_IFACE)) < 0) { | ||||||
| 		LOGI("Error: Cannot get IP for %s", IAC_IFACE); | 		LOGI("Error: Cannot get IP for %s", IAC_IFACE); | ||||||
|   | |||||||
| @@ -0,0 +1,81 @@ | |||||||
|  | From 1f9978564420818d4ce4bdbb08fce2eca7c13d8e Mon Sep 17 00:00:00 2001 | ||||||
|  | From: Rick Sommerville <rick.sommerville@netexperience.com> | ||||||
|  | Date: Sun, 23 May 2021 14:36:03 -0400 | ||||||
|  | Subject: [PATCH] Preserve certificates and redirector over factory-reset | ||||||
|  |  | ||||||
|  | --- | ||||||
|  |  package/base-files/files/etc/rc.button/reset  |  2 +- | ||||||
|  |  .../patches/001-jffs2reset-keep-option        | 48 +++++++++++++++++++ | ||||||
|  |  2 files changed, 49 insertions(+), 1 deletion(-) | ||||||
|  |  create mode 100644 package/system/fstools/patches/001-jffs2reset-keep-option | ||||||
|  |  | ||||||
|  | diff --git a/package/base-files/files/etc/rc.button/reset b/package/base-files/files/etc/rc.button/reset | ||||||
|  | index 2403122ad2..56c0548ec9 100755 | ||||||
|  | --- a/package/base-files/files/etc/rc.button/reset | ||||||
|  | +++ b/package/base-files/files/etc/rc.button/reset | ||||||
|  | @@ -23,7 +23,7 @@ released) | ||||||
|  |  	elif [ "$SEEN" -ge 5 -a -n "$OVERLAY" ] | ||||||
|  |  	then | ||||||
|  |  		echo "FACTORY RESET" > /dev/console | ||||||
|  | -		jffs2reset -y && reboot & | ||||||
|  | +		wlan_ap_factory_reset.sh | ||||||
|  |  	fi | ||||||
|  |  ;; | ||||||
|  |  esac | ||||||
|  | diff --git a/package/system/fstools/patches/001-jffs2reset-keep-option b/package/system/fstools/patches/001-jffs2reset-keep-option | ||||||
|  | new file mode 100644 | ||||||
|  | index 0000000000..50209ea276 | ||||||
|  | --- /dev/null | ||||||
|  | +++ b/package/system/fstools/patches/001-jffs2reset-keep-option | ||||||
|  | @@ -0,0 +1,48 @@ | ||||||
|  | +--- a/jffs2reset.c | ||||||
|  | ++++ b/jffs2reset.c | ||||||
|  | +@@ -40,7 +40,7 @@ ask_user(void) | ||||||
|  | + 	return 0; | ||||||
|  | + } | ||||||
|  | +  | ||||||
|  | +-static int jffs2_reset(struct volume *v, int reset) | ||||||
|  | ++static int jffs2_reset(struct volume *v, int reset, int keep) | ||||||
|  | + { | ||||||
|  | + 	char *mp; | ||||||
|  | +  | ||||||
|  | +@@ -48,7 +48,7 @@ static int jffs2_reset(struct volume *v, | ||||||
|  | + 	if (mp) { | ||||||
|  | + 		ULOG_INFO("%s is mounted as %s, only erasing files\n", v->blk, mp); | ||||||
|  | + 		fs_state_set("/overlay", FS_STATE_PENDING); | ||||||
|  | +-		overlay_delete(mp, false); | ||||||
|  | ++		overlay_delete(mp, keep); | ||||||
|  | + 		mount(mp, "/", NULL, MS_REMOUNT, 0); | ||||||
|  | + 	} else { | ||||||
|  | + 		ULOG_INFO("%s is not mounted\n", v->blk); | ||||||
|  | +@@ -93,8 +93,8 @@ static int jffs2_mark(struct volume *v) | ||||||
|  | + int main(int argc, char **argv) | ||||||
|  | + { | ||||||
|  | + 	struct volume *v; | ||||||
|  | +-	int ch, yes = 0, reset = 0; | ||||||
|  | +-	while ((ch = getopt(argc, argv, "yr")) != -1) { | ||||||
|  | ++	int ch, yes = 0, reset = 0, keep = 0; | ||||||
|  | ++	while ((ch = getopt(argc, argv, "yrk")) != -1) { | ||||||
|  | + 		switch(ch) { | ||||||
|  | + 		case 'y': | ||||||
|  | + 			yes = 1; | ||||||
|  | +@@ -102,6 +102,9 @@ int main(int argc, char **argv) | ||||||
|  | + 		case 'r': | ||||||
|  | + 			reset = 1; | ||||||
|  | + 			break; | ||||||
|  | ++                case 'k': | ||||||
|  | ++                        keep = 1; | ||||||
|  | ++                        break; | ||||||
|  | + 		} | ||||||
|  | +  | ||||||
|  | + 	} | ||||||
|  | +@@ -128,5 +131,5 @@ int main(int argc, char **argv) | ||||||
|  | + 	volume_init(v); | ||||||
|  | + 	if (!strcmp(*argv, "jffs2mark")) | ||||||
|  | + 		return jffs2_mark(v); | ||||||
|  | +-	return jffs2_reset(v, reset); | ||||||
|  | ++	return jffs2_reset(v, reset, keep); | ||||||
|  | + } | ||||||
|  | --  | ||||||
|  | 2.17.1 | ||||||
|  |  | ||||||
		Reference in New Issue
	
	Block a user