diff options
Diffstat (limited to 'code/ecp/posix')
-rw-r--r-- | code/ecp/posix/time.c | 12 | ||||
-rw-r--r-- | code/ecp/posix/transport.c | 31 |
2 files changed, 17 insertions, 26 deletions
diff --git a/code/ecp/posix/time.c b/code/ecp/posix/time.c index c7a238a..45d827e 100644 --- a/code/ecp/posix/time.c +++ b/code/ecp/posix/time.c @@ -2,8 +2,9 @@ #include <sys/time.h> #include <core.h> +#include <tm.h> -static ecp_cts_t t_abstime_ms(ecp_cts_t msec) { +ecp_cts_t ecp_tm_abstime_ms(ecp_cts_t msec) { struct timeval tv; ecp_cts_t ms_now; @@ -12,13 +13,8 @@ static ecp_cts_t t_abstime_ms(ecp_cts_t msec) { return ms_now + msec; } -static void t_sleep_ms(ecp_cts_t msec) { +void ecp_tm_sleep_ms(ecp_cts_t msec) { usleep(msec*1000); } -int ecp_time_init(ECPTimeIface *t) { - t->init = 1; - t->abstime_ms = t_abstime_ms; - t->sleep_ms = t_sleep_ms; - return 0; -} +void ecp_tm_timer_set(ecp_cts_t next) {}
\ No newline at end of file diff --git a/code/ecp/posix/transport.c b/code/ecp/posix/transport.c index 5415db6..d6426d5 100644 --- a/code/ecp/posix/transport.c +++ b/code/ecp/posix/transport.c @@ -5,16 +5,17 @@ #include <poll.h> #include <core.h> +#include <tr.h> #define ADDR_S_MAX 32 -static int t_addr_eq(ECPNetAddr *addr1, ECPNetAddr *addr2) { +int ecp_tr_addr_eq(ECPNetAddr *addr1, ECPNetAddr *addr2) { if (addr1->port != addr2->port) return 0; if (memcmp(addr1->host, addr2->host, sizeof(addr1->host)) != 0) return 0; return 1; } -static int t_addr_set(ECPNetAddr *addr, void *addr_s) { +int ecp_tr_addr_set(ECPNetAddr *addr, void *addr_s) { int rv; char addr_c[ADDR_S_MAX]; char *colon = NULL; @@ -37,14 +38,14 @@ static int t_addr_set(ECPNetAddr *addr, void *addr_s) { return 0; } -static int t_open(int *sock, void *addr_s) { +int ecp_tr_open(int *sock, void *addr_s) { struct sockaddr_in _myaddr; memset((char *)&_myaddr, 0, sizeof(_myaddr)); _myaddr.sin_family = AF_INET; if (addr_s) { ECPNetAddr addr; - int rv = t_addr_set(&addr, addr_s); + int rv = ecp_tr_addr_set(&addr, addr_s); if (rv) return rv; memcpy((void *)&_myaddr.sin_addr, addr.host, sizeof(addr.host)); @@ -62,14 +63,14 @@ static int t_open(int *sock, void *addr_s) { close(*sock); return rv; } - return 0; + return ECP_OK; } -static void t_close(int *sock) { +void ecp_tr_close(int *sock) { close(*sock); } -static ssize_t t_send(int *sock, ECPBuffer *packet, size_t msg_size, ECPNetAddr *addr, unsigned char flags) { +ssize_t ecp_tr_send(int *sock, ECPBuffer *packet, size_t msg_size, ECPNetAddr *addr, unsigned char flags) { struct sockaddr_in servaddr; memset((void *)&servaddr, 0, sizeof(servaddr)); @@ -79,7 +80,7 @@ static ssize_t t_send(int *sock, ECPBuffer *packet, size_t msg_size, ECPNetAddr return sendto(*sock, packet->buffer, msg_size, 0, (struct sockaddr *)&servaddr, sizeof(servaddr)); } -static ssize_t t_recv(int *sock, ECPBuffer *packet, ECPNetAddr *addr, int timeout) { +ssize_t ecp_tr_recv(int *sock, ECPBuffer *packet, ECPNetAddr *addr, int timeout) { struct sockaddr_in servaddr; socklen_t addrlen = sizeof(servaddr); struct pollfd fds[] = { @@ -102,13 +103,7 @@ static ssize_t t_recv(int *sock, ECPBuffer *packet, ECPNetAddr *addr, int timeou return ECP_ERR_TIMEOUT; } -int ecp_transport_init(ECPTransportIface *t) { - t->init = 1; - t->open = t_open; - t->close = t_close; - t->send = t_send; - t->recv = t_recv; - t->addr_eq = t_addr_eq; - t->addr_set = t_addr_set; - return ECP_OK; -} +void ecp_tr_buf_free(ECP2Buffer *b, unsigned char flags) {} +void ecp_tr_buf_flag_set(ECP2Buffer *b, unsigned char flags) {} +void ecp_tr_buf_flag_clear(ECP2Buffer *b, unsigned char flags) {} + |