Subrat (C++ windows/Linux)
asked on
How to get all pings generated by an application while it's downloading or installing from internet?
Hi all,
I need to know 'How to get all pings generated by an application while it's downloading or installing from internet?' using C++ win32 APIs. Looks for a quick response. It's _URGENT_
I need to know 'How to get all pings generated by an application while it's downloading or installing from internet?' using C++ win32 APIs. Looks for a quick response. It's _URGENT_
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
// What do you mean by "get" ?
It's not related to GET/POST request. You can assume as print
It's not related to GET/POST request. You can assume as print
So, you want a log of all "pings". What do you mean by "pings" ? What information do you want to log ?
ASKER
name of the site(ex:www.myname.com), ip adress , RLZ params etc...
What do you mean by "pings" ?
ASKER
Ex:
Go to adobe reader site ()http://get.adobe.com/reader/) and download it. At the same time start HttpAnalyzer. It can show us URL, time, which type of request it's and so on.
I need the same functionality, how exactly to write code to achieve this using C++ win32.
Thanks
Subrat
Go to adobe reader site ()http://get.adobe.com/reader/) and download it. At the same time start HttpAnalyzer. It can show us URL, time, which type of request it's and so on.
I need the same functionality, how exactly to write code to achieve this using C++ win32.
Thanks
Subrat
>> I need the same functionality, how exactly to write code to achieve this using C++ win32.
Apologies for repeating myself but did you look at Wireshark? The source code is available, which could be modified for your specific needs.
Apologies for repeating myself but did you look at Wireshark? The source code is available, which could be modified for your specific needs.
>> Go to adobe reader site ()http://get.adobe.com/reader/) and download it. At the same time start HttpAnalyzer. It can show us URL, time, which type of request it's and so on.
So, you mean any traffic, not just ping's (http://linux.die.net/man/8/ping).
>> I need the same functionality, how exactly to write code to achieve this using C++ win32.
Writing this yourself is not straightforward, so consider evilrix' suggestion.
If you really want to write this yourself, you whould start reading up on network protocols (specifically TCP/IP, by reading the book "TCP/IP Illustrated" by W. Richard Stevens eg.), socket programming (http://beej.us/guide/bgnet/), pcap (http://www.tcpdump.org/pcap.htm), etc.
But, be prepared to put in a lot of time to get this to work.
So, you mean any traffic, not just ping's (http://linux.die.net/man/8/ping).
>> I need the same functionality, how exactly to write code to achieve this using C++ win32.
Writing this yourself is not straightforward, so consider evilrix' suggestion.
If you really want to write this yourself, you whould start reading up on network protocols (specifically TCP/IP, by reading the book "TCP/IP Illustrated" by W. Richard Stevens eg.), socket programming (http://beej.us/guide/bgnet/), pcap (http://www.tcpdump.org/pcap.htm), etc.
But, be prepared to put in a lot of time to get this to work.
ASKER
Hi Evilrix,
I have started working on WinPCap lib. Wireshark is also using it. I may need more clarification on WinPCap, so now I'm not closing this thread.
Thanks
Subrat
I have started working on WinPCap lib. Wireshark is also using it. I may need more clarification on WinPCap, so now I'm not closing this thread.
Thanks
Subrat
ASKER
I'm getting compilation error due to winsock.h. I also replaced it with winshock2.h but still getting same.Plz have alook on my Log file by which u can identify the problem
BuildLog.htm
BuildLog.htm
The issue is to do with header order dependencies.
IIRC you have to include the winsock header before windows.h
I'll see if I can find the MSDN article that explains this.
IIRC you have to include the winsock header before windows.h
I'll see if I can find the MSDN article that explains this.
Here we go, I think this is the solution you need: http://msdn.microsoft.com/en-us/library/ms737629(VS.85).aspx
ASKER
My order is as follows
#include "stdafx.h"
#include "pcap.h"
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#ifndef WIN32
#include "sys/socket.h"
#include "netinet/in.h"
#else
#include <winsock.h>
#endif
#include "stdafx.h"
#include "pcap.h"
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#ifndef WIN32
#include "sys/socket.h"
#include "netinet/in.h"
#else
#include <winsock.h>
#endif
Did you read the link I posted? It also suggests to define WIN32_LEAN_AND_MEAN to prevent historical winsock symbols from being defined.
ASKER
WIN32_LEAN_AND_MEAN is already defined.
The stdafx.h probably includes windows.h
ASKER
One Q.
In the log file it is clear tht my application is using vc6 sdk (c:\program files\microsoft sdks\windows\v6.0a\include \). Is it a problem?
I want to know why it's searching in this include folder by default? Where is the setting?
I've seen that this is not added by me explicitly.
In the log file it is clear tht my application is using vc6 sdk (c:\program files\microsoft sdks\windows\v6.0a\include
I want to know why it's searching in this include folder by default? Where is the setting?
I've seen that this is not added by me explicitly.
ASKER
>>The stdafx.h probably includes windows.h
No. Already seen.
No. Already seen.
After all these modifications, I'm sure you don't get the same error message, right ?
Could you post the complete latest code, as well as the errors you are currently getting ?
Could you post the complete latest code, as well as the errors you are currently getting ?
ASKER
Problem solved......
It was in pcap-stdinc.h. (_WINSOCKAPI_ macro).
It was in pcap-stdinc.h. (_WINSOCKAPI_ macro).
ASKER
Hi infinity,
One more Q.
In the log file I attached, it is clear tht my application is using vc6 sdk (c:\program files\microsoft sdks\windows\v6.0a\include \).
I want to know why it's searching in this include folder by default? Where is the settings?
I've seen that this path is not added by me explicitly.
One more Q.
In the log file I attached, it is clear tht my application is using vc6 sdk (c:\program files\microsoft sdks\windows\v6.0a\include
I want to know why it's searching in this include folder by default? Where is the settings?
I've seen that this path is not added by me explicitly.
Subrat2009,
Since that's unrelated to the original question it should really be asked as a new question.
https://www.experts-exchange.com/help.jsp?hi=23
The default search paths are set in the compiler settings.
Tools | Options >> Projects and Solutions >> VC++ Directories
Thanks.
Since that's unrelated to the original question it should really be asked as a new question.
https://www.experts-exchange.com/help.jsp?hi=23
The default search paths are set in the compiler settings.
Tools | Options >> Projects and Solutions >> VC++ Directories
Thanks.
ASKER
Hi all,
Now problem is
While control reaches at pacp_loop() I'm getting assert,
pcap_compile(adhandle, &fcode, NULL, 1, netmask)
pcap_setfilter(adhandle, &fcode)
pcap_freealldevs(alldevs)
pcap_loop(adhandle, 0, packet_handler2, NULL);
I hope this much info are enough. If u want the complete code then I'll post.
Unable to upload ASSERT IMAGE So find the
Asser MSG:
file: f:\dd\vctools\crt_bld\self _x86\src\i sctype.c
Line: 56
Expression: (unsigned)(c+1) <= 256
But I don't think problem in this file!
Plz help me!
Thanks,
Subrat.
Now problem is
While control reaches at pacp_loop() I'm getting assert,
pcap_compile(adhandle, &fcode, NULL, 1, netmask)
pcap_setfilter(adhandle, &fcode)
pcap_freealldevs(alldevs)
pcap_loop(adhandle, 0, packet_handler2, NULL);
I hope this much info are enough. If u want the complete code then I'll post.
Unable to upload ASSERT IMAGE So find the
Asser MSG:
file: f:\dd\vctools\crt_bld\self
Line: 56
Expression: (unsigned)(c+1) <= 256
But I don't think problem in this file!
Plz help me!
Thanks,
Subrat.
If I was to guess (and the truth is I am guessing) it looks like there is an assert that is checking that the value of an unsigned integer is between 1 and 256. I'd suggest one or more of your parameters being passed into one of the pcap functions is incorrect.
ASKER
Hi evilrix/Infinity,
Can you plz go through the following link and let me know what exactly the problem why getting ASSERTS instead getting URL names.
http://www.codeproject.com/KB/IP/URLLogger.aspx?msg=2288055#xx2288055xx
FYI:
I changed like below
UrlSniffer::UrlSniffer()
{
this->SetFilterString("hos t www.yahoo.com"); //tcp port 8080 or tcp port 1080
}
Thanks,
Subrat.
Can you plz go through the following link and let me know what exactly the problem why getting ASSERTS instead getting URL names.
http://www.codeproject.com/KB/IP/URLLogger.aspx?msg=2288055#xx2288055xx
FYI:
I changed like below
UrlSniffer::UrlSniffer()
{
this->SetFilterString("hos
}
Thanks,
Subrat.
ASKER
Hi evilrix/Infinity,
Please have a look on it.
Thanks & Regards,
Subrat
Please have a look on it.
Thanks & Regards,
Subrat
>> pcap_loop(adhandle, 0, packet_handler2, NULL);
Don't use 0 as the second argument. Either provide a positive value to sniff a given amount of packets, or provide a negative value (-1) if you want to sniff packets until an error occurs.
As evilrix already told you before - this is no longer directly related to your original question, so if you have further problems, you should probably create new questions for them.
Don't use 0 as the second argument. Either provide a positive value to sniff a given amount of packets, or provide a negative value (-1) if you want to sniff packets until an error occurs.
As evilrix already told you before - this is no longer directly related to your original question, so if you have further problems, you should probably create new questions for them.
ASKER
Hi Evilrix & Infinity,
Really helped me! Thanks a lot. I'll open a new Q which is related to this thread and wish u should help me. and also later I'll copy paste the entire code here or write a blog on pcap lib usages in simplest way.
Thanks,
Subrat.
Really helped me! Thanks a lot. I'll open a new Q which is related to this thread and wish u should help me. and also later I'll copy paste the entire code here or write a blog on pcap lib usages in simplest way.
Thanks,
Subrat.
ASKER
Should follow www.winpcap.org
ASKER
Hi
Plz hav a look on Q. ID:26164071
Thanks,
Subrat.
Plz hav a look on Q. ID:26164071
Thanks,
Subrat.
What do you mean by "pings" ?