linux获取网络接口名:如eth0
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<net/if.h>
static char *bad_interface_names[] = {
"lo:",
"lo",
"stf", /* pseudo-device 6to4 tunnel interface */
"gif", /* psuedo-device generic tunnel interface */
"dummy",
"vmnet",
NULL /* last entry must be NULL */
};
static int is_bad_interface_name(char *i) {
char **p;
for (p = bad_interface_names; *p; ++p)
if (strncmp(i, *p, strlen(*p)) == 0)
return 1;
return 0;
}
/* This finds the first interface which is up and is not the loopback
* interface or one of the interface types listed in bad_interface_names. */
static char *get_first_interface(void) {
struct if_nameindex * nameindex;
char *i = NULL;
int j = 0;
/* Use if_nameindex(3) instead? */
nameindex = if_nameindex();
if(nameindex == NULL) {
return NULL;
}
while(nameindex[j].if_index != 0) {
if (strcmp(nameindex[j].if_name, "lo") != 0 && !is_bad_interface_name(nameindex[j
相关文档:
1. HCI层协议概述:
HCI提供一套统一的方法来访问Bluetooth底层。如图所示:
从图上可以看出,Host Controller Interface(HCI) 就是用来沟通Host和Module。Host通常就是PC, Module则是以各种物理连接形式(USB,serial,pc-card等)连接到PC上的bluetooth Dongle。
在Host这一端:application,SDP,L2cap等协议 ......
2009-10-27
1,重启 reboot
2009-10-28
1,忘记了root用户密码的解决帮
启动后按esc进入修复模式,选择修复,并选择最后一个。root,进去后,更改密码:passwd root
然后根据提示输入两次密码就行了。
2009-10-29
1,ls
ls -a 查看所有文件
ls -l 查看详细的属性
&nbs ......
3、线程标识
函数原型:
#include <pthread.h>
pthread_t pthread_self(void);
pid_t getpid(void);
getpid()用来取得目前进程的进程识别码,函数说明
例程8
程序目的:实现在新建立的线程中打印该线程的id和进 ......
转贴地址:http://www.linuxsir.org/main/?q=node/137
总结:
zhy2111314
来自:
LinuxSir.Org
整理:
北南南北
摘要:
本文是find 命令的详细说明,可贵的是针对参数举了很多的实例,大量的例证,让初学者更为容易理解;本文是zhyfly兄贴在论坛中;我对本文进行了再次整理,为方便大家阅读;
目录
版权声明
前 ......
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <net/if.h>
int sock_fd;
struct my_addr;
struct ifreq ifr;
unsigned char * addr;
#define ETH_INTERFACE_NAME "e ......