#ifndef ETHERNET_H_
#define ETHERNET_H_
#include <linux/if_ether.h>

struct eth_hdr 
{
    unsigned char dst_mac[6];
    unsigned char src_mac[6];
    unsigned short ethertype;
    unsigned char payload[];
};

struct eth_hdr* init_eth_hdr(char* buf);
void print_eth_hdr(struct eth_hdr *ehdr);

#endif

#ifndef ETHERNET_H_
#define ETHERNET_H_
#include <linux/if_ether.h>

struct eth_hdr 
{
    unsigned char dst_mac[6];
    unsigned char src_mac[6];
    unsigned short ethertype;
    unsigned char* payload;
};

struct eth_hdr* init_eth_hdr(char* buf);
void print_eth_hdr(struct eth_hdr *ehdr);

#endif

--- 
+++ 
@@ -7,7 +7,7 @@
     unsigned char dst_mac[6];
     unsigned char src_mac[6];
     unsigned short ethertype;
-    unsigned char* payload;
+    unsigned char payload[];
 };
 
 struct eth_hdr* init_eth_hdr(char* buf);
Fix wrong eth payload data type

Declaring a pointer here and type-casting the buffer to
a eth struct just overwrites the pointer with the payloads contents!

Oops!

Declaring a flexible array member is better.
https://en.wikipedia.org/wiki/Flexible_array_member
