Netstat: Save dns address correctly, added optionbox to disabled IPv4.

Zeroconfig: Dont give up too soon when network.ini is malformed.

git-svn-id: svn://kolibrios.org@5610 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2015-07-23 17:40:09 +00:00
parent e963673962
commit 685987e90d
2 changed files with 86 additions and 50 deletions

View File

@ -10,8 +10,6 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
enum_callback:
ipcfg: ipcfg:
mcall 40, EVM_MOUSE + EVM_MOUSE_FILTER + EVM_REDRAW + EVM_BUTTON + EVM_KEY + EVM_STACK mcall 40, EVM_MOUSE + EVM_MOUSE_FILTER + EVM_REDRAW + EVM_BUTTON + EVM_KEY + EVM_STACK
@ -28,25 +26,51 @@ ipcfg:
@@: @@:
; Read ip/subnet/gateway type ; Read ip/subnet/gateway type
mov [option_ip], op_ip_static mov [option_ip], op_ip_disabled
invoke ini.get_str, net_ini, str_ini_int, str_ini_ip_type, ini_buf, 16, sz_0 invoke ini.get_str, net_ini, str_ini_int, str_ini_ip_type, ini_buf, 16, sz_0
; test eax, eax test eax, eax
; jz .disabled jnz .ip_type_loaded
mov eax, dword[ini_buf] mov eax, dword[ini_buf]
or eax, 0x20202020 or eax, 0x20202020
cmp eax, 'stat' cmp eax, 'auto'
je @f jne @f
; cmp byte[ini_buf+4], 0
; jne @f
mov [option_ip], op_ip_auto mov [option_ip], op_ip_auto
jmp .ip_type_loaded
@@: @@:
cmp eax, 'dhcp'
jne @f
; cmp byte[ini_buf+4], 0
; jne @f
mov [option_ip], op_ip_auto
jmp .ip_type_loaded
@@:
cmp eax, 'stat'
jne @f
; mov eax, dword[ini_buf+3]
; or eax, 0x202020
; cmp eax, 'tic'
; jne @f
mov [option_ip], op_ip_static
; jmp .ip_type_loaded
@@:
.ip_type_loaded:
; Read DNS type ; Read DNS type
mov [option_dns], op_dns_static mov [option_dns], op_dns_auto
invoke ini.get_str, net_ini, str_ini_int, str_ini_dns_type, ini_buf, 16, sz_0 invoke ini.get_str, net_ini, str_ini_int, str_ini_dns_type, ini_buf, 16, sz_0
test eax, eax
jnz @f
mov eax, dword[ini_buf] mov eax, dword[ini_buf]
or eax, 0x20202020 or eax, 0x20202020
cmp eax, 'stat' cmp eax, 'stat'
je @f jne @f
mov [option_dns], op_dns_auto ; mov eax, dword[ini_buf+3]
; or eax, 0x202020
; cmp eax, 'tic'
; jne @f
mov [option_dns], op_dns_static
@@: @@:
; Read all IP addresses ; Read all IP addresses
@ -82,22 +106,22 @@ ipcfg:
mov ecx, 0x80000000 mov ecx, 0x80000000
or ecx, [sc.work_text] or ecx, [sc.work_text]
; mov ebx, 47 shl 16 + 10 ; mov ebx, 47 shl 16 + 25
; mov edx, str_mode ; mov edx, str_mode
; mcall ; mcall
mov ebx, 59 shl 16 + 35 mov ebx, 59 shl 16 + 50
mov edx, sz_ip mov edx, sz_ip
mcall 4 mcall 4
mov ebx, 5 shl 16 + 55 mov ebx, 5 shl 16 + 70
mov edx, sz_subnet mov edx, sz_subnet
mcall mcall
mov ebx, 29 shl 16 + 75 mov ebx, 29 shl 16 + 90
mov edx, sz_gateway mov edx, sz_gateway
mcall mcall
; mov ebx, 47 shl 16 + 80 ; mov ebx, 47 shl 16 + 95
; mov edx, str_mode ; mov edx, str_mode
; mcall ; mcall
mov ebx, 53 shl 16 + 120 mov ebx, 53 shl 16 + 135
mov edx, sz_dns mov edx, sz_dns
mcall mcall
@ -109,11 +133,11 @@ ipcfg:
invoke option_box_draw, Option_boxs1 invoke option_box_draw, Option_boxs1
invoke option_box_draw, Option_boxs2 invoke option_box_draw, Option_boxs2
mcall 8, 80 shl 16 + 100, 150 shl 16 + 16, 2, [sc.work_button] mcall 8, 80 shl 16 + 100, 155 shl 16 + 16, 2, [sc.work_button]
mov ecx, 0x80000000 mov ecx, 0x80000000
or ecx, [sc.work_button_text] or ecx, [sc.work_button_text]
mov ebx, 112 shl 16 + 155 mov ebx, 112 shl 16 + 160
mov edx, sz_apply mov edx, sz_apply
mcall 4 mcall 4
@ -215,18 +239,26 @@ ipcfg:
call create_str_ini_int call create_str_ini_int
cmp [option_ip], op_ip_auto cmp [option_ip], op_ip_auto
jne .ip_static jne @f
invoke ini.set_str, net_ini, str_ini_int, str_ini_ip_type, sz_dhcp, 4 invoke ini.set_str, net_ini, str_ini_int, str_ini_ip_type, sz_auto, 4
jmp @f jmp .ip_type_ok
.ip_static:
invoke ini.set_str, net_ini, str_ini_int, str_ini_ip_type, sz_static2, 6
@@: @@:
cmp [option_ip], op_ip_static
jne @f
invoke ini.set_str, net_ini, str_ini_int, str_ini_ip_type, sz_static, 6
jmp .ip_type_ok
@@:
; cmp [option_ip], op_ip_disabled
; jne @f
invoke ini.set_str, net_ini, str_ini_int, str_ini_ip_type, sz_disabled, 8
; @@:
.ip_type_ok:
cmp [option_dns], op_dns_auto cmp [option_dns], op_dns_auto
invoke ini.set_str, net_ini, str_ini_int, str_ini_dns_type, sz_dhcp, 4 invoke ini.set_str, net_ini, str_ini_int, str_ini_dns_type, sz_auto, 4
jmp @f jmp @f
.dns_static: .dns_static:
invoke ini.set_str, net_ini, str_ini_int, str_ini_dns_type, sz_static2, 6 invoke ini.set_str, net_ini, str_ini_int, str_ini_dns_type, sz_static, 6
@@: @@:
invoke ini.set_str, net_ini, str_ini_int, str_ini_ip, str_edit_ip, [edit_ip.size] invoke ini.set_str, net_ini, str_ini_int, str_ini_ip, str_edit_ip, [edit_ip.size]
@ -278,10 +310,12 @@ toggle_editboxes:
mov [edit_gateway.color], 0xcacaca mov [edit_gateway.color], 0xcacaca
@@: @@:
mov [edit_dns.color], 0xffffff
cmp [option_dns], op_dns_static
je @f
mov [edit_dns.color], 0xcacaca mov [edit_dns.color], 0xcacaca
cmp [option_ip], op_ip_disabled
je @f
cmp [option_dns], op_dns_static
jne @f
mov [edit_dns.color], 0xffffff
@@: @@:
ret ret
@ -350,21 +384,22 @@ create_str_ini_int:
;------------------------- ;-------------------------
; DATA ; DATA
edit_ip edit_box 100, 80, 30, 0xffffff, 0x6f9480, 0, 0, 0, 15, str_edit_ip, mouse_dd, 0, 0, 1 edit_ip edit_box 100, 80, 45, 0xffffff, 0x6f9480, 0, 0, 0, 15, str_edit_ip, mouse_dd, 0, 0, 1
edit_subnet edit_box 100, 80, 50, 0xffffff, 0x6f9480, 0, 0, 0, 15, str_edit_subnet, mouse_dd, 0, 0, 1 edit_subnet edit_box 100, 80, 65, 0xffffff, 0x6f9480, 0, 0, 0, 15, str_edit_subnet, mouse_dd, 0, 0, 1
edit_gateway edit_box 100, 80, 70, 0xffffff, 0x6f9480, 0, 0, 0, 15, str_edit_gateway, mouse_dd, 0, 0, 1 edit_gateway edit_box 100, 80, 85, 0xffffff, 0x6f9480, 0, 0, 0, 15, str_edit_gateway, mouse_dd, 0, 0, 1
edit_dns edit_box 100, 80, 115, 0xffffff, 0x6f9480, 0, 0, 0, 15, str_edit_dns, mouse_dd, 0, 0, 1 edit_dns edit_box 100, 80, 130, 0xffffff, 0x6f9480, 0, 0, 0, 15, str_edit_dns, mouse_dd, 0, 0, 1
op_ip_auto option_box option_ip, 15, 10, 6, 12, 0xffffff, 0, 0, sz_auto, 5 op_ip_disabled option_box option_ip, 15, 5, 6, 12, 0xffffff, 0, 0, sz_disabled, 9
op_ip_static option_box option_ip, 80, 10, 6, 12, 0xffffff, 0, 0, sz_static, 7 op_ip_auto option_box option_ip, 15, 25, 6, 12, 0xffffff, 0, 0, sz_auto, 5
op_ip_static option_box option_ip, 80, 25, 6, 12, 0xffffff, 0, 0, sz_static, 7
op_dns_auto option_box option_dns, 15, 95, 6, 12, 0xffffff, 0, 0, sz_auto, 5 op_dns_auto option_box option_dns, 15, 110, 6, 12, 0xffffff, 0, 0, sz_auto, 5
op_dns_static option_box option_dns, 80, 95, 6, 12, 0xffffff, 0, 0, sz_static, 7 op_dns_static option_box option_dns, 80, 110, 6, 12, 0xffffff, 0, 0, sz_static, 7
option_ip dd op_ip_auto option_ip dd op_ip_auto
option_dns dd op_dns_auto option_dns dd op_dns_auto
Option_boxs1 dd op_ip_auto, op_ip_static, 0 Option_boxs1 dd op_ip_disabled, op_ip_auto, op_ip_static, 0
Option_boxs2 dd op_dns_auto, op_dns_static, 0 Option_boxs2 dd op_dns_auto, op_dns_static, 0
net_ini db '/sys/settings/network.ini', 0 net_ini db '/sys/settings/network.ini', 0
@ -374,21 +409,19 @@ str_ini_int db 'ip1', 0
str_ini_ip db 'ip', 0 str_ini_ip db 'ip', 0
str_ini_subnet db 'subnet', 0 str_ini_subnet db 'subnet', 0
str_ini_gateway db 'gateway', 0 str_ini_gateway db 'gateway', 0
str_ini_dns db 'dns1', 0 str_ini_dns db 'dns', 0
str_ini_ip_type db 'ip_type', 0 str_ini_ip_type db 'ip_type', 0
str_ini_dns_type db 'dns_type', 0 str_ini_dns_type db 'dns_type', 0
sz_0 db 0
sz_dhcp db 'dhcp', 0
sz_static2 db 'static', 0
str_title db 'IP settings', 0 str_title db 'IP settings', 0
sz_0 db 0
sz_ip db 'IP:', 0 sz_ip db 'IP:', 0
sz_subnet db 'Subnet mask:', 0 sz_subnet db 'Subnet mask:', 0
sz_gateway db 'Gateway:', 0 sz_gateway db 'Gateway:', 0
sz_dns db 'DNS:', 0 sz_dns db 'DNS:', 0
sz_auto db 'Auto', 0 sz_auto db 'Auto', 0
sz_static db 'Static', 0 sz_static db 'Static', 0
sz_disabled db 'Disabled', 0
sz_apply db 'Apply', 0 sz_apply db 'Apply', 0
str_edit_ip rb 16 str_edit_ip rb 16

View File

@ -86,7 +86,7 @@ ends
struct interface struct interface
number dd ? number dd ?
state dd ? ; 0 - disconnected, 1 - connected state dd ? ; 0 - disconnected, 1 - connected
mode dd ? ; 0 - static, 1 - dhcp, 2 - auto (zero config) mode dd ? ; 0 - disabled, 1 - static, 2 - dhcp, 3 - auto (zero config)
tries dd ? tries dd ?
lease dd ? lease dd ?
ServerIP dd ? ServerIP dd ?
@ -175,22 +175,25 @@ mainloop:
invoke ini.get_str, ini_path, str_ini_int, str_ip_type, inibuf, 16, str_null invoke ini.get_str, ini_path, str_ini_int, str_ip_type, inibuf, 16, str_null
test eax, eax test eax, eax
jnz .fail jnz .invalid
mov eax, dword[inibuf] mov eax, dword[inibuf]
or eax, 0x20202020 or eax, 0x20202020
mov [ebp + interface.mode], 0 mov [ebp + interface.mode], 0
cmp eax, 'disa'
je .next
mov [ebp + interface.mode], 1
cmp eax, 'stat' cmp eax, 'stat'
je static je static
mov [ebp + interface.mode], 1 mov [ebp + interface.mode], 2
cmp eax, 'dhcp' cmp eax, 'dhcp'
je dhcp je dhcp
mov [ebp + interface.mode], 2 mov [ebp + interface.mode], 3
cmp eax, 'auto' cmp eax, 'auto'
je dhcp je dhcp
.fail: .invalid:
DEBUGF 2, "Invalid network.ini settings\n" DEBUGF 2, "Invalid settings for interface: %s.\n", str_ini_int
mcall -1 ; Give up jmp .next
.maintain_link: .maintain_link:
@ -593,7 +596,7 @@ dhcp_fail:
dhcp_error: dhcp_error:
DEBUGF 1, "DHCP failed\n" DEBUGF 1, "DHCP failed\n"
cmp [ebp + interface.mode], 2 ; zero config mode? cmp [ebp + interface.mode], 3 ; zero config mode?
jne link_up jne link_up
link_local: link_local: