-
Notifications
You must be signed in to change notification settings - Fork 0
/
push.h
84 lines (73 loc) · 1.51 KB
/
push.h
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
#ifndef _PUSH_H
#define _PUSH_H
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <linux/if.h>
#include <linux/if_ether.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/ip6.h>
#include <netinet/udp.h>
#include <netinet/tcp.h>
/* Enumerations */
typedef enum check_item_e
{
item_dst_MAC,
item_src_MAC,
item_frame_length,
item_tagged,
item_protocol,
} check_item_t;
typedef enum protocols_s
{
proto_raw,
proto_ipv4,
proto_ipv6,
} protocols_t;
/* Structures */
typedef struct eth_hdr_s
{
uint8_t dst_MAC[ETH_ALEN];
uint8_t src_MAC[ETH_ALEN];
uint16_t type_length;
} eth_hdr_t;
typedef struct vlan_tag_s
{
uint8_t ether_type[2];
uint16_t cos:3;
uint16_t cfa:1;
uint16_t vlan_id:12;
} vlan_tag_t;
typedef struct pkt_gen_configuration_s
{
bool check_dst_MAC;
bool check_src_MAC;
bool check_frame_length;
bool check_tagged;
bool check_protocol;
eth_hdr_t ethernet_header;
vlan_tag_t vlan_tag;
protocols_t protocol;
struct iphdr ipv4_header;
struct ip6_hdr ipv6_header;
struct udphdr udp_header;
int pkt_len;
int data_len;
uint8_t data[ETH_FRAME_LEN];
} __attribute__ ((__packed__)) pkt_gen_configuration_t;
/* Constants */
#define SUCCESS 0
#define FAILURE 1
#define SIGNATURE "alphonsearackal."
#define MAX_FILE_FRAMES 100
#define MIN_PAYLOAD_LEN 16
#define O_NO_ARG 0
#define O_REQ_ARG 1
#define O_OPT_ARG 2
#endif /* _PUSH_H */