ARM平台下iptables编译

target: arm device: FriendlyARM tiny210

./configure  --prefix=/home/iptables-arm  
                 --host=arm-linux 
                 --with kernel=/opt/FriendlyARM/tiny210/linux/linux-2.6.35.7/
make
make install

Ubuntu 下编译 qtopia

qtopia: 2.2.0 OS: ubuntu 12.1

安装必要软件

sudo apt-get -y install x-dev libx11-dev x11proto-xext-dev  libxext-dev libqt3-mt-dev uuid uuid-dev 
sudo apt-get install libv4l-dev

遇到的问题

问题1
安装libv4l-dev后还是会提示缺少 linux/videodev.h

解决
原因是 3.2.0 已经移除了对 v4l1 的支持,可以在linux/目录下建立软链接:
 ln -s /usr/include/lib4l1.h        /usr/include/linux/videodev.h
问题2
error: ‘ptrdiff_t’ does not name a type

解决
这个错误应该是libc的版本造成的,解决的方法是在每个报错的头文件中加入
 include  <stddef>
问题3
undefined reference to `uuid_generate'

解决
 git  clone  git://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git  或者网络下载e2fsprogs源码包
 编译e2fsprogs:
./configure --enable-elf-shlibs
sudo cp -av libuuid.so*        /usr/lib

接下来正常编译qtopia,Done !

Linux C获取系统网卡信息

OS:ubuntu 12.04

int getNetCardCount()
{
    int nCount = 0;
    FILE *file = fopen("/proc/net/dev", "r");
    if(!file)
    {   
        debug("Open /proc/net/dev failed by %s !\n", strerror(errno));
        return nCount;
    }   

    char szLine[512];
    fgets(szLine, sizeof(szLine), file);
    fgets(szLine, sizeof(szLine), file);

    while(fgets(szLine, sizeof(szLine), file))
    {   
        char szName[128] = {0};
        sscanf(szLine, "%s", szName);
        int nLen = strlen(szName);
        if(nLen <= 0)
            continue;
        if(szName[nLen - 1] == ':')
            szName[nLen - 1] = 0;
        if(strcmp(szName, "lo") == 0)
            continue;
        nCount++;
    }   

    fclose(file);
    file = NULL;
    return nCount;
}

void dispNetInfo(const char *szDevName, struct netCardInfo *netCardInfo)
{
    int s = socket(AF_INET, SOCK_DGRAM, 0);
    if(s < 0)
    {
        debug("Create socket failed by %s!\n", strerror(errno));
        return;
    }
    struct ifreq ifr;
    unsigned char mac[6];
    unsigned long nIP, nNetmask, nBroadIP;

    strcpy(netCardInfo->devName, szDevName);
    printf("%s\n", szDevName);

    strcpy(ifr.ifr_name, szDevName);
    if(ioctl(s, SIOCGIFHWADDR, &ifr) < 0)
    {
        return;
    }
    memcpy(netCardInfo->mac, ifr.ifr_hwaddr.sa_data, sizeof(mac));
    //fprintf(stderr, "\tMAC:%02x-%02x-%02x-%02x-%02x-%02x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);

    strcpy(ifr.ifr_name, szDevName);
    if(ioctl(s, SIOCGIFADDR, &ifr) < 0)
        nIP = 0;
    else
        nIP = *(unsigned long*)&ifr.ifr_broadaddr.sa_data[2];

    strcpy(netCardInfo->IP,  inet_ntoa(*(struct in_addr*)&nIP));

    //fprintf(stderr, "\tIP:%s\n", inet_ntoa(*(struct in_addr*)&nIP));

    strcpy(ifr.ifr_name, szDevName);
    if(ioctl(s, SIOCGIFBRDADDR, &ifr) < 0)
        nBroadIP = 0;
    else
        nBroadIP = *(unsigned long*)&ifr.ifr_broadaddr.sa_data[2];
    strcpy(netCardInfo->broadIp, inet_ntoa(*(struct in_addr*)&nBroadIP));
    //fprintf(stderr, "\tBroadIP:%s\n", inet_ntoa(*(struct in_addr*)&nBroadIP));

   strcpy(ifr.ifr_name, szDevName);
    if(ioctl(s, SIOCGIFNETMASK, &ifr) < 0)
        nNetmask = 0;
    else
        nNetmask = *(unsigned long*)&ifr.ifr_netmask.sa_data[2];
    strcpy(netCardInfo->netMask, inet_ntoa(*(struct in_addr*)&nNetmask));
    //fprintf(stderr, "\tNetmask:%s\n", inet_ntoa(*(struct in_addr*)&nNetmask));

    strcpy(ifr.ifr_name, szDevName);
    if(ioctl(s, SIOCGIFMTU, &ifr) < 0)
        netCardInfo->mtu = 0;
    else
        netCardInfo->mtu = ifr.ifr_mtu;
        //fprintf(stderr, "\tMTU:%d", ifr.ifr_mtu);

    close(s);
}

void dispActiveAdap(struct netInfo *netInfo)
{
    int fd;
    int count;
    struct ifconf ifc;
    struct ifreq ifr[512];

    if((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
    {
        debug("socket error by %s\n", strerror(errno));
        return;
    }
    bzero(&ifc, sizeof(ifc));
    bzero(ifr, sizeof(ifr));
    ifc.ifc_len = sizeof(ifr);
    ifc.ifc_req = ifr;
    if(ioctl(fd, SIOCGIFCONF, &ifc) < 0)
    {
        debug("ioctl error by %s\n", strerror(errno));
        return;
    }
    count = ifc.ifc_len / sizeof(struct ifreq);
    int i;
    for(i = 0; i < count; i++)
    {
        struct ifreq *req = &ifr[i];
        if ((strcmp(req->ifr_name, "lo") != 0))
        {
            dispNetInfo(req->ifr_name, &(netInfo->cardInfo[i]));
        }
    }
    close(fd);
    return ;
}

void getDNS(struct netInfo *netInfo)
{
    int i;
    if(res_init() < 0)
    {
        debug("res_init error by %s\n", strerror(errno));
        return;
    }
    for(i = 0; i < _res.nscount; i++)
    {
        struct sockaddr *server = (struct sockaddr*)&_res.nsaddr_list[i];
        strcpy(netInfo->dns[i], inet_ntoa(*(struct in_addr*)&(server->sa_data[2])));
        //fprintf(stderr, "DNS%d:%s\n",i+1, inet_ntoa(*(struct in_addr*)&(server->sa_data[2])));
    }
}

WordPress Image Upload Error

问题

wordpress image upload error

解决

wp-admin -> Settings -> Media ----->

Store uploads in this folder    wp-content/uploads

adb通过网络连接Android

setprop service.adb.tcp.port 5555
stop adbd #停止adbd
start adbd #启动adbd

adb connect <IP>
setprop service.adb.tcp.port -1 :恢复USB连接