473,500 Members | 1,686 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Setting a NIC to Promiscuous Mode

158 New Member
Hello all,

I am trying to write a C program on Unix (OpenBSD 4.3) that will be sniffing a certain packet which is being sent by a diff rent machine to another different machine.

The only way I believe this is possible is to set my NIC into promiscuous mode.

I would like to set the NIC to Promiscuous mode in my C program but I would also be content if anyone knows a way to just set it in that mode permanently, but thats more of a question for an BSD forum.

As for the code method, I have searched google for awhile now but have still not found a technique that works, everything I try usually doesn't work because the header file #include <netinet/tcp.h> has errors in it.


Here is the method that I found in a bunch of places online, I get syntax errors in the #include <netinet/ip.h> #include <netinet/tcp.h> header files.

/usr/include/netinet/ip.h:156: error: syntax error before "n_time"


Expand|Select|Wrap|Line Numbers
  1. #include <stdlib.h>
  2. #include <sys/socket.h>
  3. #include <netinet/ip.h>
  4. #include <netinet/tcp.h>
  5. #include <linux/if.h>
  6. #include <sys/ioctl.h>
  7.  
  8. int promisc(){
  9.  
  10.     int fd;
  11.     struct ifreq eth;
  12.  
  13.     fd = socket(AF_INET, SOCK_PACKET, htons(0x800));
  14.  
  15.     strcpy(eth.ifr_name, "eth0");
  16.  
  17.     ioctl(fd, SIOCGIFFLAGS, &eth);
  18.  
  19.     eth.ifr_flags |= IFF_PROMISC;
  20.  
  21.     ioctl(fd, SIOCSIFFLAGS, &eth);
  22.  
  23.  
  24. }
  25.  
  26.  
  27.  
Aug 1 '08 #1
1 10854
gpraghuram
1,275 Recognized Expert Top Contributor
I grepped for n_time in the folder /usr/include/netinet and got these
$ grep n_time /usr/include/netinet/*.h
/usr/include/netinet/in_systm.h:typedef u_int32_t n_time; /* ms since 00:00 GMT, byte rev */

Try including this header file or check whether you have to have some specific #define for this

Raghu
Aug 4 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1079
by: J.R. | last post by:
Hi, I want to use the wxStyledTextCtrl to open a huge ascii file, see almost 10MB. After I set the wrap mode, i.e. set to wxSTC_WRAP_WORD, the open and resize of the wxStyledTextCtrl will be...
0
1859
by: armsby | last post by:
do anybody have any experience with promiscuous mode i need to put my solaris in promiscuous mode so i can log and analyse it
6
6953
by: Peter Krikelis | last post by:
Hi All, I am having a problem setting up input mode for serial communications. (Sorry about the long code post). The following code is what I use to set up my comm port.
6
6950
by: Laxmikant Rashinkar | last post by:
Is there any way to use a C# socket in promiscuous mode? Any sample code that shows how this is done? any assistance is much appreciated! thanks LK
10
2680
by: Brian Conway | last post by:
I have no idea what is going on. I have a Login screen where someone types in their login information and this populates a datagrid based off of the login. Works great in debug and test through...
1
7722
by: Joe | last post by:
What I want to do is make only one page require a login. The application itself works fine. I'm getting the following error: Parser Error Message: It is an error to use a section registered as...
4
2229
by: Donna | last post by:
I am attempting to build a web service in .NET 2.0, using Visual Studio 2005. I am able to build it in debug mode, but for deployment, I want to change to release mode. The problem is that there...
1
6436
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
7
3623
by: news.microsoft.com | last post by:
I have an asp.net 2.0 project that when I change the build configuration to release I get the following error: Command line error BC2014: the value 'None' is invalid for option 'debug'. If I...
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7014
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7229
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7395
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5485
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3108
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
311
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.