#ifndef _LIB_BARRELFISH_UMP_NET_H
#define _LIB_BARRELFISH_UMP_NET_H

#include <aos/aos.h>

enum ump_net_op {
    // calls (out: call, in: return)
    UMP_NET_OP_UDP_SEND,
    UMP_NET_OP_UDP_LISTEN,
    UMP_NET_OP_UDP_LISTEN_STOP,

    // events (in only)
    UMP_NET_EV_UDP_RECV,
};

struct ump_net_op_udp_send {
    uint32_t dest_ip;
    uint16_t src_port;
    uint16_t dest_port;
};

struct ump_net_op_udp_listen {
    uint16_t dest_port; // If 0, allocate a port
};

struct ump_net_ret_udp_listen {
    uint16_t dest_port;
};

struct ump_net_op_udp_listen_stop {
    uint16_t dest_port;
};

struct ump_net_ev_udp_recv {
    uint32_t src_ip;
    uint32_t dest_ip;
    uint16_t src_port;
    uint16_t dest_port;
};

struct ump_net_out_header {
    enum ump_net_op op;
    union ump_net_out_d {
        struct ump_net_op_udp_send udp_send;
        struct ump_net_op_udp_listen udp_listen;
        struct ump_net_op_udp_listen_stop udp_listen_stop;
    } d;
};

struct ump_net_in_header {
    enum ump_net_op op;
    errval_t ret_err;
    union ump_net_in_d {
        struct ump_net_ret_udp_listen udp_listen;
        struct ump_net_ev_udp_recv udp_recv;
    } d;
};

#endif // _LIB_BARRELFISH_UMP_NET_H
