views:

54

answers:

3

I want to get the source IP of UDP packet kindly guide me so that I can make it possible. I am working in c under windows platform.

+1  A: 

EDIT:

have a look at this tutorial: http://www.sockets.com/ch16.htm

There you should find some code that can guide you in the right direction!

This should help you:

sockaddr structure:

http://msdn.microsoft.com/en-us/library/ms740496(VS.85).aspx

in_addr structure:

http://msdn.microsoft.com/en-us/library/ms738571(VS.85).aspx

Tony
A: 

recvfrom is what you need

ULysses
+2  A: 

Use the recvfrom function. It has a from parameter that points to a sockaddr structure that will receive the source address.

Marcelo Cantos
Actually my application is in sniffer mode, so that I can't use the recvfrom function.
Arman
What does that mean - what API are you using for sniffing ?
nos
I am using winsock.
Arman
@Arman, wait, so what's the matter with the recvfrom in your case? I believe that the link in the post you marked as an answer also suggests using the function
ULysses
@ULysses, now Ok??
Arman
@Arman, :) yepp
ULysses