diff --git a/src/core/agent_map.c b/src/core/agent_map.c index d783a3a1eca2170c0a1814e749a315974d0465d8..4cf0f1a7935e5a725a3b5adebb6162d378731f7d 100644 --- a/src/core/agent_map.c +++ b/src/core/agent_map.c @@ -1147,6 +1147,7 @@ int handle_ap_autoconfig_wsc(void *agent, struct cmdu_buff *rx_cmdu) uint8_t bssid[6]; struct tlv *tlv = NULL; struct wifi_radio_element *radio; + struct tlv_traffic_sep_policy *traffic_sep; struct tlv *tv[4][16] = {0}; bool agent_found; int ret = 0, num = 0, i; @@ -1235,9 +1236,13 @@ int handle_ap_autoconfig_wsc(void *agent, struct cmdu_buff *rx_cmdu) wifi_teardown_map_ifaces_by_radio(a, radio->name); goto teardown; } + + free(ext); num++; } + uci_apply_traffic_sep((struct tlv_traffic_sep_policy *)tv[1][0]->data); + uci_set_wireless_interface_option("mapagent", "wifi-radio", "device", radio->name, "configured", "1"); dbg("|%s:%d| radio (%s) was configured! Apply heartbeat for this radio\n", diff --git a/src/core/config.c b/src/core/config.c index e9bbd1ab1011a56a95a301e6a1d39ccd99d939c8..776fc9109be069172633375a08256005d6ce02de 100644 --- a/src/core/config.c +++ b/src/core/config.c @@ -19,6 +19,19 @@ #define _GNU_SOURCE #endif +//Security and encryption +#define WPS_AUTH_OPEN (0x0001) +#define WPS_AUTH_WPAPSK (0x0002) +#define WPS_AUTH_SHARED (0x0004) /* deprecated */ +#define WPS_AUTH_WPA (0x0008) +#define WPS_AUTH_WPA2 (0x0010) +#define WPS_AUTH_WPA2PSK (0x0020) +#define ATTR_ENCR_TYPE_FLAGS (0x1010) +#define WPS_ENCR_NONE (0x0001) +#define WPS_ENCR_WEP (0x0002) /* deprecated */ +#define WPS_ENCR_TKIP (0x0004) +#define WPS_ENCR_AES (0x0008) + #include <json-c/json.h> #include <libubox/blobmsg.h> #include <libubox/blobmsg_json.h> @@ -29,16 +42,21 @@ #include <uci.h> #include <i1905_wsc.h> +#include <1905_tlvs.h> +#include <map22.h> +#include <easy/easy.h> +#include <map_module22.h> +#include <bufutil.h> #include <easy/easy.h> #include "debug.h" #include "utils.h" -#include "config.h" #include "steer_rules.h" #include "comm.h" #include "msgqueue.h" #include "worker.h" +#include "config.h" #include "agent.h" // UCI sections @@ -711,6 +729,35 @@ int uci_apply_wps_credentials(struct agent_config *cfg, enum wifi_band band) #endif +/* + * Will only be successful if uci_apply_m2 is done prior, or interfaces already + * exist and are configured through other means + */ +void uci_apply_traffic_sep(struct tlv_traffic_sep_policy *tlv) +{ + int i; + uint8_t *ptr; + + ptr = tlv; + ptr++; + for (i = 0; i < tlv->num_ssid; i++) { + char ssid[33] = {0}; + char vid[8] = {0}; + uint8_t len = 0; + + len = *ptr; + ptr++; + + memcpy(ssid, ptr, len); + ptr += len; + + snprintf(vid, sizeof(vid), "%u", buf_get_be16(ptr)); + ptr += 2; + uci_set_wireless_interface_option(UCI_AGENT, UCI_FH_AGENT, + "ssid", ssid, "vid", vid); + } +} + /* TODO: batch the changes arther than commit oneby one */ int uci_apply_m2(struct agent_config *cfg, char *interface_name, char *device, struct wps_credential *out, bool onboarded, struct iop_ext *exts) @@ -720,7 +767,6 @@ int uci_apply_m2(struct agent_config *cfg, char *interface_name, char *device, char multiap_str[2] = {0}; uint8_t multi_ap = 0; char band_str[2] = {0}; - char agent_section[16] = {0}; char ipaddr_str[INET_ADDRSTRLEN] = {0}; char ssid[33] = {0}, network_key[65] = {0}, bridge_buf[16] = {0}, *bridge; /* step past br- prefix if present*/ @@ -741,7 +787,7 @@ int uci_apply_m2(struct agent_config *cfg, char *interface_name, char *device, memcpy(network_key, out->key, out->keylen); memcpy(bridge, exts->bridge, 15); - inet_ntop(AF_INET, &out->br_ip, ipaddr_str, INET_ADDRSTRLEN); + inet_ntop(AF_INET, &exts->br_ip, ipaddr_str, INET_ADDRSTRLEN); dbg("Applying WSC configuration (%s):\n", interface_name); dbg(" - SSID : %s\n", ssid); @@ -781,27 +827,25 @@ int uci_apply_m2(struct agent_config *cfg, char *interface_name, char *device, return M2_PROCESS_ERROR; } - strncpy(agent_section, UCI_FH_AGENT, sizeof(agent_section)); - // Set uci in agent ret = uci_check_wifi_iface(UCI_AGENT, interface_name, - agent_section); + UCI_FH_AGENT); if (!ret) { ret = uci_add_wireless_iface_sec(UCI_AGENT, interface_name, - agent_section, NULL); + UCI_FH_AGENT, NULL); if (!ret) return M2_PROCESS_ERROR; } - uci_set_wireless_interface_option(UCI_AGENT, agent_section, "ifname", + uci_set_wireless_interface_option(UCI_AGENT, UCI_FH_AGENT, "ifname", interface_name, "band", band_str); - uci_set_wireless_interface_option(UCI_AGENT, agent_section, "ifname", + uci_set_wireless_interface_option(UCI_AGENT, UCI_FH_AGENT, "ifname", interface_name, "device", device); - uci_set_wireless_interface_option(UCI_AGENT, agent_section, "ifname", + uci_set_wireless_interface_option(UCI_AGENT, UCI_FH_AGENT, "ifname", interface_name, "ssid", ssid); - uci_set_wireless_interface_option(UCI_AGENT, agent_section, "ifname", + uci_set_wireless_interface_option(UCI_AGENT, UCI_FH_AGENT, "ifname", interface_name, "key", network_key); - uci_set_wireless_interface_option(UCI_AGENT, agent_section, "ifname", + uci_set_wireless_interface_option(UCI_AGENT, UCI_FH_AGENT, "ifname", interface_name, "encryption", auth_type_str); if (multi_ap & 0x01) { char disallow_str[2] = {0}; @@ -809,7 +853,7 @@ int uci_apply_m2(struct agent_config *cfg, char *interface_name, char *device, snprintf(disallow_str, sizeof(disallow_str), "%d", ((out->mapie >> 2) & 0x03)); uci_set_wireless_interface_option(UCI_AGENT, - agent_section, "ifname", + UCI_FH_AGENT, "ifname", interface_name, "disallow_bsta", disallow_str); } diff --git a/src/core/config.h b/src/core/config.h index 32956e3dfd36a24d95ba52fb5207a6039aaa53e4..fb67881b84e4b08ddeabe793375e0747c9a4c088 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -269,5 +269,6 @@ int uci_add_dhcp(char *interface); int uci_add_fw(struct agent_config *cfg, char *interface); void config_disable_bstas(struct agent_config *cfg); int config_disable_bsta(struct netif_bkcfg *bk); +void uci_apply_traffic_sep(struct tlv_traffic_sep_policy *tlv); #endif