Jump to content

WinPcap AutoIt _FindDevice()


Splash
 Share

Recommended Posts

;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:
Link to comment
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.

Link to comment
Share on other sites

  • 1 year later...

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...