Jump to content

_broadcastIP Udf


jaenster
 Share

Recommended Posts

A udf to calucate the broadcastIP.

Msgbox(0,"",_BroadcastIP()&@crlf&"Created by jaenster (Thanks to SmOke_N)")

Func _SubnetMask($strIP = @IPAddress1)
    Local $strEnumKey, $nEnum
    Local $strKey = "HKLM\SYSTEM\CurrentControlSet\" & _
            "Services\Tcpip\Parameters\Interfaces\"
    While 1
        $nEnum += 1
        $strEnumKey = RegEnumKey($strKey, $nEnum)
        If @error <> 0 Then ExitLoop
        If RegRead($strKey & $strEnumKey, "DhcpIPAddress") = $strIP Then
            Return RegRead($strKey & $strEnumKey, "DhcpSubnetMask")
        EndIf
    WEnd
    Return SetError(1, 0, 0)
EndFunc
func _BroadcastIP()
    $submask = _SubnetMask()
    $split_sub = stringsplit($submask,".")
    $split_ip = stringsplit(@IPAddress1,".")
    $Broadcast = ""
    for $i = 1 to 4
        $Broadcast &= "."&bitOR((255-$split_sub[$i]),$split_ip[$i])
    next
    $Broadcast = stringmid($Broadcast,2)
    return $Broadcast
endfunc

- Jaenster

Edited by jaenster

-jaenster

Link to comment
Share on other sites

  • 2 weeks later...

No reply because it sucks.

Can you show me when one would need to calculate that address? Waiting..

it sucks in no way,

its very usefull if you want to send a broadcastpacket to discover all dhcp servers in a net.

Multicast is used to send files to more then one pc at the same time, which needs the broadcast address to be known.

so in any way this function does not suck... ( and please be a bit smarter...)

$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
Link to comment
Share on other sites

Having error at line 23:

+>16:48:42 Starting AutoIt3Wrapper v.1.9.3
>Running AU3Check (1.54.9.0)  from:C:\Program Files\AutoIt3
+>16:48:42 AU3Check ended.rc:0
>Running:(3.2.8.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Documents and Settings\User\Рабочий стол\AutoIt v3 Script.au3"   
C:\Documents and Settings\User\??????? ????\AutoIt v3 Script.au3 (23) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: 
$Broadcast &= "."&bitOR((255-$split_sub[$i]),$split_ip[$i]) 
$Broadcast &= "."&bitOR((255-^ ERROR
Edited by qwer85
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...