#ifndef _fec_decoder_h
#define _fec_decoder_h


#include "fec.h"
#include <stdio.h>
#include <stdint.h>

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <arpa/inet.h>
#include <linux/if_packet.h>
#include <linux/if_ether.h>
#include <linux/if_arp.h>

#include <linux/errqueue.h>
#include <linux/sockios.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <asm/types.h>
#include <fcntl.h>
#include <errno.h>


#include <ctype.h>
#define DEMO__
//#define DEMO__ // makes a binary for the demo

#include <asm/socket.h>

#define PACKET_SIZE 1518
#define IFACE_NAME_LEN 16
#define ETHER_MTU 1518
#define PACKED __attribute__((packed))

// FECed frame header size [bytes]
#define FEC_HEADE_SIZE 8

typedef uint32_t ipv4_addr_t;

typedef char Octet;

typedef uint8_t mac_addr_t[6];

const mac_addr_t FEC_ADDR = {0x76, 0x54, 0xba, 0x98 , 0xfe, 0xdc};

PACKED struct etherpacket {
	struct ethhdr ether;
	char data[ETHER_MTU];
};

typedef void *wr_socket_t;

typedef struct {
// Network interface name (eth0, ...)
    char if_name[IFACE_NAME_LEN];
// MAC address
    mac_addr_t mac;
// Destination MASC address, filled by recvfrom() function on interfaces bound to multiple addresses
    mac_addr_t mac_dest;
// IP address
    ipv4_addr_t ip;
// UDP port
    uint16_t port;
// RAW ethertype
    uint16_t ethertype;
// physical port to bind socket to
    uint16_t physical_port;
} wr_sockaddr_t;

struct my_socket {
	int fd;
	wr_sockaddr_t bind_addr;
	mac_addr_t local_mac;
	int if_index;
} ;

#endif