Possible solution to determine if default network has changed (MacOS only for now)
Bob Sneidar
bobsneidar at iotecdigital.com
Tue Oct 22 14:31:05 EDT 2019
> On Oct 22, 2019, at 11:05 , Bob Sneidar via use-livecode <use-livecode at lists.runrev.com> wrote:
>
> Hi all.
>
> MacOS only for now.
>
> I think I put together a way to tell if the default network has changed since the last time an internet connection took place. It's no good of course, just getting the IP address, as given an identical subnet, you have a 1 in 254 change of getting the same IP address on a different network. We want to be absolutely certain.
<snip>
Well of course, as soon as I posted I realized 2 adapters on the same network like ethernet and wireless would produce the same results, so here's an iteration that gets the MAC address of the default adapter AND the Router's MAC address.
Bob S
on mouseUp
put "route get default" into tShellCommand
put shell(tShellCommand) into tDefaultAdapter
put lineOffset("Interface: ", tDefaultAdapter) into tInterfaceLine
if tInterfaceLine = 0 then
answer info "No default interface found!" as sheet
exit mouseUp
end if
put word 2 of line tInterfaceLine of tDefaultAdapter into tDefaultInterface
put "ipconfig getpacket " & tDefaultInterface into tShellCommand
put shell(tShellCommand) into tInterfaceDetail
put lineOffset("chaddr", tInterfaceDetail) into tInterfaceMACLine
put word 3 of line tInterfaceMACLine of tInterfaceDetail into tDefaultMACAddress
put lineOffset("router (ip_mult): ", tInterfaceDetail) into tRouterLine
put word 3 of line tRouterLine of tInterfaceDetail into tRouterAddress
put char 2 to -2 of tRouterAddress into tRouterAddress
put "arp " & tRouterAddress into tShellCommand
put shell(tShellCommand) into tArpReply
put word 4 of tArpReply into tDefaultRouterAddress
put tDefaultMACAddress & cr & tDefaultRouterAddress into tLastMACs
put tLastMACs
end mouseUp
More information about the use-livecode
mailing list