ETHERNET SMART BRIDGE
Alberto Carboni, Alessio CiarciĆ , Jacopo Grecuccio, Lorenzo Zaia
eth_smb_util.h
1 #ifndef ETH_SMB_UTIL_H
2 #define ETH_SMB_UTIL_H
3 
4 #include "stdio.h"
5 #include "inttypes.h"
6 
7 #define ADDITIONAL_SIZE 14
8 #define MAC_ADDR_SIZE 6
9 
10 static const uint8_t simple_arp_packet[] = {
11  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // Destination MAC
12  0x00, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, // Source MAC
13  0x08, 0x06, // ARP
14  0x00, 0x01, // Hardware type: Ethernet
15  0x08, 0x00, // Protocol type: IPv4
16  0x06, // Hardware size: 6
17  0x04, // Protocol size: 4
18  0x00, 0x01, // Opcode: request
19  0x00, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, // Sender MAC address
20  0x00, 0x00, 0x00, 0x00, // Sender IP address
21  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Target MAC address
22  //0xa9, 0xfe, 0xff, 0x7e // Target IP address (here is 169.254.255.126, change this according to your needs)
23  0x0a, 0x0a, 0x0a, 0x0a // Target IP address (here is 10.10.10.10)
24  //0xc0, 0xa8, 0x0a, 0x0a // Target IP address (here is 192.168.10.10)
25  // 42 bytes without padding
26 };
27 
28 size_t eth_composeSampleFrameTypeII(uint8_t *ethFrame, uint8_t *dstMAC, uint8_t *srcMAC, uint16_t etherType, uint8_t *payload, size_t payloadLen);
29 int isArpRequest(uint8_t *ethFrame, size_t length);
30 int isArpReply(uint8_t *ethFrame, size_t length);
31 int getSourceMAC(uint8_t *ethFrame);
32 
33 #endif // ETH_SMB_UTIL_H