ÔÚlinuxϲéѯ·ÓÉ
ÔÚlinux²éѯ·Óɵķ½·¨ÓкܶàÖÖ¡£ÏÂÃæ½éÉÜÒ»ÖÖ´Óiproute¿ªÔ´Èí¼þÖÐÌáÈ¡³öÀ´µÄÒ»ÖÖ·½·¨¡£ÔÚubuntu904ϱàÒ룬ÔËÐÐͨ¹ý¡£
±àÒë: gcc -o reqroute iproute_linux.c
ʹÓÃ: ./reqroute 1.2.3.4
½á¹û:source:1.3.4.5
Gateway:192.168.1.3
Dev:eth0
Ô´´úÂëÈçÏ£º
iproute_linux.h
typedef unsigned char __u8;
typedef short __s16;
typedef unsigned int __u32;
typedef struct{
__u8 family;
__u8 bytelen;
__s16 bitlen;
__u32 flags;
__u32 data[8];
} inet_prefix;
static struct{
int tb;
int cloned;
int flushed;
char *flushb;
int flushp;
int flushe;
struct rtnl_handle *rth;
int protocol, protocolmask;
int scope, scopemask;
int type, typemask;
int tos, tosmask;
int iif, iifmask;
int oif, oifmask;
int realm, realmmask;
inet_prefix rprefsrc;
inet_prefix rvia;
inet_prefix rdst;
inet_prefix mdst;
inet_prefix rsrc;
inet_prefix msrc;
} filter;
struct dn_naddr{
unsigned short a_len;
unsigned char a_addr[20];
};
struct ipx_addr {
u_int32_t ipx_net;
u_int8_t ipx_node[6];
};
struct idxmap{
struct idxmap * next;
unsigned index;
int type;
int alen;
unsigned flags;
unsigned char addr[20];
char name[16];
};
struct rtnl_handle{
int fd;
struct sockaddr_nl local;
struct sockaddr_nl peer;
__u32 seq;
__u32 dump;
};
ÁíÒ»¸öÎļþ£º
iproute_linux.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <syslog.h>
#include <fcntl.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>
#includ
Ïà¹ØÎĵµ£º
Name
hosts - The static table lookup for host names
Synopsis
/etc/hosts
Description
This manual page describes the format of the /etc/hosts
file. This file is a simple text file that
associates IP addresses with hostnames, one line per IP address. For
each host a single line should be presen ......
caddr_t //ºËÐĵØÖ·
clock_t //ʱÖӵδð¼ÆÊýÆ÷
compt_t //ѹËõµÄʱÖӵδð
dev_t //É豸ºÅ£¨Ö÷ºÍ´Î£©
fd_set //ÎļþÃèÊö·û¼¯
fpos_t //ÎļþλÖÃ
gid_t //ÊýÖµ×éID
ino_t //i½Úµã±àºÅ
mode_t //ÎļþÀ ......
ÒÔϵÄһЩÎÄ×ÖÖ÷ÒªÀ´Ô´ÓÚkhg£¬johnsonmµÄWrite linux device driver£¬Brennan's Guide to Inline Assembly£¬The Linux A-Z£¬»¹ÓÐÇ廪BBSÉϵÄÓйØdevice driverµÄһЩ×ÊÁÏ. ÕâЩ×ÊÁÏÓеÄÒѾ¹ýʱ£¬ÓеϹÓÐһЩ´íÎó£¬ÎÒÒÀ¾Ý×Ô¼ºµÄÊÔÑé½á¹û½øÐÐÁËÐÞÕý.
Ò»¡¢Linux device driver µÄ¸ÅÄî
ϵͳµ÷ÓÃÊDzÙ× ......
VirtualBox¹Ù·½ÍøÕ¾£ºhttp://www.virtualbox.org/
ÒÔÏÂΪubuntu Ϊƽ̨µÄ°²×°¡¢ÅäÖá¢Ê¹Óã¬ÆäʵÔÚ¸÷¸ö·¢ÐаæÖеÄʹÓö¼²î²»¶à£¬Ö»ÊÇÔÚÏÂÔØµÄʱºòÐèÒªÏÂÔØÏà¶ÔÓ¦Ö÷ϵͳƽ̨µÄ°²×°°ü¼´¿É¡£
»·¾³ÐèÇó£º
VirtualBoxÐèÒªker ......
Linux¶àÏ̱߳à³Ì¼¼Êõ×ܽá
1
¡¢Ï̵߳Ĵ´½¨¡¢ÖÕÖ¹¼°¿ØÖÆ£º
Èκνø³ÌÔÚÆô¶¯Ê±¾ÍÒÑÓÐÁËÒ»¸öÖ÷Ị̈߳¬Èç¹ûÐèÒªÔÙÉú³ÉÏß³ÌÔòʹÓÃ
pthread_create
º¯Êý£¬Ôڸú¯ÊýÖпÉÒÔÖ¸¶¨Ï̵߳ÄÊôÐÔ¡¢Ïß³ÌÀý³Ì¡¢´«¸øÏß³ÌÀý³ÌµÄ²ÎÊý¡£Ïß³ÌÀý³ÌÊÇÒ»¸öÓû§×Ô¶¨ÒåµÄº¯Êý£¬¼°Ïß³ÌÖ´ÐеĴúÂë¡£µ±Ïß³ÌÀý³Ì· ......