Ping_ppp0_call.zip

  • 泽强
    了解作者
  • Visual C++
    开发工具
  • 1KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 12
    下载次数
  • 2013-04-15 20:44
    上传日期
epoll linux 代码 网络编程实现3G网络接入自动切换,适合无线网络设备开发者参考代码
Ping_ppp0_call.zip
  • Ping_ppp0_call.c
    3.3KB
内容介绍
#include <stdio.h> #include <stdlib.h> #include <signal.h> #include <fcntl.h> #include <unistd.h> #include <string.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <linux/autoconf.h> #include "nvram.h" #include <pthread.h> void call_dddppp() { system("nvram_set 2860 curWanMode 3G"); system("echo 12132nocable > /tmp/test_recallppp"); printf("%s @ %d\n", __FUNCTION__, __LINE__); printf("%s @ %d\n", __FUNCTION__, __LINE__); system("3g2dhcp.sh"); system("3poe_pppcalll.sh"); } void Ping_ppp0_interval() { //system(60); int interval = 60; char stri[] = {0}; printf("Test_ping 50\n"); sprintf(stri," %d\n",interval); sleep(stri); } void Wan_Ping_call() { char str1[] = "8.8.8.7"; char str2[] = "eth2.2"; char str3[] = ">/tmp/Ping_tmp &"; char str[] = {0}; char stri[] = {0}; int Count = 10; //int interval = 60; //system("ping -c 10 -I ppp0 8.8.8.7 >/tmp/Ping_tmp &"); sprintf(str,"ping -c %d -I %s %s %s\n",Count,str2,str1,str3); printf("STR is: %s",str); system(str); printf("STR2 is: %s",str); printf("Test_ping 5\n"); //system(60); //sprintf(stri,"interval %d",interval); //system(stri); } void Ping_3G_call() { system("ping -c 10 -I ppp0 8.8.8.7 >/tmp/Ping_tmp &"); printf("Test_ping 01\n"); //system(60); } void Ping_3G_Secondary() { const char *Pcm = nvram_bufget(RT2860_NVRAM, "Primary"); } void Ping_3G_Primary() { const char *Scm = nvram_bufget(RT2860_NVRAM, "Secondary"); } int main(int argc, char *argv[]) { int port, rc; static int pppd_call_flag = 0; int cnt = 0; FILE *fp; char buf[1024]; char *pos; const char *Pcm = nvram_bufget(RT2860_NVRAM, "Primary"); const char *Scm = nvram_bufget(RT2860_NVRAM, "Secondary"); while (1) { Wan_Ping_call(); //Ping_3G_call(); sleep(60); //Ping_3G_call(); //Ping_ppp0_interval(); if((fp = popen("cat /tmp/Ping_tmp", "r")) == NULL){ printf("Open Ping_tmp file error!\n"); return 0; } rc = fread(buf, 1, 1024, fp); printf("Buffer1 is : %s\n",buf); pclose(fp); if(rc == -1){ return 0; } else{ printf("Test_ping 0\n"); if((pos = strstr(buf, "packets transmitted, ")) != NULL){ pos += strlen("packets transmitted, "); printf("Test_ping 1\n"); printf("Pos: %s\n",pos); printf("Buffer2 is : %s\n",buf); /*if(*pos == '0') { printf("Test_ping 2\n"); call_dddppp(); pppd_call_flag = 1; /*if (pppd_call_flag == 0) { cnt++; if (cnt >= 10 ) { printf("Test_ping 2\n"); recall_ppp(); pppd_call_flag = 1; cnt = 0; } }*/ //} //printf("PCM: %s",Pcm); printf("SCM: %s",Scm); if ((*pos == '0')&&(strncmp(Scm, "PPPOE", 5)) == 0){ printf("Test_ping 6\n"); system("Ping_pppoe.sh"); } else if ((*pos == '0')&&(strncmp(Scm, "STATIC", 6) == 0)){ printf("Test_ping 7\n"); system("Ping_static.sh"); } else if ((*pos == '0')&&(strncmp(Scm, "DHCP", 4) == 0)){ printf("Test_ping 8\n"); system("Ping_dhcp.sh"); } else if ((*pos == '0')&&(strncmp(Scm, "3G", 2) == 0)){ printf("Test_ping 9\n"); system("3poe_pppcalll.sh"); } else { printf("Test_ping 3\n"); cnt = 0; pppd_call_flag = 0; } } } } }
评论
    相关推荐
    • autoconf.zip
      Linux中的auto_config.h该文件是编译内核时的配置文件,系统编译信息在该文件中指定,注释掉某些宏即可裁剪该部分的代码
    • qpopper2.53.tar.Z
      pop3 server
    • imap-4.7.tar.Z
      被广泛使用的email服务器 /IMAPD/POPD
    • 53308459Add_Dlt_TabCtrl.rar
      Tab分页的删除和添加,实现分页动态的管理。
    • ns-allinone-2.33.tar.gz
      ns2.33这是目前比较新的ns2版本,欢迎下载
    • NetVideoActiveX23.rar
      海康威视 网络监控插件 带有例子 和开发的dll文件,非常易用
    • UR054g_(R01).zip
      法国inventel的ur054g(r01)v1.1的无线网卡驱动。
    • eat.rar
      外卖叫餐系统,采用ACCESS数据库,有完整天的后台管理系统
    • KSTVTUNE.ZIP
      装摄像头驱动需要用到的文件。Microsoft DirectX 9 SDK
    • Skin++.rar
      知名的Skin++界面库,内含所有库文件和大量皮肤文件.该库使用方便,可以减少您美化程序的痛苦.本版是破解版,没有注册提示.但只供学习研究使用哦,不要用在商业用途.