NETWORK ATTACKS FRAMEWORK  1.0.0
A NETwork Attacks framework. Making network attacks impact evaluation easier!
NA_llf.c File Reference
#include "NA_defs.h"
#include "NA_debug.h"
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/uio.h>
#include <asm/types.h>
#include <ctype.h>
#include <time.h>
#include <sys/time.h>
#include <net/ethernet.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <linux/wireless.h>
#include <iwlib.h>
#include "NA_aodv_neighbor.h"
#include "NA_routing_table.h"

Go to the source code of this file.

Classes

struct  rtnl_handle
struct  wireless_iface

Typedefs

typedef struct wireless_iface wireless_iface

Functions

void llf_init ()
void llf_cleanup ()
int mac_to_ip (struct sockaddr *hwaddr, struct in_addr *ip_addr, char *ifname)

Variables

struct wireless_ifaceinterface_cache = NULL

Typedef Documentation


Function Documentation

void llf_cleanup ( )

Definition at line 79 of file NA_llf.c.

{
    close(rth.fd);
}
void llf_init ( )

Definition at line 65 of file NA_llf.c.

{

    if (llf_rtnl_open(&rth, RTMGRP_LINK) < 0) {
        DEBUG(LOG_ERR, 0, "Can't initialize rtnetlink socket");
        return;
    }
    if (attach_callback_func(rth.fd, llf_callback) < 0) {
        alog(LOG_ERR, 0, __FUNCTION__, "Could not attach callback");
        return;
    }
}
int mac_to_ip ( struct sockaddr *  hwaddr,
struct in_addr *  ip_addr,
char *  ifname 
)

Definition at line 221 of file NA_llf.c.

{
    FILE *fp;
    char ip[100];
    char hwa[100];
    char mask[100];
    char line[200];
    char dev[100];
    int type, flags, num;
    struct ether_addr eth;

    if ((fp = fopen("/proc/net/arp", "r")) == NULL) {
        perror("/proc/net/arp");
        return (-1);
    }
    /* Bypass header -- read until newline */
    if (fgets(line, sizeof(line), fp) != (char *) NULL) {
        strcpy(mask, "-");
        strcpy(dev, "-");
        /* Read the ARP cache entries. */
        for (; fgets(line, sizeof(line), fp);) {
            num = sscanf(line, "%s 0x%x 0x%x %100s %100s %100s\n",
                         ip, &type, &flags, hwa, mask, dev);
            if (num < 4)
                break;

            iw_ether_aton(hwa, &eth);

            if (memcmp(&eth, hwaddr->sa_data, ETH_ALEN) == 0) {

                inet_aton(ip, ip_addr);

                fclose(fp);
                return 0;
            }
        }
    }
    fclose(fp);
    return -1;
}

Variable Documentation

Definition at line 144 of file NA_llf.c.

 All Classes Files Functions Variables Typedefs Enumerator Defines