1
0
mirror of https://code.semirocket.science/wrapsix synced 2024-11-10 16:21:00 +02:00

A bit of formal code cleaning

Mostly lines breaking, then also comments
This commit is contained in:
Michal Zima 2013-02-13 20:32:42 +01:00
parent 746712c6de
commit 378d3200c2
12 changed files with 146 additions and 92 deletions

View File

@ -1,6 +1,6 @@
/*
* WrapSix
* Copyright (C) 2008-2012 Michal Zima <xhire@mujmalysvet.cz>
* Copyright (C) 2008-2013 Michal Zima <xhire@mujmalysvet.cz>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -30,16 +30,21 @@
/* ARP structure */
struct s_arp {
unsigned short hw; /* 16 b; hardware type [0x0001] */
unsigned short proto; /* 16 b; protocol type [0x0800] */
unsigned char hw_len; /* 8 b; length of hardware address in bytes [0x06] */
unsigned char proto_len; /* 8 b; length of protocol address in bytes [0x04] */
unsigned short opcode; /* 16 b; operation code: [0x0001] or [0x0002] */
struct s_mac_addr mac_src; /* 48 b; sender hardware address */
struct s_ipv4_addr ip_src; /* 32 b; sender protocol address */
struct s_mac_addr mac_dest; /* 48 b; target hardware address */
struct s_ipv4_addr ip_dest; /* 32 b; target protocol address */
}__attribute__((__packed__));
unsigned short hw; /* 16 b; hardware type
[0x0001] */
unsigned short proto; /* 16 b; protocol type
[0x0800] */
unsigned char hw_len; /* 8 b; length of hardware
addr in bytes [0x06] */
unsigned char proto_len; /* 8 b; length of protocol
addr in bytes [0x04] */
unsigned short opcode; /* 16 b; operation code:
[0x0001] or [0x0002] */
struct s_mac_addr mac_src; /* 48 b; sender hardware addr */
struct s_ipv4_addr ip_src; /* 32 b; sender protocol addr */
struct s_mac_addr mac_dest; /* 48 b; target hardware addr */
struct s_ipv4_addr ip_dest; /* 32 b; target protocol addr */
} __attribute__ ((__packed__));
int arp(struct s_ethernet *ethq, char *payload);

View File

@ -1,6 +1,6 @@
/*
* WrapSix
* Copyright (C) 2008-2012 Michal Zima <xhire@mujmalysvet.cz>
* Copyright (C) 2008-2013 Michal Zima <xhire@mujmalysvet.cz>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -26,7 +26,7 @@
#include "log.h"
/**
* General checksum computation function
* General checksum computation function.
*
* @param data Pointer to data of which to compute the checksum
* @param length Length of the data (in bytes)
@ -108,7 +108,7 @@ unsigned short checksum_update(unsigned short old_sum,
}
/**
* IPv4 checksum computation function
* IPv4 checksum computation function.
*
* @param ip_src Source IPv4 address
* @param ip_dest Destination IPv4 address
@ -150,7 +150,7 @@ unsigned short checksum_ipv4(struct s_ipv4_addr ip_src,
}
/**
* IPv6 checksum computation function
* IPv6 checksum computation function.
*
* @param ip_src Source IPv6 address
* @param ip_dest Destionation IPv6 address
@ -192,7 +192,7 @@ unsigned short checksum_ipv6(struct s_ipv6_addr ip_src,
}
/**
* IPv4 checksum update computation function
* IPv4 checksum update computation function.
*
* @param old_sum Old checksum
* @param ip6_src Original source IPv6 address
@ -231,7 +231,7 @@ unsigned short checksum_ipv4_update(unsigned short old_sum,
}
/**
* IPv6 checksum update computation function
* IPv6 checksum update computation function.
*
* @param old_sum Old checksum
* @param ip4_src Original source IPv4 address

View File

@ -30,7 +30,8 @@ struct s_mac_addr {
/* Ethernet header structure */
struct s_ethernet {
struct s_mac_addr dest; /* 48 b; destination host (MAC) address */
struct s_mac_addr dest; /* 48 b; destination host (MAC)
address */
struct s_mac_addr src; /* 48 b; source host (MAC) address */
unsigned short type; /* 16 b; IP/ARP/RARP/... */
} __attribute__ ((__packed__));

View File

@ -1,6 +1,6 @@
/*
* WrapSix
* Copyright (C) 2008-2012 Michal Zima <xhire@mujmalysvet.cz>
* Copyright (C) 2008-2013 Michal Zima <xhire@mujmalysvet.cz>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -60,7 +60,8 @@ struct s_ipv4_pseudo {
struct s_ipv4_pseudo_delta {
struct s_ipv4_addr ip_src; /* 32 b; source address */
struct s_ipv4_addr ip_dest; /* 32 b; destination address */
unsigned short port; /* 16 b; transport layer address */
unsigned short port; /* 16 b; transport layer
address */
} __attribute__ ((__packed__));
int ipv4(struct s_ethernet *eth, char *packet);

View File

@ -1,6 +1,6 @@
/*
* WrapSix
* Copyright (C) 2008-2012 Michal Zima <xhire@mujmalysvet.cz>
* Copyright (C) 2008-2013 Michal Zima <xhire@mujmalysvet.cz>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -64,7 +64,8 @@ struct s_ipv6_pseudo {
struct s_ipv6_pseudo_delta {
struct s_ipv6_addr ip_src; /* 128 b; source address */
struct s_ipv6_addr ip_dest; /* 128 b; destination address */
unsigned short port; /* 16 b; transport layer address */
unsigned short port; /* 16 b; transport layer
address */
} __attribute__ ((__packed__));
int ipv6(struct s_ethernet *eth, char *packet);

View File

@ -1,6 +1,6 @@
/*
* WrapSix
* Copyright (C) 2008-2012 Michal Zima <xhire@mujmalysvet.cz>
* Copyright (C) 2008-2013 Michal Zima <xhire@mujmalysvet.cz>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -230,6 +230,7 @@ struct s_nat *nat_in(radixtree_t *nat_proto4, struct s_ipv4_addr ipv4_src,
* Retrieve or create data structure via fragment identification.
*
* @param nat_proto4 Radix tree of fragments
* @param nat_timeout Linked list in which to watch for timeout
* @param ipv4_src Source IPv4 address
* @param id Fragment identification
*

View File

@ -1,6 +1,6 @@
/*
* WrapSix
* Copyright (C) 2008-2012 Michal Zima <xhire@mujmalysvet.cz>
* Copyright (C) 2008-2013 Michal Zima <xhire@mujmalysvet.cz>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -25,7 +25,7 @@
/**
* Creates root of radix tree.
*
* @return Root of new radix tree
* @return Root of new radix tree
*/
radixtree_t *radixtree_create(void)
{
@ -44,8 +44,8 @@ radixtree_t *radixtree_create(void)
/**
* Destroys a radix tree.
*
* @param root Root of the tree to destroy
* @param depth Depth of the tree
* @param root Root of the tree to destroy
* @param depth Depth of the tree
*/
void radixtree_destroy(radixtree_t *root, unsigned char depth)
{
@ -65,14 +65,16 @@ void radixtree_destroy(radixtree_t *root, unsigned char depth)
/**
* Inserts new data entry into the tree.
*
* @param root Root of the radix tree
* @param chunker Function to use to get chunks for indexing internal array
* @param search_data Key used to search in the tree
* @param size Length of the key
* @param data Data to store in the tree
* @param root Root of the radix tree
* @param chunker Function to use to get chunks for indexing
* internal array
* @param search_data Key used to search in the tree
* @param size Length of the key
* @param data Data to store in the tree
*/
void radixtree_insert(radixtree_t *root,
unsigned char *(chunker)(void *data, unsigned char size, unsigned char *count),
unsigned char *(chunker)(void *data, unsigned char size,
unsigned char *count),
void *search_data, unsigned char size, void *data)
{
radixtree_t *tmp;
@ -109,13 +111,15 @@ void radixtree_insert(radixtree_t *root,
/**
* Deletes an entry from the tree.
*
* @param root Root of the radix tree
* @param chunker Function to use to get chunks for indexing internal array
* @param data Key used to search in the tree
* @param size Length of the key
* @param root Root of the radix tree
* @param chunker Function to use to get chunks for indexing
* internal array
* @param data Key used to search in the tree
* @param size Length of the key
*/
void radixtree_delete(radixtree_t *root,
unsigned char *(chunker)(void *data, unsigned char size, unsigned char *count),
unsigned char *(chunker)(void *data, unsigned char size,
unsigned char *count),
void *data, unsigned char size)
{
radixtree_t *tmp,
@ -126,7 +130,8 @@ void radixtree_delete(radixtree_t *root,
chunks = chunker(data, size, &chunk_count);
for (i = 0, tmp = root; i < chunk_count && tmp != NULL; tmp = tmp->array[chunks[i++]]) {
for (i = 0, tmp = root; i < chunk_count && tmp != NULL;
tmp = tmp->array[chunks[i++]]) {
flags = tmp->count == 1 ? flags | (0x1 << i) : 0;
if (i + 1 == chunk_count) {
@ -160,13 +165,15 @@ void radixtree_delete(radixtree_t *root,
/**
* Lookups an entry in the tree.
*
* @param root Root of the radix tree
* @param chunker Function to use to get chunks for indexing internal array
* @param data Key used to search in the tree
* @param size Length of the key
* @param root Root of the radix tree
* @param chunker Function to use to get chunks for indexing
* internal array
* @param data Key used to search in the tree
* @param size Length of the key
*/
void *radixtree_lookup(radixtree_t *root,
unsigned char *(chunker)(void *data, unsigned char size, unsigned char *count),
unsigned char *(chunker)(void *data, unsigned char size,
unsigned char *count),
void *data, unsigned char size)
{
radixtree_t *tmp;
@ -210,7 +217,8 @@ void *radixtree_lookup(radixtree_t *root,
*
* @return Array of chunks
*/
unsigned char *radixtree_chunker(void *data, unsigned char size, unsigned char *count)
unsigned char *radixtree_chunker(void *data, unsigned char size,
unsigned char *count)
{
short i;
unsigned char counter;
@ -220,7 +228,8 @@ unsigned char *radixtree_chunker(void *data, unsigned char size, unsigned char *
counter = size * 8 / 6;
memcpy(count, &counter, sizeof(unsigned char));
if ((chunks = (unsigned char *) malloc(counter * sizeof(unsigned char))) == NULL) {
if ((chunks = (unsigned char *) malloc(counter * sizeof(unsigned char)))
== NULL) {
log_error("Lack of free memory");
return NULL;
}
@ -238,9 +247,11 @@ unsigned char *radixtree_chunker(void *data, unsigned char size, unsigned char *
/* processes 3 bytes at a time */
for (i = 0, counter = 0; counter < *count; i++) {
chunks[counter++] = cdata[i] & 0x3f;
chunks[counter++] = ((cdata[i] & 0xc0) >> 6) | ((cdata[i + 1] & 0x0f) << 2);
chunks[counter++] = ((cdata[i] & 0xc0) >> 6) |
((cdata[i + 1] & 0x0f) << 2);
i++;
chunks[counter++] = ((cdata[i] & 0xf0) >> 4) | ((cdata[i + 1] & 0x03) << 4);
chunks[counter++] = ((cdata[i] & 0xf0) >> 4) |
((cdata[i + 1] & 0x03) << 4);
i++;
chunks[counter++] = ((cdata[i] & 0xfc) >> 2);
}

View File

@ -1,6 +1,6 @@
/*
* WrapSix
* Copyright (C) 2008-2012 Michal Zima <xhire@mujmalysvet.cz>
* Copyright (C) 2008-2013 Michal Zima <xhire@mujmalysvet.cz>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -30,14 +30,18 @@ typedef struct radixtree {
radixtree_t *radixtree_create(void);
void radixtree_destroy(radixtree_t *root, unsigned char depth);
void radixtree_insert(radixtree_t *root,
unsigned char *(chunker)(void *data, unsigned char size, unsigned char *count),
unsigned char *(chunker)(void *data, unsigned char size,
unsigned char *count),
void *search_data, unsigned char size, void *data);
void radixtree_delete(radixtree_t *root,
unsigned char *(chunker)(void *data, unsigned char size, unsigned char *count),
unsigned char *(chunker)(void *data, unsigned char size,
unsigned char *count),
void *data, unsigned char size);
void *radixtree_lookup(radixtree_t *root,
unsigned char *(chunker)(void *data, unsigned char size, unsigned char *count),
void *data, unsigned char size);
unsigned char *radixtree_chunker(void *data, unsigned char size, unsigned char *count);
unsigned char *(chunker)(void *data, unsigned char size,
unsigned char *count),
void *data, unsigned char size);
unsigned char *radixtree_chunker(void *data, unsigned char size,
unsigned char *count);
#endif /* RADIXTREE_H */

View File

@ -1,6 +1,6 @@
/*
* WrapSix
* Copyright (C) 2008-2012 Michal Zima <xhire@mujmalysvet.cz>
* Copyright (C) 2008-2013 Michal Zima <xhire@mujmalysvet.cz>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -106,31 +106,37 @@ int tcp_ipv4(struct s_ethernet *eth4, struct s_ipv4 *ip4, char *payload,
break;
} else if (tcp->flags & TCP_FLAG_RST) {
connection->state = TCP_STATE_TRANS;
linkedlist_move2end(timeout_tcp_trans, connection->llnode);
linkedlist_move2end(timeout_tcp_trans,
connection->llnode);
break;
} else {
linkedlist_move2end(timeout_tcp_est, connection->llnode);
linkedlist_move2end(timeout_tcp_est,
connection->llnode);
break;
}
case TCP_STATE_INIT:
if (tcp->flags & TCP_FLAG_SYN) {
connection->state = TCP_STATE_EST;
linkedlist_move2end(timeout_tcp_est, connection->llnode);
linkedlist_move2end(timeout_tcp_est,
connection->llnode);
}
break;
case TCP_STATE_FIN4:
linkedlist_move2end(timeout_tcp_est, connection->llnode);
linkedlist_move2end(timeout_tcp_est,
connection->llnode);
break;
case TCP_STATE_FIN6:
if (tcp->flags & TCP_FLAG_FIN) {
connection->state = TCP_STATE_FIN64;
linkedlist_move2end(timeout_tcp_trans, connection->llnode);
linkedlist_move2end(timeout_tcp_trans,
connection->llnode);
break;
} else {
linkedlist_move2end(timeout_tcp_est, connection->llnode);
linkedlist_move2end(timeout_tcp_est,
connection->llnode);
break;
}
@ -142,7 +148,8 @@ int tcp_ipv4(struct s_ethernet *eth4, struct s_ipv4 *ip4, char *payload,
break;
} else {
connection->state = TCP_STATE_EST;
linkedlist_move2end(timeout_tcp_est, connection->llnode);
linkedlist_move2end(timeout_tcp_est,
connection->llnode);
break;
}
}
@ -377,7 +384,8 @@ int tcp_ipv4(struct s_ethernet *eth4, struct s_ipv4 *ip4, char *payload,
/* fill in missing IPv6 fragment header fields */
frag->offset_flag = htons((htons(ip4->flags_offset) <<
3) | IPV6_FLAG_MORE_FRAGMENTS);
3) |
IPV6_FLAG_MORE_FRAGMENTS);
/* copy the payload data */
memcpy((unsigned char *) frag +
@ -417,7 +425,8 @@ int tcp_ipv4(struct s_ethernet *eth4, struct s_ipv4 *ip4, char *payload,
sizeof(struct s_ipv6_fragment));
/* fill in missing IPv6 fragment header fields */
frag->offset_flag = htons(htons(ip4->flags_offset) << 3);
frag->offset_flag = htons(htons(ip4->flags_offset) <<
3);
if (ip4->flags_offset &
htons(IPV4_FLAG_MORE_FRAGMENTS)) {
frag->offset_flag |=
@ -497,20 +506,26 @@ int tcp_ipv6(struct s_ethernet *eth6, struct s_ipv6 *ip6, char *payload)
break;
} else if (tcp->flags & TCP_FLAG_RST) {
connection->state = TCP_STATE_TRANS;
linkedlist_move2end(timeout_tcp_trans, connection->llnode);
linkedlist_move2end(timeout_tcp_trans,
connection->llnode);
break;
} else {
linkedlist_move2end(timeout_tcp_est, connection->llnode);
linkedlist_move2end(timeout_tcp_est,
connection->llnode);
break;
}
case TCP_STATE_INIT:
if (tcp->flags & TCP_FLAG_SYN) {
if (connection->llnode == NULL) {
connection->llnode = linkedlist_append(timeout_tcp_trans, connection);
connection->llnode =
linkedlist_append(
timeout_tcp_trans,
connection);
break;
} else {
linkedlist_move2end(timeout_tcp_trans, connection->llnode);
linkedlist_move2end(timeout_tcp_trans,
connection->llnode);
break;
}
}
@ -519,15 +534,18 @@ int tcp_ipv6(struct s_ethernet *eth6, struct s_ipv6 *ip6, char *payload)
case TCP_STATE_FIN4:
if (tcp->flags & TCP_FLAG_FIN) {
connection->state = TCP_STATE_FIN64;
linkedlist_move2end(timeout_tcp_trans, connection->llnode);
linkedlist_move2end(timeout_tcp_trans,
connection->llnode);
break;
} else {
linkedlist_move2end(timeout_tcp_est, connection->llnode);
linkedlist_move2end(timeout_tcp_est,
connection->llnode);
break;
}
case TCP_STATE_FIN6:
linkedlist_move2end(timeout_tcp_est, connection->llnode);
linkedlist_move2end(timeout_tcp_est,
connection->llnode);
break;
case TCP_STATE_FIN64:
@ -538,7 +556,8 @@ int tcp_ipv6(struct s_ethernet *eth6, struct s_ipv6 *ip6, char *payload)
break;
} else {
connection->state = TCP_STATE_EST;
linkedlist_move2end(timeout_tcp_est, connection->llnode);
linkedlist_move2end(timeout_tcp_est,
connection->llnode);
break;
}
}

View File

@ -1,6 +1,6 @@
/*
* WrapSix
* Copyright (C) 2008-2012 Michal Zima <xhire@mujmalysvet.cz>
* Copyright (C) 2008-2013 Michal Zima <xhire@mujmalysvet.cz>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -24,6 +24,7 @@
int transmission_init(void);
int transmission_quit(void);
int transmit_raw(unsigned char *data, unsigned int length);
int transmit_ipv4(struct s_ipv4_addr *ip, unsigned char *data, unsigned int length);
int transmit_ipv4(struct s_ipv4_addr *ip, unsigned char *data,
unsigned int length);
#endif /* TRANSMITTER_H */

View File

@ -1,6 +1,6 @@
/*
* WrapSix
* Copyright (C) 2008-2012 Michal Zima <xhire@mujmalysvet.cz>
* Copyright (C) 2008-2013 Michal Zima <xhire@mujmalysvet.cz>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -25,8 +25,8 @@
#include "ethernet.h"
#include "ipv4.h"
#include "ipv6.h"
#include "log.h"
#include "linkedlist.h"
#include "log.h"
#include "nat.h"
#include "transmitter.h"
#include "udp.h"
@ -75,7 +75,8 @@ int udp_ipv4(struct s_ethernet *eth4, struct s_ipv4 *ip4, char *payload,
}
/* find connection in NAT */
connection = nat_in(nat4_udp, ip4->ip_src, udp->port_src, udp->port_dest);
connection = nat_in(nat4_udp, ip4->ip_src,
udp->port_src, udp->port_dest);
if (connection == NULL) {
log_debug("Incoming connection wasn't found in NAT");
@ -121,8 +122,9 @@ int udp_ipv4(struct s_ethernet *eth4, struct s_ipv4 *ip4, char *payload,
connection->ipv6_port_src);
} else {
/* if original checksum was 0x0000, we need to compute it */
udp->checksum = checksum_ipv6(ip6->ip_src, ip6->ip_dest, payload_size,
IPPROTO_UDP, (unsigned char *) udp);
udp->checksum = checksum_ipv6(ip6->ip_src, ip6->ip_dest,
payload_size, IPPROTO_UDP,
(unsigned char *) udp);
}
/* copy the payload data (with new checksum) */

View File

@ -1,6 +1,6 @@
/*
* WrapSix
* Copyright (C) 2008-2012 Michal Zima <xhire@mujmalysvet.cz>
* Copyright (C) 2008-2013 Michal Zima <xhire@mujmalysvet.cz>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -18,10 +18,10 @@
#include <arpa/inet.h> /* inet_pton */
#include <linux/if_ether.h> /* ETH_P_ALL */
#include <net/if.h> /* struct ifreq */
#include <netpacket/packet.h> /* struct packet_mreq, struct sockaddr_ll */
#include <netinet/in.h> /* htons */
#include <net/ethernet.h> /* ETHERTYPE_* */
#include <net/if.h> /* struct ifreq */
#include <netinet/in.h> /* htons */
#include <netpacket/packet.h> /* struct packet_mreq, struct sockaddr_ll */
#include <stdlib.h> /* srand */
#include <string.h> /* strncpy */
#include <sys/ioctl.h> /* ioctl, SIOCGIFINDEX */
@ -66,7 +66,8 @@ int main(int argc, char **argv)
log_info(PACKAGE_STRING " is starting");
/* initialize the socket for sniffing */
if ((sniff_sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) == -1) {
if ((sniff_sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) ==
-1) {
log_error("Unable to create listening socket");
return 1;
}
@ -80,7 +81,8 @@ int main(int argc, char **argv)
/* get interface's HW address (i.e. MAC) */
if (ioctl(sniff_sock, SIOCGIFHWADDR, &interface) == 0) {
memcpy(&mac, &interface.ifr_hwaddr.sa_data, sizeof(struct s_mac_addr));
memcpy(&mac, &interface.ifr_hwaddr.sa_data,
sizeof(struct s_mac_addr));
/* reinitialize the interface */
if (ioctl(sniff_sock, SIOCGIFINDEX, &interface) == -1) {
@ -96,8 +98,10 @@ int main(int argc, char **argv)
memset(&pmr, 0x0, sizeof(pmr));
pmr.mr_ifindex = interface.ifr_ifindex;
pmr.mr_type = PACKET_MR_PROMISC;
if (setsockopt(sniff_sock, SOL_PACKET, PACKET_ADD_MEMBERSHIP, (char *) &pmr, sizeof(pmr)) == -1) {
log_error("Unable to set the promiscuous mode on the interface");
if (setsockopt(sniff_sock, SOL_PACKET, PACKET_ADD_MEMBERSHIP,
(char *) &pmr, sizeof(pmr)) == -1) {
log_error("Unable to set the promiscuous mode on the "
"interface");
return 1;
}
@ -128,7 +132,8 @@ int main(int argc, char **argv)
/* sniff! :c) */
for (i = 1;; i++) {
if ((length = recv(sniff_sock, buffer, PACKET_BUFFER, 0)) == -1) {
if ((length = recv(sniff_sock, buffer, PACKET_BUFFER, 0)) ==
-1) {
log_error("Unable to retrieve data from socket");
return 1;
}
@ -154,9 +159,11 @@ int main(int argc, char **argv)
nat_quit();
/* unset the promiscuous mode */
if (setsockopt(sniff_sock, SOL_PACKET, PACKET_DROP_MEMBERSHIP, (char *) &pmr, sizeof(pmr)) == -1) {
log_error("Unable to unset the promiscuous mode on the interface");
/* do not call `return` here as we want to close the socket too */
if (setsockopt(sniff_sock, SOL_PACKET, PACKET_DROP_MEMBERSHIP,
(char *) &pmr, sizeof(pmr)) == -1) {
log_error("Unable to unset the promiscuous mode on the "
"interface");
/* do not call return here as we want to close the socket too */
}
/* close the socket */
@ -168,7 +175,8 @@ int main(int argc, char **argv)
int process(char *packet)
{
struct s_ethernet *eth; /* the ethernet header */
char *payload; /* the IP header + packet payload */
char *payload; /* the IP header + packet
payload */
/* parse ethernet header */
eth = (struct s_ethernet *) (packet);