summaryrefslogtreecommitdiff
path: root/code/fe310/eos/sock.h
blob: 3e0527bb0ca2d0326d4f09aed63ad217b92f4b7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <stdint.h>

#define EOS_SOCK_MTYPE_PKT          0
#define EOS_SOCK_MTYPE_OPEN_DGRAM   1
#define EOS_SOCK_MTYPE_CLOSE        127

#define EOS_SOCK_MAX_SOCK           2

#define EOS_SOCK_SIZE_UDP_HDR       8

#define EOS_IPv4_ADDR_SIZE          4

typedef struct EOSNetAddr {
    unsigned char host[EOS_IPv4_ADDR_SIZE];
    uint16_t port;
} EOSNetAddr;

typedef void (*eos_sock_fptr_t) (unsigned char *, uint16_t);

void eos_sock_init(void);
int eos_sock_open_udp(void);
void eos_sock_close(int sock);
int eos_sock_sendto(int sock, unsigned char *buffer, uint16_t size, unsigned char more, EOSNetAddr *addr);
void eos_sock_getfrom(unsigned char *buffer, EOSNetAddr *addr);
void eos_sock_set_handler(int sock, eos_sock_fptr_t handler, uint8_t flags);