在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 ......
出处:http://bbs.java.ccidnet.com
挂接命令(mount)
首先,介绍一下挂接(mount)命令的使用方法,mount命令参数非常多,这里主要讲一下今天我们要用到的。
命令格式:
mount [-t vfstype] [-o options] device dir
其中:
1.-t vfstype 指定文件系统的类型,通常不必指定。mount 会自动选择正确 ......
按以下步骤来,先写这么多来提醒下自己:
1.熟悉linux的基本环境,熟悉linux的基本命令.
2.熟悉linux的交叉编译环境的的配置.
3.复习基本的C语言知识.
&nbs ......
#include <sys/select.h>
#include <sys/time.h>
#include
<sys/types.h>
#include <unistd.h>
int select(int
nfds,fd_set *readfds,fd_set *writefds, fd_set *except fds,struct timeval
*timeout)
void FD_SET(int fd,fd_set *fdset)
void FD_CLR(int fd,fd_set
*fdset)
void F ......