IOCTL 添加路由
来源:互联网 发布:ubuntu paichu fuzhi 编辑:程序博客网 时间:2024/06/04 01:10
#include <errno.h>#include <stdio.h>#include <string.h>#include <stdlib.h>#include <net/route.h>#include <sys/types.h>#include <sys/ioctl.h>int main(char** args) { int sockfd; struct rtentry route; struct sockaddr_in *addr; int err = 0; // create the socket if((sockfd = socket(AF_INET, SOCK_DGRAM, 0)))<0){perror("socket");exit(1);} memset(&route, 0, sizeof(route)); addr = (struct sockaddr_in*) &route.rt_gateway; addr->sin_family = AF_INET; addr->sin_addr.s_addr = inet_addr("192.168.2.1"); addr = (struct sockaddr_in*) &route.rt_dst; addr->sin_family = AF_INET; addr->sin_addr.s_addr = INADDR_ANY; addr = (struct sockaddr_in*) &route.rt_genmask; addr->sin_family = AF_INET; addr->sin_addr.s_addr = INADDR_ANY; // TODO Add the interface name to the request route.rt_flags = RTF_UP | RTF_GATEWAY; route.rt_metric = 0; if ((err = ioctl(sockfd, SIOCADDRT, &route)) != 0) { perror("SIOCADDRT failed"); exit(1); }}
0 0
- IOCTL 添加路由
- Wince6.0 添加IOCTL
- Wince6.0 添加IOCTL
- Wince6.0 添加IOCTL
- 添加字符设备ioctl
- 添加路由
- 添加路由
- 添加路由
- 添加路由
- 添加路由
- 添加路由
- [转帖]Wince6.0 添加IOCTL
- 添加静态路由 删除路由
- solaris添加静态路由
- linux添加路由
- linux 添加静态路由
- VC动态添加路由
- AIX 添加路由
- GDB的使用,重点讲解图像化 gdb -tui 方式
- XCO教程
- java 中的枚举类
- 【玲珑学院OJ1058】Coco(记忆化搜索)
- UVa 272 Tex Quotes
- IOCTL 添加路由
- js中的基础text(),html(),val()有什么区别
- win10下硬盘安装ubuntu (完整版)
- 解析 xml 安卓
- Uboot_Makefile 总结
- iOS开发- 友盟SDK开发,社会化分享攻略
- STM32F103/ <1>开发环境IDE的选择
- Java 9,OSGi以及模块化的未来
- 第五届蓝桥杯软件类省赛真题-C-A-3_神奇算式