ÔÚ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 ......
1£¬ÏÔÖøÓ°ÏìϵͳÐÔÄܵÄ4ÖÖ×ÊÔ´
(1),CPUʱ¼ä
(2),ÄÚ´æ
(3),Ó²ÅÌI/O
(4),ÍøÂçI/O
2£¬·ÖÎöCPUʹÓÃÇé¿ö
ʹÓÃvmstat²É¼¯CPUµÄÐÔÄÜÆ¿¾±
[root@local]# vmstat 2
procs -----------memory---------- ---swap-- -----io-- ......
°´ÒÔϲ½ÖèÀ´,ÏÈдÕâô¶àÀ´ÌáÐÑÏÂ×Ô¼º:
1.ÊìϤlinuxµÄ»ù±¾»·¾³,ÊìϤlinuxµÄ»ù±¾ÃüÁî.
2.ÊìϤlinuxµÄ½»²æ±àÒë»·¾³µÄµÄÅäÖÃ.
3.¸´Ï°»ù±¾µÄCÓïÑÔ֪ʶ.
&nbs ......
£¨1£©exit()Óë_exit()Çø±ð£º _exit()Ö±½Óʹ½ø³ÌÍ£Ö¹ÔËÐУ¬Çå³ýÆ÷ʹÓõÄÄÚ´æ¿Õ¼ä£¬Ïú»ÙÆäÔÚÄÚºËÖеĸ÷ÖÖÊý¾Ý½á¹¹¡£
exit()º¯ÊýÔÚµ÷ÓÃexitϵͳµ÷ÓÃ֮ǰҪ¼ì²éÎļþµÄ´ò¿ªÇé¿ö£¬°ÑÎļþ»º³åÇøÖеÄÄÚÈÝд»ØÎļþ£¬ÇåÀíI/O»º³å£¨ÍƼöʹÓÃÕâ¸öº¯Êý£©
£¨2£©waitpid
#include <sys/ ......
Linux¶àÏ̱߳à³Ì¼¼Êõ×ܽá
1
¡¢Ï̵߳Ĵ´½¨¡¢ÖÕÖ¹¼°¿ØÖÆ£º
Èκνø³ÌÔÚÆô¶¯Ê±¾ÍÒÑÓÐÁËÒ»¸öÖ÷Ị̈߳¬Èç¹ûÐèÒªÔÙÉú³ÉÏß³ÌÔòʹÓÃ
pthread_create
º¯Êý£¬Ôڸú¯ÊýÖпÉÒÔÖ¸¶¨Ï̵߳ÄÊôÐÔ¡¢Ïß³ÌÀý³Ì¡¢´«¸øÏß³ÌÀý³ÌµÄ²ÎÊý¡£Ïß³ÌÀý³ÌÊÇÒ»¸öÓû§×Ô¶¨ÒåµÄº¯Êý£¬¼°Ïß³ÌÖ´ÐеĴúÂë¡£µ±Ïß³ÌÀý³Ì· ......