Sign in to follow this  
Followers 0
Splash

WinPcap AutoIt _FindDevice()

5 posts in this topic

#1 ·  Posted (edited)

;Author: Splash
;Web: http://meadiciona.com.br/cemim

;Required:
;#include <Process.au3>
;#include "Winpcap.au3"

;Description
;Try to find a device with internet connection avaliable.

;Parameters
;None.

;Return Value
;Sucess: Device number.
;Error: False.

Func _FindDevice()
    $device_number = 0
    $connection = False
    $pcap = _PcapSetup()
    $devices = _PcapGetDeviceList()

    While $connection == False and $device_number < Ubound($devices)
        $capture = _PcapStartCapture($devices[$device_number][0], "icmp and dst host google.com", 1, 65536, 524288, 0)
        _RunDos("ping google.com")
        $packet = _PcapGetPacket($capture)

        If IsArray($packet) Then
            If ($packet[2] > 0) Then
                $connection = True
                _PcapStopCapture($capture)
                _PcapFree()
                Return $device_number
            EndIf
        EndIF

        _PcapStopCapture($capture)
        $device_number = $device_number + 1
    WEnd

    Return False
EndFunc

You can get WinPcap Autoit UDF here:

http://opensource.grisambre.net/pcapau3/

:idea:

Edited by Splash

Automatic Update UDF - IP Address UDF - WinPcap AutoIt _FindDevice()[font="Verdana"][size="2"]AutoIt Spanish/Brasil/World community!!![/size][/font]Use you wanna a dot.tk domain please use my link:

Share this post


Link to post
Share on other sites



I don't think he made the UDF, he just came up with a neat way of finding an active network device using the WinPcap UDF. This could come in handy if you wanted your program to wait till an Internet connection was available, for example.

Share this post


Link to post
Share on other sites

Nossa! Estava realmente precisando disto Splash! :idea:

Depois testarei. Por enquanto, muito obrigado! :(

-----

Thanks! :)


Share this post


Link to post
Share on other sites

I think this is my first post but it's worth it:

Thanks! :oops:

Share this post


Link to post
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
Sign in to follow this  
Followers 0