source
code documentation
dumpdev.c File Reference
Detailed Description
Dummy network adapter that will simulate a network adapter and dump all packets.
- Author:
- Christian Scheurer <http://www.christianscheurer.ch>
OUTLINE:
This simple dummy network interface can be used to debug ipsec and the lwIP stack by injecting a sequence of previously dumped packets. All INBOUND (from the dumpdev into higher protocol layers such as ipsec or TCP/IP) and OUTBOUND (data coming from the TCP/IP and ipsec stack, ready to be sent out i.g. in an Ethernet frame over the wire) packets are dumped using the printf() function. This allows a simple verification of the fed traffic.
IMPLEMENTATION:
A sequence of previously dumped packets can be used as input. An example of a ping sequence can be found in "dumpdev-pingdata.h".
NOTES:
It may be useful to modify the dumpdev code in order to allow automatic verification of the outbound traffic.
This document is part of embedded IPsec
Copyright (c) 2003 Niklaus Schild and Christian Scheurer, HTI Biel/Bienne
All rights reserved.
Definition in file dumpdev.c.
#include "lwip/mem.h"
#include "netif/etharp.h"
#include "netif/dumpdev.h"
#include "ipsec/debug.h"
#include "ipsec/util.h"
#include "testing/functional/ipsec-lwip-integration/dumpdev-httpgetdata.h"
Go to the source code of this file.
Define Documentation
#define DUMPDEV_IGNORE_RESPONSE
|
|
|
If defined, response of upper level stacks (ipsec/TCP/IP) will not be verified against the dumped response packets
- Todo:
- this feature is not implemented
Definition at line 75 of file dumpdev.c. |
#define DUMPDEV_NAME0 'd'
|
|
|
1st letter of device name "dp"
Definition at line 67 of file dumpdev.c. |
#define DUMPDEV_NAME1 'p'
|
|
|
1st letter of device name "dp"
Definition at line 68 of file dumpdev.c. |
#define DUMPDEV_USE_HTTPGET_DATA
|
|
|
If DUMPDEV_USE_HTTPGET_DATA is defined, a recored ping sequence between PC (192.168.1.2) and MCB167-NET board (192.168.1.3) will be used and its content will be fed the upper level protocols.
- Warning:
- this dataset has to be used in a mutual exclusive manner (only one dataset may be active at once)
Definition at line 89 of file dumpdev.c. |
Function Documentation
err_t dumpdev_init |
( |
struct netif * |
netif |
) |
|
|
|
Initialize the dump network device
This function must be called prior to any other operation with this device. It sets the device name, MAC address, initializes statistics and performs general configuration of the "dumpdev" device.
- Parameters:
-
netif | lwIP network interface data structure for this device. The structure must be initialized with IP, netmask and gateway address. |
- Returns:
- err_t return code
Definition at line 389 of file dumpdev.c. |
void dumpdev_input |
( |
struct netif * |
netif |
) |
|
|
|
This function is used to transfer a received packet in newly allocated pbuf-memory and pass it to upper protocol layers.
Note: this is the place where the dumped packets are injected and passed to higher protocol layers. It simulates the reception of a packet over the physical connection.
- Parameters:
-
netif | initialized lwIP network interface data structure of this device |
- Returns:
- void
- Todo:
- simulate reception of new packets HERE
replace this loop with memcpy()
ATTENTION: should be real IP, not -1
If there is no INBOUND packet in the input queue, inject a sample ESP packet to check the stacks behavior
Definition at line 215 of file dumpdev.c. |
err_t dumpdev_netlink_output |
( |
struct netif * |
netif, |
|
|
struct pbuf * |
p |
|
) |
|
|
|
This function simulates the low-level network interface
Note: This function does currently nothing but return ERR_OK
- Parameters:
-
netif | initialized lwIP network interface data structure of this device |
p | pbuf containing a complete Ethernet frame as payload |
- Returns:
- err_t status
Definition at line 368 of file dumpdev.c. |
err_t dumpdev_output |
( |
struct netif * |
netif, |
|
|
struct pbuf * |
p, |
|
|
struct ip_addr * |
ipaddr |
|
) |
|
|
|
This function is used to send a packet out of the network device.
Before dumping the frame (which is equivalent to sending data over the wire in a real Ethernet driver), the MAC address must be resolved using the ARP module. After the MAC address has been found, the packet will be "sent" (dumped).
Note: this is the place where an automated check of outbound data can be added.
- Parameters:
-
netif | initialized lwIP network interface data structure of this device |
p | pbuf containing a complete Ethernet frame as payload |
ipaddr | destination address |
- Returns:
- err_t status
Definition at line 341 of file dumpdev.c. |
void dumpdev_service |
( |
struct netif * |
netif |
) |
|
|
|
This function must be called at regular intervals (i.g. 20 times per second). It will allow the dump device driver to perform pending operations, such as emptying the transmit buffer or feeding newly received data into the TCP/IP stack.
- Parameters:
-
netif | initialized lwIP network interface data structure of this device |
- Returns:
- void
Definition at line 198 of file dumpdev.c. |
void ipsec_debug_dumppbufs |
( |
char * |
prefix, |
|
|
struct pbuf * |
data |
|
) |
|
|
|
This helper function prints the payload of a pbuf packet buffer - Parameters:
-
prefix | pointer to string (this text will be displayed at the beginning of each line) |
data | pointer to pbuf packet buffer data structure |
- Returns:
- void
Definition at line 150 of file dumpdev.c. |
Variable Documentation
|
Initial value:
{
0x00, 0xA0, 0x24, 0x15, 0x3E, 0x12, 0x00, 0xE0, 0x29, 0x25, 0x60, 0x6C, 0x08, 0x00, 0x45, 0x00,
0x00, 0x64, 0x79, 0x28, 0x00, 0x00, 0x40, 0x32, 0x7D, 0xC4, 0xC0, 0xA8, 0x01, 0x28, 0xC0, 0xA8,
0x01, 0x03, 0x00, 0x00, 0x10, 0x06, 0x00, 0x00, 0x00, 0x01, 0xA7, 0x36, 0xBA, 0x27, 0x8D, 0x39,
0xC5, 0x09, 0x49, 0x26, 0x53, 0x04, 0x07, 0xC9, 0x4D, 0xBB, 0x16, 0x59, 0x0E, 0x4E, 0x0B, 0x35,
0xBD, 0x56, 0x0A, 0x84, 0x26, 0x8E, 0x24, 0x8D, 0xB7, 0xAE, 0x8C, 0x59, 0x3F, 0x0C, 0x40, 0x22,
0x2B, 0x82, 0xA3, 0xC8, 0x3D, 0xDB, 0x0B, 0xA9, 0xD7, 0x81, 0x1A, 0x52, 0xC3, 0x26, 0xDB, 0x19,
0xCB, 0xFF, 0x67, 0xA3, 0xA0, 0x04, 0x94, 0x8E, 0x36, 0xE4, 0xBF, 0xDF, 0x61, 0xBA, 0xCB, 0xB5,
0xBA, 0xE9,
}
sample ESP packet
single ESP TCP SYN packet (FreeS/WAN configuration "manual6" used) -------
conn manual6 authby=manual left=192.168.1.3 leftid= right=192.168.1.40 rightid= esp=3des spi=0x1006 espenckey=0x01234567_01234567_01234567_01234567_01234567_0123456
Definition at line 116 of file dumpdev.c. |
|
Initial value:
{
0x00, 0xE0, 0x29, 0x25, 0x60, 0x6C, 0x00, 0xE0, 0x29, 0x15, 0x1C, 0x41, 0x08, 0x00, 0x45, 0x00,
0x00, 0x3C, 0x07, 0xF5, 0x00, 0x00, 0x80, 0x01, 0xAF, 0x78, 0xC0, 0xA8, 0x01, 0x02, 0xC0, 0xA8,
0x01, 0x01, 0x08, 0x00, 0x40, 0x5C, 0x05, 0x00, 0x08, 0x00, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,
0x77, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69,
}
sample ICMP Ping packet
Definition at line 106 of file dumpdev.c. |
|