Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Linux·¢ËÍarpÇëÇóÓë½ÓÊÕarpÏìÓ¦

Linux ÖлñµÃ±¾»úÍø¿¨MACµØÖ·ºÜ¼òµ¥£¬ioctl()¾ÍOK¡£¿ÉÈçºÎ»ñµÃ¾ÖÓòÍøÆäËûÖ÷»úµÄMACµØÖ·ÄØ…Á´Â·²ã¹ã²¥ARPÇëÇó£¬È»ºó½ÓÊÕARPÏìÓ¦¡£ÊµÏÖ½é¸ö¹¦ÄÜÆäʵÒÑÓÐÏÖ³ÉÈý·½¿â¿ÉÓã¬Èçlibnet¡£²»¹ýÏë¼ÓÉî¶ÔЭÒéµÄÀí½âºÍLinuxÍøÂç±à³ÌAPIµÄÀí½â£¬jiayi »¹ÊǾö¶¨ÓÃLinuxµÄPF_PACKET×Ô¼ºÊµÏÖ£¬¸Ä°¡¸Ä£¬ÖÕÓڳɹ¦¡«ÒÔÏÂÊÇ´óÌå˼·
1. ΪÊý¾Ý±¨·ÖÅä¿Õ¼ä£¬´´½¨ÏàÓ¦µÄ½á¹¹Ìå req£¬arp Êý¾Ý±¨µÄÖ¡¸ñʽÈçͼ
        
2. ´´½¨ PF_PACKET ԭʼÌ×½Ó×Ö£¬·¢ËÍÌ×½Ó×ÖΪ reqfd£¬½ÓÊÕÌ×½Ó×ÖΪ recvfd
3. ÌîдÁ´Â·²ãͨÓýṹÌå reqsa
3. get_ifi()»ñÈ¡±¾»úÍøÂç½Ó¿ÚÊý¾Ý£¬ÌîдҪ·¢Ë͵ÄARPÊý¾Ý±¨ req ½á¹¹Ì壬sendto()·¢ËÍ
4. Ñ­»·recvfrom()½ÓÊÕARPÏìÓ¦£¬Â˵ô¾­Óɱ¾µØ½Ó¿ÚµÄÆäËûARPÊý¾Ý±¨
·¢ËÍARPÇëÇóÄÜ×öµÄʲ»½ö½ö»ñÈ¡MACµØÖ·°É…ÆäËû“ÓÐÒâÒ唵ÄÊÂÒ²¿ÉÒÔ³¢ÊÔÒ»ÏÂÏÂ……ÏÂÃæÊÇ´úÂë
C code
/**
* @send_arp.c
* @This software is intended to be used as a example to show how to send and receive arp request with Linux * PF_PACKET interface
* @Author£ºjiayi,http://www.jiayii.com
**/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <netdb.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <net/if.h>
#include <sys/types.h>
#include <asm/types.h>
#include <features.h> /* ÐèÒªÀïÃæµÄ glibc °æ±¾ºÅ */
#if __GLIBC__ >= 2 && __GLIBC_MINOR >= 1
        #include <netpacket/packet.h>
        #include <net/ethernet.h> /* Á´Â·²ã£¨L2£©Ð­Òé */
#else
        #include <asm/types.h>
        #include <linux/if_packet.h>
        #include <linux/if_ether.h> /* Á´Â·²ãЭÒé */
#endif
#include <netinet/if_ether.h>
#define INLEN 4
#define MAC_BCAST_ADDR  (uint8_t *) "\xff\xff\xff\xff\xff\xff"
void usage_quit(char *arg0);
int get_ifi(char *


Ïà¹ØÎĵµ£º

Éî¶È½éÉÜLinuxÄÚºËÊÇÈçºÎ¹¤×÷µÄ


Å£½ò×ÖµäÖжÔ"kernel"Ò»´ÊµÄ¶¨ÒåÊÇ£º"½ÏÈíµÄ¡¢Í¨³£ÊÇÒ»¸ö¼á¹û¿ÉʳÓõIJ¿·Ö¡£"µ±È»»¹ÓеڶþÖÖ¶¨Ò壺"ij¸ö¶«Î÷ºËÐÄ»òÕß×îÖØÒªµÄ²¿·Ö¡£"¶ÔLinuxÀ´Ëµ£¬ËüµÄKernelÎÞÒÉÊôÓÚµÚ¶þÖÖ½âÊÍ¡£ÈÃÎÒÃÇÀ´¿´¿´Õâ¸öÖØÒªµÄ¶«Î÷ÊÇÈçºÎ¹¤×÷µÄ£¬ÏÈ´ÓÒ»µãÀíÂÛ˵Æð¡£
¹ãÒ嵨À´Ëµkernel¾ÍÊÇÒ»¸öÈí¼þ£¬ËüÔÚÓ²¼þºÍÔËÐÐÔÚ¼ÆËã»úÉϵÄÓ¦ÓóÌÐòÖ®¼äÌá¹ ......

LinuxÎļþѹËõºÍ½âѹ


1) .tar
½âѹ£ºtar xvf filename.tar
½âѹ£ºtar xjvf filename.tar.bz2
½âѹ£ºtar xzvf filename.tar.gz
´ò°ü£ºtar cvf filename.tar dirname1 dirname2
´ò°ü£ºtar czvf filename.tar.gz dirname1 dirname2
2) .gzºÍ.Z
½âѹ£ºgunzip filename.tar.gz
½âѹ£ºgunzip filename.Z
´ò°ü£ºgzip  ......

4.1. Introduction to Linux Routing


4.1. Introduction to Linux Routing
The design of IP routing allows for very simple route definitions for small networks, while not hindering the flexibility of routing in complex environments. A key concept in IP routing is the ability to define what addresses are locally reachable as oppose ......

Linux×öÒ»¸ö¹¦ÄÜÍ걸µÄ·ÓÉÆ÷

±¾ÎÄÖ÷Òª½éÉÜÈçºÎÓÃLinux×öÒ»¸ö¹¦ÄÜÍ걸µÄ·ÓÉÆ÷£¬ÕâÀォÖ÷Òª½éÉܾ²Ì¬Â·ÓÉÆ÷ºÍ¶¯Ì¬Â·ÓÉÆ÷µÄÅäÖ㬵«²»°üÀ¨IPαװ»òÕß˵¹«ÓÃÒ»¸öIPµØÖ··ÃÎÊÍâÃæÍøÂçµÈÎÊÌâ¡£ÆäÒѾ­²»ÊôÓÚ±¾Ö÷ÌâÌÖÂ۵ķ¶Î§£¬Çë²Î¿¼ÆäËûÈç·À»ðǽµÄÅäÖõȵÄÄÚÈÝ¡£
LRP(Linux Router Project)ÒѾ­³ÉÁ¢ÁËÓкü¸ÄêµÄʱ¼äÁË¡£Õâ¸ö¼Æ»®µÄÄ¿µÄÊÇÀûÓÃLinux²Ù×÷ϵͳ½«À ......

WinCE EbootÖмÓÈëLinux bootµÄÖ§³Ö

Index: flash.c
===================================================================
--- flash.c    (revision 1804)
+++ flash.c    (working copy)
@@ -26,6 +26,8 @@
#include "ebootnand.h"
#include "ll_nand.h"
#includ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ