Article Title: methods and ideas for capturing network data frames based on Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
At present, many Linux Release versions have been released in China, which are focused on Chinese platforms to facilitate the use of Linux by domestic users, however, there is a sign that Chinese is not very good. In fact, although Chinese Character Processing is very important, it is not very valuable to promote Linux as a desktop system, in addition, in the release version, the source code package of the application is mostly deleted, and some non-very valuable X-Windows packages are selected, while many applications (such as PHP3) the source code must be supported before function expansion can be made. The excellent GNU/Linux mainly gives us a wealth of software resources and full freedom to enjoy resources, application Analysis is far less difficult than the kernel, and can bring obvious results. In fact, many applications provide multi-platform support. Currently, Linux may be used as a tool against Windows NT.
Source program attached: /*
* This program demonstrate SOCK_PACK call.
* Thanks Linux. Thanks Alan Cox
* Derived from/usr/src/redhat/SOURCES/dosemu-0.66.7/src/dosext/net/libpacket. c
* Compile method: cc capturer. c-o capturer
*/
/*
* Alan Cox raw code
*/
/*
* SOCK_PACKET support.
* Placed under the gnu lgpl.
*
* First cut at a library of handy support routines. Comments, additions
* And bug fixes greatfully received.
*
* (C) 1994 Alan Cox iiitac@pyr.swan.ac.uk GW4PTS @ GB7SWN
*/
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
/* # If _ GLIBC _> 1 */
# Include
# Include
/* # Else
# Include
# Include
# Endif */
# Include
# Include
/*
* Obtain a file handle on a raw ethernet type. In actual fact
* You can also request the dummy types for AX.25 or 802.3 also
*
*-1 indicates an error
* 0 or higher is a file descriptor which we have set non blocking
*
* WARNING: It is OK to listen to a service the system is using (eg arp)
* But don't try and run a user mode stack on the same service or all
* Hell will break loose.
*/
Int
OpenNetworkType (unsigned short netid)
{
Int s = socket (AF_INET, SOCK_PACKET, htons (netid ));
If (s =-1)
Return-1;
Fcntl (s, F_SETFL, O_NDELAY );
Return s;
}
/*
* Close a file handle to a raw packet type.
*/
Void
CloseNetworkLink (int sock)
{
Close (sock );
}
/*
* Write a packet to the network. You have to give a device
* This function. This is a device name (eg 'eth0' for the first
* Ethernet card). Please don't assume eth0, make it portable able
*-Plip is ethernet like but not eth0, ditto for the de600's.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.