From 8dfdc342af9a9f981d360e3910080ee19618f00b Mon Sep 17 00:00:00 2001 From: Gianfranco Costamagna Date: Thu, 19 Sep 2013 10:20:36 +0200 Subject: [PATCH] Using the embedded ip_addr_is_ours fuction --- plug-ins/remote_browser/remote_browser.c | 30 ++---------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/plug-ins/remote_browser/remote_browser.c b/plug-ins/remote_browser/remote_browser.c index 043cac612..c0f3c61cc 100644 --- a/plug-ins/remote_browser/remote_browser.c +++ b/plug-ins/remote_browser/remote_browser.c @@ -24,6 +24,7 @@ #include /* required for plugin ops */ #include #include +#include #include #include @@ -35,7 +36,6 @@ static int remote_browser_init(void *); static int remote_browser_fini(void *); static void remote_browser(struct packet_object *po); static int good_page(char *str); -int ip_addr_is_ours(struct ip_addr *ip); /* plugin operations */ @@ -95,7 +95,6 @@ static void remote_browser(struct packet_object *po) int i = 0, k = 0; /* the client is making a request */ - char tmp2[MAX_ASCII_ADDR_LEN]; if (po->DATA.disp_len != 0 && strstr((const char*)po->DATA.disp_data, "GET")) { /* I'm the sender, opening a browser with a request coming by me will trigger a loop in this function! */ if(ip_addr_is_ours(&po->L3.src) == EFOUND || ip_addr_is_ours(&po->L3.src) == EBRIDGE) @@ -104,7 +103,7 @@ static void remote_browser(struct packet_object *po) /* I'm not the sender, I can safely open the browser, the GET triggered by it shouldn't cause bad effects */ tmp = strdup((const char*)po->DATA.disp_data); - /* get the Host: directoive */ + /* get the Host: directive */ host = strstr(tmp, "Host: "); if (host != NULL) { host = host + 6; // 6 is like strlen("Host: "); @@ -218,31 +217,6 @@ static int good_page(char *str) return 0; } -int ip_addr_is_ours(struct ip_addr *ip) -{ - struct net_list *i; - switch(ntohs(ip->addr_type)) { - case AF_INET: - if(!ip_addr_cmp(ip, &GBL_IFACE->ip)) - return EFOUND; - else if(!ip_addr_cmp(ip, &GBL_BRIDGE->ip)) - return EBRIDGE; - else - return -ENOTFOUND; - break; - - case AF_INET6: - LIST_FOREACH(i, &GBL_IFACE->ip6_list, next) { - if(!ip_addr_cmp(ip, &i->ip)) - return EFOUND; - } - return -ENOTFOUND; - } - - return -EINVALID; -} - - /* EOF */ // vim:ts=3:expandtab