stack.h
4.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
* Copyright (C) 2016 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @defgroup
* @ingroup
* @brief
* @{
*
* @file
* @brief
*
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
*/
#ifndef STACK_H
#define STACK_H
#include <stdbool.h>
#include <stdint.h>
#include "net/ipv6/addr.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes networking for tests
*/
void _net_init(void);
/**
* @brief Does what ever preparations are needed to check the packets sent
*/
void _prepare_send_checks(void);
/**
* @brief Injects a received UDPv4 packet into the stack
*
* @param[in] src The source address of the UDP packet
* @param[in] dst The destination address of the UDP packet
* @param[in] src_port The source port of the UDP packet
* @param[in] dst_port The destination port of the UDP packet
* @param[in] data The payload of the UDP packet
* @param[in] data_len The payload length of the UDP packet
* @param[in] netif The interface the packet came over
*
* @return true, if packet was successfully injected
* @return false, if an error occurred during injection
*/
bool _inject_4packet(uint32_t src, uint32_t dst, uint16_t src_port,
uint16_t dst_port, void *data, size_t data_len,
uint16_t netif);
/**
* @brief Injects a received UDPv6 packet into the stack
*
* @param[in] src The source address of the UDP packet
* @param[in] dst The destination address of the UDP packet
* @param[in] src_port The source port of the UDP packet
* @param[in] dst_port The destination port of the UDP packet
* @param[in] data The payload of the UDP packet
* @param[in] data_len The payload length of the UDP packet
* @param[in] netif The interface the packet came over
*
* @return true, if packet was successfully injected
* @return false, if an error occurred during injection
*/
bool _inject_6packet(const ipv6_addr_t *src, const ipv6_addr_t *dst,
uint16_t src_port, uint16_t dst_port,
void *data, size_t data_len, uint16_t netif);
/**
* @brief Checks networking state (e.g. packet buffer state)
*
* @return true, if networking component is still in valid state
* @return false, if networking component is in an invalid state
*/
bool _check_net(void);
/**
* @brief Checks if a UDPv4 packet was sent by the networking component
*
* @param[in] src Expected source address of the UDP packet
* @param[in] dst Expected destination address of the UDP packet
* @param[in] src_port Expected source port of the UDP packet
* @param[in] dst_port Expected destination port of the UDP packet
* @param[in] data Expected payload of the UDP packet
* @param[in] data_len Expected payload length of the UDP packet
* @param[in] netif Expected interface the packet is supposed to
* be send over
* @param[in] random_src_port Do not check source port, it might be random
*
* @return true, if all parameters match as expected
* @return false, if not.
*/
bool _check_4packet(uint32_t src, uint32_t dst, uint16_t src_port,
uint16_t dst_port, void *data, size_t data_len,
uint16_t netif, bool random_src_port);
/**
* @brief Checks if a UDPv6 packet was sent by the networking component
*
* @param[in] src Expected source address of the UDP packet
* @param[in] dst Expected destination address of the UDP packet
* @param[in] src_port Expected source port of the UDP packet
* @param[in] dst_port Expected destination port of the UDP packet
* @param[in] data Expected payload of the UDP packet
* @param[in] data_len Expected payload length of the UDP packet
* @param[in] netif Expected interface the packet is supposed to
* be send over
* @param[in] random_src_port Do not check source port, it might be random
*
* @return true, if all parameters match as expected
* @return false, if not.
*/
bool _check_6packet(const ipv6_addr_t *src, const ipv6_addr_t *dst,
uint16_t src_port, uint16_t dst_port,
void *data, size_t data_len, uint16_t netif,
bool random_src_port);
#ifdef __cplusplus
}
#endif
#endif /* STACK_H */
/** @} */