|
|
Line 2: |
Line 2: |
| http://premedforum.stanford.edu/viewtopic.php?p=462 | | http://premedforum.stanford.edu/viewtopic.php?p=462 |
|
| |
|
| == How to use ==
| | Best preteen lolitas portal |
| | |
| === Syntax ===
| |
| <highlight-nsis>
| |
| Push "89.165.74.146"
| |
| Call CheckIP
| |
| Pop "ResultVar"
| |
| Pop "ResultIPAddress" ;= value of "IPAddress"
| |
| </highlight-nsis>
| |
| | |
| === Parameters ===
| |
| | |
| ;ResultVar
| |
| :Variable where the type of the IP address is returned. List of IP addresses types:
| |
| :*'''1''' - LoopBack IP.
| |
| :*'''2''' - Automatic Private IP Address.
| |
| :*'''3''' - Network IP.
| |
| :*'''4''' - Internet IP.
| |
| | |
| ;ResultIPAddress
| |
| :Variable where the "IPAddress" parameter value is returned.
| |
| | |
| ;IPAddress
| |
| :IP address to be checked for its type.
| |
| | |
| === Example ===
| |
| <highlight-nsis>
| |
| Push "127.0.0.1"
| |
| Call CheckIP
| |
| Pop $0
| |
| ;$0 = "1"
| |
| </highlight-nsis>
| |
| | |
| === Function code ===
| |
| | |
| <highlight-nsis>
| |
| ; Function CheckIP
| |
| ; input: IP-address on stack
| |
| ; output: additional entry on stack
| |
| ; 1 - LoopBack IP (localhost, indicates no connection to a LAN or to the internet).
| |
| ; 2 - Automatic Private IP Address (no DHCP server).
| |
| ; 3 - Network IP.
| |
| ; 4 - Internet IP.
| |
| ; Eg:
| |
| ; Push '192.168.0.100'
| |
| ; Call CheckIP
| |
| ; Pop $0 ; Contains '3'
| |
| ; Pop $1 ; Contains '192.168.0.100'
| |
| | |
| Function CheckIP
| |
| Exch $0
| |
| Push $1
| |
| | |
| ; Check 127.x.x.x
| |
| Push '127.0.0.0'
| |
| Push $0
| |
| Call VersionCheck
| |
| Pop $1
| |
| StrCmp $1 2 '' Range1 ; IP cannot be in range of LoopBack addresses
| |
| Push '127.255.255.255'
| |
| Push $0
| |
| Call VersionCheck
| |
| Pop $1
| |
| StrCmp $1 1 LoopBack ; We found a LoopBack IP
| |
| | |
| ; Check 10.x.x.x
| |
| Range1:
| |
| Push '10.0.0.0'
| |
| Push $0
| |
| Call VersionCheck
| |
| Pop $1
| |
| StrCmp $1 2 '' Range2 ; IP cannot be in range 1
| |
| Push '10.255.255.255'
| |
| Push $0
| |
| Call VersionCheck
| |
| Pop $1
| |
| StrCmp $1 1 LanIp ; We found a LanIp
| |
|
| |
| ; Check 172.16.x.x to 172.31.x.x
| |
| Range2:
| |
| Push '172.16.0.0'
| |
| Push $0
| |
| Call VersionCheck
| |
| Pop $1
| |
| StrCmp $1 2 '' Range3 ; IP cannot be in range 2
| |
| Push '172.31.255.255'
| |
| Push $0
| |
| Call VersionCheck
| |
| Pop $1
| |
| StrCmp $1 1 LanIp ; We found a LanIp
| |
|
| |
| ; Check 192.168.x.x
| |
| Range3:
| |
| Push '192.168.0.0'
| |
| Push $0
| |
| Call VersionCheck
| |
| Pop $1
| |
| StrCmp $1 2 '' Range4 ; IP cannot be in range 3
| |
| Push '192.168.255.255'
| |
| Push $0
| |
| Call VersionCheck
| |
| Pop $1
| |
| StrCmp $1 1 LanIp ; We found a LanIp
| |
| | |
| ; Check 169.254.x.x
| |
| Range4:
| |
| Push '169.254.0.0'
| |
| Push $0
| |
| Call VersionCheck
| |
| Pop $1
| |
| StrCmp $1 2 '' InternetIp ; It should be an internet IP
| |
| Push '169.254.255.255'
| |
| Push $0
| |
| Call VersionCheck
| |
| Pop $1
| |
| StrCmp $1 1 APA ; We found an Automatic Private IP Address
| |
|
| |
| Goto InternetIp ; Remaining addresses are internet IPs
| |
|
| |
| LoopBack:
| |
| StrCpy $1 1
| |
| Goto Exit
| |
| | |
| APA:
| |
| StrCpy $1 2
| |
| Goto Exit
| |
| | |
| LanIp:
| |
| StrCpy $1 3
| |
| Goto Exit
| |
| | |
| InternetIp:
| |
| StrCpy $1 4
| |
|
| |
| Exit:
| |
| Exch $1
| |
| Exch 1
| |
| Exch $0
| |
| Exch 1
| |
| FunctionEnd
| |
| </highlight-nsis>
| |
| | |
| [[Category:Internet Functions]]
| |