Add socket_id and port_num strong types to W6300 socket API
This commit is contained in:
@@ -5,6 +5,9 @@ namespace w6300 {
|
||||
|
||||
constexpr int SOCK_COUNT = 8;
|
||||
|
||||
enum class socket_id : uint8_t {};
|
||||
enum class port_num : uint16_t {};
|
||||
|
||||
enum chip_ctl {
|
||||
CW_SYS_LOCK, CW_SYS_UNLOCK, CW_GET_SYSLOCK,
|
||||
CW_RESET_WIZCHIP, CW_INIT_WIZCHIP,
|
||||
@@ -222,12 +225,12 @@ constexpr uint8_t TCPSOCK_SIP = 1 << 0;
|
||||
constexpr uint8_t SOCK_IO_BLOCK = 0;
|
||||
constexpr uint8_t SOCK_IO_NONBLOCK = 1;
|
||||
|
||||
int8_t socket(uint8_t sn, uint8_t protocol, uint16_t port, uint8_t flag);
|
||||
int8_t close(uint8_t sn);
|
||||
int8_t listen(uint8_t sn);
|
||||
int8_t disconnect(uint8_t sn);
|
||||
int32_t send(uint8_t sn, uint8_t* buf, uint16_t len);
|
||||
int32_t recv(uint8_t sn, uint8_t* buf, uint16_t len);
|
||||
int8_t open_socket(socket_id sn, uint8_t protocol, port_num port, uint8_t flag);
|
||||
int8_t close(socket_id sn);
|
||||
int8_t listen(socket_id sn);
|
||||
int8_t disconnect(socket_id sn);
|
||||
int32_t send(socket_id sn, uint8_t* buf, uint16_t len);
|
||||
int32_t recv(socket_id sn, uint8_t* buf, uint16_t len);
|
||||
|
||||
enum sockint_kind {
|
||||
SIK_CONNECTED = (1 << 0),
|
||||
@@ -269,13 +272,13 @@ enum sockopt_type {
|
||||
SO_PACKINFO
|
||||
};
|
||||
|
||||
int8_t ctl_socket(uint8_t sn, sock_ctl type, void* arg);
|
||||
int8_t set_sockopt(uint8_t sn, sockopt_type type, void* arg);
|
||||
int8_t get_sockopt(uint8_t sn, sockopt_type type, void* arg);
|
||||
int16_t peek_socket_msg(uint8_t sn, uint8_t* submsg, uint16_t subsize);
|
||||
int8_t ctl_socket(socket_id sn, sock_ctl type, void* arg);
|
||||
int8_t set_sockopt(socket_id sn, sockopt_type type, void* arg);
|
||||
int8_t get_sockopt(socket_id sn, sockopt_type type, void* arg);
|
||||
int16_t peek_socket_msg(socket_id sn, uint8_t* submsg, uint16_t subsize);
|
||||
|
||||
int8_t connect(uint8_t sn, uint8_t* addr, uint16_t port, uint8_t addrlen);
|
||||
int32_t sendto(uint8_t sn, uint8_t* buf, uint16_t len, uint8_t* addr, uint16_t port, uint8_t addrlen);
|
||||
int32_t recvfrom(uint8_t sn, uint8_t* buf, uint16_t len, uint8_t* addr, uint16_t* port, uint8_t* addrlen);
|
||||
int8_t connect(socket_id sn, uint8_t* addr, port_num port, uint8_t addrlen);
|
||||
int32_t sendto(socket_id sn, uint8_t* buf, uint16_t len, uint8_t* addr, port_num port, uint8_t addrlen);
|
||||
int32_t recvfrom(socket_id sn, uint8_t* buf, uint16_t len, uint8_t* addr, port_num* port, uint8_t* addrlen);
|
||||
|
||||
} // namespace w6300
|
||||
|
||||
Reference in New Issue
Block a user