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
相关文档:
Linux 2.6下SPI设备模型
--------基于AT91RM9200分析
Atmel公司的ARM AT系列,其SPI驱动在kernel 2.6.23里已经包含。如果你打了at91-patch补丁的话,则在内核配置时要小心。在Device Drivers---- > Character devices ---- >取消选中SPI Driver(legacy) for at91rm9200 pro ......
Here is small script that does this. Debian or Ubuntu GNU/Linux does
not comes with any SYS V init script (located in /etc/init.d directory)
.
You create a script as follows and use it to stop or flush the iptables rules.
Please don't type rules at command prompt. Use the script to sp ......
//videoserver
#!/bin/bash
#
# videoserver
#
# chkconfig: 3456 11 91
# description: videoserver
# Source function library.
. /etc/rc.d/init.d/functions
prog="videoserver"
start() {
# Start daemons.
echo -n $"Starting $prog: "
/video/videoserver/recordvideosvr /video/videoserver ......