From ed768d8ea0b3d971f10dcf664f561e0c1b56be85 Mon Sep 17 00:00:00 2001 From: Hamster Tian Date: Mon, 24 Oct 2016 11:37:20 +0800 Subject: [PATCH] malloc.h -> stdlib.h, perform DHCP, remove redundant ifaddrs.o * Some compatibility for macOS * Actually do DHCP plz...Though I don't mean it that way, at least it works (kinda) --- .gitignore | 1 + Makefile | 4 ++-- if_impl_sockraw.c | 2 +- linkedlist.c | 2 +- misc.c | 2 +- net_util.c | 6 ++++-- packet_builder.c | 2 +- packet_plugin.c | 2 +- packet_plugin_printer.c | 2 +- packet_plugin_rjv3.c | 2 +- packet_plugin_rjv3_keepalive.c | 2 +- packet_plugin_rjv3_priv.c | 2 +- packet_plugin_rjv3_prop.c | 2 +- sched_alarm.c | 2 +- 14 files changed, 18 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index ffaf534..b1c4269 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.o .* minieap +ifaddrs.c diff --git a/Makefile b/Makefile index cdb2e32..8b7d354 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ MINIEAP_COMMON_OBJS := config.o logging.o minieap.o misc.o linkedlist.o if_impl.o packet_builder.o \ - packet_util.o packet_plugin.o eap_state_machine.o net_util.o sched_alarm.o ifaddrs.o + packet_util.o packet_plugin.o eap_state_machine.o net_util.o sched_alarm.o -# If your platform does not get getifaddrs, you can find some implemention and compile it +# If your platform does not provide getifaddrs(), you can find some implemention and compile it here #MINIEAP_COMMON_OBJS += ifaddrs.o MINIEAP_PLUGIN_OBJS := if_impl_sockraw.o diff --git a/if_impl_sockraw.c b/if_impl_sockraw.c index 0900a9b..d501676 100644 --- a/if_impl_sockraw.c +++ b/if_impl_sockraw.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include typedef struct _if_impl_sockraw_priv { diff --git a/linkedlist.c b/linkedlist.c index 1b99149..6c45bce 100644 --- a/linkedlist.c +++ b/linkedlist.c @@ -1,6 +1,6 @@ #include "linkedlist.h" #include "misc.h" -#include +#include #include /* Rather naive! */ diff --git a/misc.c b/misc.c index 106833f..5c5882e 100644 --- a/misc.c +++ b/misc.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/net_util.c b/net_util.c index 422d87c..81db70e 100644 --- a/net_util.c +++ b/net_util.c @@ -9,11 +9,11 @@ #include #include #include -#include +#include #include #include #include -#include +#include static int ip_addr_family_cmpfunc(void* family, void* ip_addr) { if (*(short*)family == ((IP_ADDR*)ip_addr)->family) { @@ -192,7 +192,9 @@ static RESULT retrive_if_gateway(const char* ifname, struct nlmsghdr* nl_hdr, st } } +#ifdef DEBUG PR_DBG("%08X %08X %s", dst_addr.s_addr, this_gateway.s_addr, this_ifname); +#endif if (dst_addr.s_addr == 0 && strncmp(this_ifname, ifname, IFNAMSIZ) == 0) { gateway->s_addr = this_gateway.s_addr; return SUCCESS; diff --git a/packet_builder.c b/packet_builder.c index 21bfc97..7f478d2 100644 --- a/packet_builder.c +++ b/packet_builder.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "packet_builder.h" diff --git a/packet_plugin.c b/packet_plugin.c index 66a152c..cb610bb 100644 --- a/packet_plugin.c +++ b/packet_plugin.c @@ -3,7 +3,7 @@ #include "logging.h" #include -#include +#include #include #define TRUE 1 diff --git a/packet_plugin_printer.c b/packet_plugin_printer.c index f4855a5..a968978 100644 --- a/packet_plugin_printer.c +++ b/packet_plugin_printer.c @@ -1,7 +1,7 @@ #include "packet_plugin.h" #include "eth_frame.h" #include "logging.h" -#include "malloc.h" +#include "stdlib.h" #include RESULT printer_prepare_frame(struct _packet_plugin* this, ETH_EAP_FRAME* frame) { diff --git a/packet_plugin_rjv3.c b/packet_plugin_rjv3.c index 6aebd28..1ca26c0 100644 --- a/packet_plugin_rjv3.c +++ b/packet_plugin_rjv3.c @@ -192,7 +192,7 @@ static RESULT rjv3_process_success(struct _packet_plugin* this, ETH_EAP_FRAME* f if (PRIV->dhcp_type == DHCP_DOUBLE_AUTH) { if (PRIV->succ_count < 2) { PR_INFO("正在执行 DHCP 脚本以准备第二次认证"); - system(""); // TODO + system((get_program_config())->run_on_success); // TODO move this to plugin /* Try right before the script ends */ rjv3_start_secondary_auth(this); diff --git a/packet_plugin_rjv3_keepalive.c b/packet_plugin_rjv3_keepalive.c index 2df1cf1..b989224 100644 --- a/packet_plugin_rjv3_keepalive.c +++ b/packet_plugin_rjv3_keepalive.c @@ -6,7 +6,7 @@ #include "sched_alarm.h" #include "misc.h" -#include +#include static uint32_t g_echokey; static uint32_t g_echono; diff --git a/packet_plugin_rjv3_priv.c b/packet_plugin_rjv3_priv.c index 922b409..53c24b7 100644 --- a/packet_plugin_rjv3_priv.c +++ b/packet_plugin_rjv3_priv.c @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include /* diff --git a/packet_plugin_rjv3_prop.c b/packet_plugin_rjv3_prop.c index fb4adfc..e76f4cc 100644 --- a/packet_plugin_rjv3_prop.c +++ b/packet_plugin_rjv3_prop.c @@ -7,7 +7,7 @@ #include "packet_util.h" #include -#include +#include #include RJ_PROP* new_rjv3_prop() { diff --git a/sched_alarm.c b/sched_alarm.c index 80af24f..89c645f 100644 --- a/sched_alarm.c +++ b/sched_alarm.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include typedef struct _alarm_event { int remaining;