#ifndef _ETHERNETIF_H_
#define _ETHERNETIF_H_

#include "lwip/netif.h"
#include "lwip/err.h"
#include "lwip/ip4_addr.h"

extern struct netif ch390_netif;

/**
 * Helper struct to hold private data used to operate your ethernet interface.
 * Keeping the ethernet address of the MAC in this struct is not necessary
 * as it is already kept in the struct netif.
 * But this is only an example, anyway...
 */
struct ethernetif {
//    struct eth_addr *ethaddr;
    /* Add whatever per-interface state that is needed here. */
    uint16_t rx_len;
    uint8_t rx_status;
};

err_t ethernetif_init(struct netif *netif);
void ethernetif_input(struct netif *netif);
void lwip_netif_init(const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw);
void ethernetif_diag_ch390_init(void);
void ethernetif_diag_poll_status(void);
void ethernetif_check_link(void);
void ethernetif_apply_runtime_netif_config(const ip4_addr_t *ipaddr,
                                           const ip4_addr_t *netmask,
                                           const ip4_addr_t *gw,
                                           const uint8_t *mac);
void ethernetif_force_full_recovery(const ip4_addr_t *ipaddr,
                                    const ip4_addr_t *netmask,
                                    const ip4_addr_t *gw,
                                    const uint8_t *mac);
void ethernetif_force_link_down(void);
uint16_t ethernetif_ch390_get_vendor_id(void);
uint16_t ethernetif_ch390_get_product_id(void);
uint8_t ethernetif_ch390_get_revision(void);
uint8_t ethernetif_ch390_health_ok(void);
uint8_t ethernetif_get_effective_mac(uint8_t *mac);
uint8_t ethernetif_link_is_up(void);
void ethernetif_poll(void);

void print_netif(struct netif *netif);

#endif /* _ETHERNETIF_H_ */
