#ifndef NETDEV_NETDEV_H_
#define NETDEV_NETDEV_H_

#include <stdint.h>
#include <stddef.h>
#include "spinlock/spinlock.h"
#include "compiler/attr.h"
#include "pico_device.h"
#include "pico_ipv4.h"

enum {
  NETDEV_LOOPBACK,
};

#define NETDEV_MAGIC 0xB00B

typedef struct NetDev {
  struct pico_device *picodev;
  uint32_t _magic;
  struct NetDev *next;
  SpinLock spinlock;
  struct pico_ip4 ipaddr4, netmask4;
} NetDev;

typedef struct {
  NetDev *head;
  SpinLock spinlock;
} NetDevList;

extern NetDevList NETDEV_LIST;

void netdev_init(void);

NetDev *netdev_create(int32_t ndtype, const char *ipaddrstring, const char *netmaskstring);

#endif // NETDEV_NETDEV_H_
