|
Post by zenerguy on Sept 18, 2006 16:39:06 GMT -5
Is it somehow possible to have multiple instances of VBPCAP running as to capture/send packets from more than a single adapter at a time? I'm looking to build a network bridge between two adapters and it would greatly help if there was a way to do that with VBPCAP. Does anyone know if this is possible? Thanks!
|
|
|
Post by jdomnitz on Sept 18, 2006 21:04:49 GMT -5
Are you asking how to do it from a single application?
|
|
|
Post by zenerguy on Sept 19, 2006 14:55:17 GMT -5
Yes, I would like it to work from a single application written in VB6. I've tried a couple other WinPCap wrappers for VB out there but either they cost money or don't send raw packets. I'd like to write my application using VBPCAP if I can manage to use two network adapters simultaneously.
|
|
|
Post by jdomnitz on Sept 19, 2006 20:01:41 GMT -5
Im almost positive it will work if you built the vbpcap calls into a class and just create 2 instances of it.
There may be an easier way but its not coming to mind.
|
|
|
Post by zenerguy on Sept 19, 2006 22:39:08 GMT -5
Thanks for your reply,
How would I go about building the calls into a class as you mentioned? Thanks again.
|
|
|
Post by jdomnitz on Sept 20, 2006 21:36:41 GMT -5
google....
|
|
|
Post by zenerguy on Sept 21, 2006 13:16:03 GMT -5
I'm not getting it to work. I have made the class (I named it PCAP), and I modified the example project (provided in the newest ZIP download). Using my class I can sucessfully see the list of adapters and select one from the combobox just like the example. However I also made a second dropdown with the same list as the first combobox. This is so I can select which two adapters I want to bridge together. After a bit of debugging I discovered that VBPCAP will only capture from the adapter that is set LAST. For example,
'Dim vbpcap1 As PCAP 'Dim vbpcap2 As PCAP
vbpcap1.mvpSetCurrentAdapter cbadapter.ListIndex vbpcap2.mvpSetCurrentAdapter cbadapter2.ListIndex
will capture from the adapter listed in combobox 2. However,
vbpcap2.mvpSetCurrentAdapter cbadapter2.ListIndex vbpcap1.mvpSetCurrentAdapter cbadapter.ListIndex
captures from only the adapter in combobox 1. The code I am using to see which adapters are capturing packets is:
rval = vbpcap1.mvpBegin(20) ' 20 msec timeout rval2 = vbpcap2.mvpBegin(20)
go = True
Do While go rval = vbpcap1.mvpCapture If rval > 0 Then lblPackets = lblPackets + 1
rval2 = vbpcap2.mvpCapture '<-- this never happens (always returns 0) If rval2 > 0 Then lblPackets2 = lblPackets2 + 1
DoEvents Loop
The vbpcap1.mvpCapture works for the adapter set LAST. So for example, if I use this code to set adapters:
vbpcap1.mvpSetCurrentAdapter cbadapter.ListIndex vbpcap2.mvpSetCurrentAdapter cbadapter2.ListIndex '<--set last
then vbpcap1.mvpCapture will capture packets from the second adapter, and nothing from the first. vpcap2.mvpCapture returns nothing. If I use:
vbpcap2.mvpSetCurrentAdapter cbadapter2.ListIndex vbpcap1.mvpSetCurrentAdapter cbadapter.ListIndex '<--set last
then vbpcap1.mvpCapture captures from the first adapter and nothing from the second. vpcap2.mvpCapture still returns nothing.
The vbpcap2.mpvCapture never returns anything but 0. The "m" preceeding the functions are defined in my class, PCAP. Because I can't pass user-defined types back to my main form from within the class I have to assign public variables to each element in the type (in the class) and then reference the public class variables in my main form. This is why I was having trouble "building the calls into a class". I had used Google with not much luck finding how to pass user-defined variables from class to form. I'm not sure if this is the most efficient way of doing it but it seems to be working for my testing purposes. For example, this is a function in my class:
Private AdapInfo As AdINFO Private PackHeader As PacketHeader Public adap_desc As String Public adap_name As String
Public Function mvpGetAdapterInfo(ByVal ID As Integer) vpGetAdapterInfo ID, AdapInfo adap_desc = AdapInfo.Description adap_name = AdapInfo.Name End Function
Am I doing something wrong (probable), or can VBPCAP only support capture from one adapter at a time?
|
|
|
Post by jdomnitz on Sept 21, 2006 20:12:20 GMT -5
I have an easy fix even though its not the best...make a copy of the dll and change the name (then call the original for one adapter and the copy for the other). Im not sure why vb isnt creating a seperate instance of the dll though...
|
|
|
Post by jdomnitz on Sept 21, 2006 20:14:15 GMT -5
Actually...why are the declare statements commented out? And you may need to have private dll calls with accessor methods.
|
|
|
Post by zenerguy on Sept 23, 2006 22:21:05 GMT -5
Sorry - those declares aren't actually commented out - I must have missed those when posting. I copied VBPCAP.DLL and made a new copy named "VBPCAP2.DLL", made a second class named "PCAP2", and then referenced the new DLL file in the new class. Doing that seems to be working - I can capture from both adapters at the same time. Thanks for the help! Now I've run into a new problem. My program is meant to bridge two network adapters together, and to do that it sends captured packets from one adapter to the other (and vise versa). However, once a single packet is captured on adapter A, it is resent through adapter B which is captured and sent back through adapter A and this creates an infinite loop and lots of network traffic. I searched Google for a way to disable loopback packets or to only capture incoming (not outgoing) packets, and I found this link: www.mail-archive.com/winpcap-users@winpcap.polito.it/msg00360.html. I did what was reccommended and it seems to have stopped capturing outgoing packets but it also prevents me from using Ethereal to view my sent packets for debugging purposes. Is there a different way (perhaps by changing VBPCAP source?) to prevent outgoing packets from reaching my program but also allow other WinPCap programs to capture everything as usual? Thanks! P.S. I am using version 0.4 of VBPCAP because if I use the newest version 1, I get the "Errore applicazione" error described in this post: vbpcap.proboards22.com/index.cgi?board=vbpcap&action=display&thread=1155736824I also noticed the old 0.4 version DLL is 60kB but the new version 1 is only 28kB. I would think the new version with added functionality would be larger in size than its predecessor. Is this correct?
|
|