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 *
Ïà¹ØÎĵµ£º
Å£½ò×ÖµäÖжÔ"kernel"Ò»´ÊµÄ¶¨ÒåÊÇ£º"½ÏÈíµÄ¡¢Í¨³£ÊÇÒ»¸ö¼á¹û¿ÉʳÓõIJ¿·Ö¡£"µ±È»»¹ÓеڶþÖÖ¶¨Ò壺"ij¸ö¶«Î÷ºËÐÄ»òÕß×îÖØÒªµÄ²¿·Ö¡£"¶ÔLinuxÀ´Ëµ£¬ËüµÄKernelÎÞÒÉÊôÓÚµÚ¶þÖÖ½âÊÍ¡£ÈÃÎÒÃÇÀ´¿´¿´Õâ¸öÖØÒªµÄ¶«Î÷ÊÇÈçºÎ¹¤×÷µÄ£¬ÏÈ´ÓÒ»µãÀíÂÛ˵Æð¡£
¹ãÒ嵨À´Ëµkernel¾ÍÊÇÒ»¸öÈí¼þ£¬ËüÔÚÓ²¼þºÍÔËÐÐÔÚ¼ÆËã»úÉϵÄÓ¦ÓóÌÐòÖ®¼äÌá¹ ......
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
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×öÒ»¸ö¹¦ÄÜÍ걸µÄ·ÓÉÆ÷£¬ÕâÀォÖ÷Òª½éÉܾ²Ì¬Â·ÓÉÆ÷ºÍ¶¯Ì¬Â·ÓÉÆ÷µÄÅäÖ㬵«²»°üÀ¨IPαװ»òÕß˵¹«ÓÃÒ»¸öIPµØÖ··ÃÎÊÍâÃæÍøÂçµÈÎÊÌâ¡£ÆäÒѾ²»ÊôÓÚ±¾Ö÷ÌâÌÖÂ۵ķ¶Î§£¬Çë²Î¿¼ÆäËûÈç·À»ðǽµÄÅäÖõȵÄÄÚÈÝ¡£
LRP(Linux Router Project)ÒѾ³ÉÁ¢ÁËÓкü¸ÄêµÄʱ¼äÁË¡£Õâ¸ö¼Æ»®µÄÄ¿µÄÊÇÀûÓÃLinux²Ù×÷ϵͳ½«À ......
Index: flash.c
===================================================================
--- flash.c (revision 1804)
+++ flash.c (working copy)
@@ -26,6 +26,8 @@
#include "ebootnand.h"
#include "ll_nand.h"
#includ ......