クロスコンパイルifplugdのifplugstatus

8355 ワード

板子:helper 2416  外に出られないほどカッコいいです.  c+++ハハハ堂:31843264
ifplugd URLhttp://0pointer.de/lennart/projects/ifplugd/       ネットワークが接続されているかどうかを検出するために使用することができます.例えば、有線LANケーブルが接続されているかどうか、無線LANカードが接続されていますか?  3 gのはしばらくテストできません.    また、networkmanagerは、コマンドラインインターフェースを提供するプログラムnmcliを検出するためにも使用することができる.
ifplugd-0.28 tar.gzをダウンロードします.
 tar-xvf ifplugd-0.28 tar.gz
cd ifplugd-0.28
このディレクトリの下で新規作成
ifplugstatus-jyx.path
内容は以下の通りです
diff -uN ifplugd-0.28/src//ifplugstatus.c ifplugd-0.28.jyx/src//ifplugstatus.c
--- ifplugd-0.28/src//ifplugstatus.c	2005-01-05 08:25:31.000000000 +0800
+++ ifplugd-0.28.jyx/src//ifplugstatus.c	2012-11-10 17:15:22.000000000 +0800
@@ -31,8 +31,6 @@
 #include <sys/ioctl.h>
 #include <net/if.h>
 
-#include <libdaemon/dlog.h>
-
 #include "interface.h"
 #include "svn-revision.h"
 
@@ -157,7 +155,7 @@
                 break;
             case 'V':
 #ifdef SVN_REVISION
-		 printf("ifplugstatus "VERSION" (SVN: "SVN_REVISION")
"); + //printf("ifplugstatus "VERSION" (SVN: "SVN_REVISION")
"); #else printf("ifplugstatus "VERSION"
"); #endif diff -uN ifplugd-0.28/src//interface.c ifplugd-0.28.jyx/src//interface.c --- ifplugd-0.28/src//interface.c 2005-01-05 08:25:31.000000000 +0800 +++ ifplugd-0.28.jyx/src//interface.c 2012-11-10 18:01:24.000000000 +0800 @@ -22,11 +22,11 @@ #include <config.h> #endif -#include <linux/sockios.h> -#include <linux/if_ether.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/ioctl.h> +#include <linux/sockios.h> +#include <linux/if_ether.h> #include <linux/if.h> #include <syslog.h> #include <string.h> @@ -41,8 +41,6 @@ #include "interface.h" #include "wireless.h" -#include <libdaemon/dlog.h> - void interface_up(int fd, char *iface) { struct ifreq ifr; @@ -51,7 +49,7 @@ if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) { if (interface_do_message) - daemon_log(LOG_WARNING, "Warning: Could not get interface flags."); + printf("Warning: Could not get interface flags."); return; } @@ -61,21 +59,21 @@ if (ioctl(fd, SIOCGIFADDR, &ifr) < 0) { if (interface_do_message) - daemon_log(LOG_WARNING, "Warning: Could not get interface address."); + printf("Warning: Could not get interface address."); } else if (ifr.ifr_addr.sa_family != AF_INET) { if (interface_do_message) - daemon_log(LOG_WARNING, "Warning: The interface is not IP-based."); + printf("Warning: The interface is not IP-based."); } else { ((struct sockaddr_in *)(&ifr.ifr_addr))->sin_addr.s_addr = INADDR_ANY; if (ioctl(fd, SIOCSIFADDR, &ifr) < 0) { if (interface_do_message) - daemon_log(LOG_WARNING, "Warning: Could not set interface address."); + printf("Warning: Could not set interface address."); } } if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) { if (interface_do_message) - daemon_log(LOG_WARNING, "Warning: Could not get interface flags."); + printf("Warning: Could not get interface flags."); return; } @@ -84,7 +82,7 @@ if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) if (interface_do_message) - daemon_log(LOG_WARNING, "Warning: Could not set interface flags."); + printf("Warning: Could not set interface flags."); } interface_status_t interface_detect_beat_mii(int fd, char *iface) { @@ -98,7 +96,7 @@ if (ioctl(fd, SIOCGMIIPHY, &ifr) == -1) { if (interface_do_message) - daemon_log(LOG_ERR, "SIOCGMIIPHY failed: %s", strerror(errno)); + printf("SIOCGMIIPHY failed: %s", strerror(errno)); return IFSTATUS_ERR; } @@ -107,7 +105,7 @@ if (ioctl(fd, SIOCGMIIREG, &ifr) == -1) { if (interface_do_message) - daemon_log(LOG_ERR, "SIOCGMIIREG failed: %s", strerror(errno)); + printf("SIOCGMIIREG failed: %s", strerror(errno)); return IFSTATUS_ERR; } @@ -126,7 +124,7 @@ if (ioctl(fd, SIOCDEVPRIVATE, &ifr) == -1) { if (interface_do_message) - daemon_log(LOG_ERR, "SIOCDEVPRIVATE failed: %s", strerror(errno)); + printf("SIOCDEVPRIVATE failed: %s", strerror(errno)); return IFSTATUS_ERR; } @@ -135,7 +133,7 @@ if (ioctl(fd, SIOCDEVPRIVATE+1, &ifr) == -1) { if (interface_do_message) - daemon_log(LOG_ERR, "SIOCDEVPRIVATE+1 failed: %s", strerror(errno)); + printf("SIOCDEVPRIVATE+1 failed: %s", strerror(errno)); return IFSTATUS_ERR; } @@ -159,7 +157,7 @@ if (ioctl(fd, SIOCETHTOOL, &ifr) == -1) { if (interface_do_message) - daemon_log(LOG_ERR, "ETHTOOL_GLINK failed: %s", strerror(errno)); + printf("ETHTOOL_GLINK failed: %s", strerror(errno)); return IFSTATUS_ERR; } @@ -179,7 +177,7 @@ if (ioctl(fd, SIOCGIFFLAGS, &ifr) == -1) { if (interface_do_message) - daemon_log(LOG_ERR, "SIOCGIFFLAGS failed: %s", strerror(errno)); + printf("SIOCGIFFLAGS failed: %s", strerror(errno)); return IFSTATUS_ERR; } @@ -197,7 +195,7 @@ if (!(f = fopen("/proc/net/wireless", "r"))) { if (interface_do_message) - daemon_log(LOG_WARNING, "Failed to open /proc/net/wireless: %s",strerror(errno)); + printf("Failed to open /proc/net/wireless: %s",strerror(errno)); return -1; } @@ -229,7 +227,7 @@ if (q < 0) { if (interface_do_message) - daemon_log(LOG_ERR, "Failed to find interface in /proc/net/wireless"); + printf("Failed to find interface in /proc/net/wireless"); } return q; @@ -249,7 +247,7 @@ if (ioctl(fd, SIOCGIWSTATS, &req) < 0) { if (interface_do_message) - daemon_log(LOG_ERR, "Failed to get interface quality: %s
", strerror(errno)); + printf("Failed to get interface quality: %s
", strerror(errno)); return -1; } @@ -263,7 +261,7 @@ if (ioctl(fd, SIOCGIWRANGE, &req) < 0) { if (interface_do_message) - daemon_log(LOG_ERR, "SIOCGIWRANGE failed: %s
", strerror(errno)); + printf("SIOCGIWRANGE failed: %s
", strerror(errno)); return -1; } @@ -302,7 +300,7 @@ if (ioctl(fd, SIOCGIWAP, &req) < 0) { if (interface_do_message) - daemon_log(LOG_WARNING, "Failed to get AP address: %s",strerror(errno)); + printf("Failed to get AP address: %s",strerror(errno)); return IFSTATUS_ERR; } @@ -314,7 +312,7 @@ if ((q = get_wlan_qual_new(fd, iface)) < 0) if ((q = get_wlan_qual_old(iface)) < 0) { if (interface_do_message) - daemon_log(LOG_WARNING, "Failed to get wireless link quality."); + printf("Failed to get wireless link quality."); return IFSTATUS_ERR; } diff -uN ifplugd-0.28/src//Makefile.jyx ifplugd-0.28.jyx/src//Makefile.jyx --- ifplugd-0.28/src//Makefile.jyx 1970-01-01 08:00:00.000000000 +0800 +++ ifplugd-0.28.jyx/src//Makefile.jyx 2012-11-10 18:00:11.000000000 +0800 @@ -0,0 +1,2 @@ +ifplugstatus:interface.c ifplugstatus.c + arm-linux-gcc interface.c ifplugstatus.c -I ./ -o ifplugstatus
patch-p 1cd src
make-f Makefile.jyx
クロスコンパイルのifplugstatusを生成することができます.
実行します
類似出力
lo:link beat detected eth 0:unplugged wlan 0:link beat detected