diff options
author | Abhishek Sansanwal <abhishek.s94@samsung.com> | 2017-10-23 17:08:35 +0530 |
---|---|---|
committer | Abhishek Sansanwal <abhishek.s94@samsung.com> | 2017-10-24 09:27:01 +0530 |
commit | 831bef1e45c6d64b14af1e0cef20e442d852f3bb (patch) | |
tree | 67831d88c6ed256abe9df43033ce9d627724aebd | |
parent | e7e1950eae7040c38f7187a2310147202e37cf69 (diff) | |
download | wifi-831bef1e45c6d64b14af1e0cef20e442d852f3bb.tar.gz wifi-831bef1e45c6d64b14af1e0cef20e442d852f3bb.tar.bz2 wifi-831bef1e45c6d64b14af1e0cef20e442d852f3bb.zip |
Improved entry input, ignore consecutive zeroes
Description: Ignore consecutive zeroes entered by the user
and switch to next IPv4/v6 octet/hextet. In case of network
prefix length just ignore multiple zeroes.
Signed-off-by: Abhishek Sansanwal <abhishek.s94@samsung.com>
Change-Id: Ib5e35c5102f79e7e1d2731363ea17674c82e1a88
-rwxr-xr-x | sources/wearable/inc/net/util/wifi_address.h | 2 | ||||
-rw-r--r-- | sources/wearable/src/wearable-circle/app_main.c | 37 |
2 files changed, 25 insertions, 14 deletions
diff --git a/sources/wearable/inc/net/util/wifi_address.h b/sources/wearable/inc/net/util/wifi_address.h index 71f62bb..8406974 100755 --- a/sources/wearable/inc/net/util/wifi_address.h +++ b/sources/wearable/inc/net/util/wifi_address.h @@ -28,7 +28,7 @@ extern "C" { #define DEFAULT_GUIDE_IP_ADDRESS "192.168.1.128" #define DEFAULT_GUIDE_IPV6_ADDRESS "0000:0000:0000:0000:0000:0000:0000:0000" #define DEFAULT_GUIDE_SUBNET_MASK "255.255.255.0" -#define DEFAULT_GUIDE_NETWORK_PREFIX_LENGTH "24" +#define DEFAULT_GUIDE_NETWORK_PREFIX_LENGTH "128" #define DEFAULT_GUIDE_GATEWAY_ADDRESS "192.168.1.1" #define DEFAULT_GUIDE_DNS1 "8.8.8.8" #define DEFAULT_GUIDE_DNS2 "8.8.4.4" diff --git a/sources/wearable/src/wearable-circle/app_main.c b/sources/wearable/src/wearable-circle/app_main.c index 69700b4..76e72db 100644 --- a/sources/wearable/src/wearable-circle/app_main.c +++ b/sources/wearable/src/wearable-circle/app_main.c @@ -55,6 +55,9 @@ #define MAX_PROXY_ADDRESS_LENGTH 2000 #define MAX_PROXY_PORT_LENGTH 5 #define MAX_PORT_NUMBER 65535 +#define MAX_IPV6_PREFIX_LENGTH 128 +#define MAX_HEXTET_SIZE 65535 +#define MAX_OCTET_SIZE 255 typedef struct { // network module @@ -2846,16 +2849,17 @@ static void __static_ipv6_wearable_subnet_input_changed_cb(void *data, Evas_Obje } + ip_addr = atoi(entry_text); + length = strlen(entry_text); + + if (ip_addr > MAX_IPV6_PREFIX_LENGTH || (ip_addr == 0 && length > 1)) { + entry_text[length - 1] = '\n'; ip_addr = atoi(entry_text); + fixed = TRUE; + } - if (ip_addr > 24) { - length = strlen(entry_text); - entry_text[length - 1] = '\n'; - ip_addr = atoi(entry_text); - fixed = TRUE; - } - g_snprintf(entry_text, 3, "%d", ip_addr); - g_strlcat(entry_ip_text, entry_text, sizeof(entry_ip_text)); + g_snprintf(entry_text, 4, "%d", ip_addr); + g_strlcat(entry_ip_text, entry_text, sizeof(entry_ip_text)); if (fixed) { i = elm_entry_cursor_pos_get(obj); @@ -2902,13 +2906,16 @@ static void __static_ipv6_wearable_input_changed_cb(void *data, Evas_Object *obj } ip_addr[i] = (int)strtol(ip_text[i], NULL, 16); - - if (ip_addr[i] > 65535) { - length = strlen(ip_text[i]); + length = strlen(ip_text[i]); + if (ip_addr[i] > MAX_HEXTET_SIZE) { saved = ip_text[i][length - 1]; ip_text[i][length - 1] = '\n'; ip_addr[i] = (int)strtol(ip_text[i], NULL, 16); fixed = TRUE; + } else if (ip_addr[i] == 0 && length > 1) { + ip_text[i][length - 1] = '\n'; + ip_addr[i] = (int)strtol(ip_text[i], NULL, 16); + fixed = TRUE; } if (i < 7) { @@ -3002,12 +3009,16 @@ static void __static_ip_wearable_input_changed_cb(void *data, Evas_Object *obj, } ip_addr[i] = atoi(ip_text[i]); - if (ip_addr[i] > 255) { - length = strlen(ip_text[i]); + length = strlen(ip_text[i]); + if (ip_addr[i] > MAX_OCTET_SIZE) { saved = ip_text[i][length - 1]; ip_text[i][length - 1] = '\n'; ip_addr[i] = atoi(ip_text[i]); fixed = TRUE; + } else if (ip_addr[i] == 0 && length > 1) { + ip_text[i][length - 1] = '\n'; + ip_addr[i] = atoi(ip_text[i]); + fixed = TRUE; } if (i < 3) { |