summaryrefslogtreecommitdiff
path: root/ecp/src/platform/fe310
diff options
context:
space:
mode:
Diffstat (limited to 'ecp/src/platform/fe310')
-rw-r--r--ecp/src/platform/fe310/time.c10
-rw-r--r--ecp/src/platform/fe310/transport.c16
-rw-r--r--ecp/src/platform/fe310/transport.h7
3 files changed, 19 insertions, 14 deletions
diff --git a/ecp/src/platform/fe310/time.c b/ecp/src/platform/fe310/time.c
index 3c74933..1e5eb17 100644
--- a/ecp/src/platform/fe310/time.c
+++ b/ecp/src/platform/fe310/time.c
@@ -1,3 +1,5 @@
+#include <stdlib.h>
+
#include <core.h>
#include <tr.h>
@@ -9,7 +11,7 @@
extern ECPSocket *_ecp_tr_sock;
static void timer_handler(unsigned char type) {
- ecp_cts_t next = ecp_timer_exe(_ecp_tr_sock);
+ ecp_sts_t next = ecp_timer_exe(_ecp_tr_sock);
if (next) {
eos_timer_set(next, EOS_TIMER_ETYPE_ECP);
}
@@ -21,15 +23,15 @@ int ecp_tm_init(ECPContext *ctx) {
return ECP_OK;
}
-ecp_cts_t ecp_tm_abstime_ms(ecp_cts_t msec) {
+ecp_sts_t ecp_tm_abstime_ms(ecp_sts_t msec) {
return eos_time_get_tick() * 1000 / EOS_TIMER_RTC_FREQ + msec;
}
-void ecp_tm_sleep_ms(ecp_cts_t msec) {
+void ecp_tm_sleep_ms(ecp_sts_t msec) {
eos_time_sleep(msec);
}
-void ecp_tm_timer_set(ecp_cts_t next) {
+void ecp_tm_timer_set(ecp_sts_t next) {
uint32_t _next = eos_timer_get(EOS_TIMER_ETYPE_ECP);
if ((_next == EOS_TIMER_NONE) || (next < _next)) eos_timer_set(next, EOS_TIMER_ETYPE_ECP);
}
diff --git a/ecp/src/platform/fe310/transport.c b/ecp/src/platform/fe310/transport.c
index 777a956..b551c51 100644
--- a/ecp/src/platform/fe310/transport.c
+++ b/ecp/src/platform/fe310/transport.c
@@ -1,4 +1,5 @@
#include <stdlib.h>
+#include <string.h>
#include <core.h>
#include <tr.h>
@@ -11,7 +12,7 @@ static unsigned char _flags = 0;
ECPSocket *_ecp_tr_sock = NULL;
static void packet_handler(unsigned char type, unsigned char *buffer, uint16_t len) {
- ECPNetAddr addr;
+ ecp_tr_addr_t addr;
ECP2Buffer bufs;
ECPBuffer packet;
@@ -49,13 +50,18 @@ int ecp_tr_init(ECPContext *ctx) {
return ECP_OK;
}
-int ecp_tr_addr_eq(ECPNetAddr *addr1, ECPNetAddr *addr2) {
+unsigned int ecp_tr_addr_hash(ecp_tr_addr_t *addr) {
+ unsigned int ret = *((unsigned int *)addr->host);
+ return ret ^ ((unsigned int)addr->port << 16);
+}
+
+int ecp_tr_addr_eq(ecp_tr_addr_t *addr1, ecp_tr_addr_t *addr2) {
if (addr1->port != addr2->port) return 0;
if (memcmp(addr1->host, addr2->host, sizeof(addr1->host)) != 0) return 0;
return 1;
}
-int ecp_tr_addr_set(ECPNetAddr *addr, void *addr_s) {
+int ecp_tr_addr_set(ecp_tr_addr_t *addr, void *addr_s) {
return ECP_ERR;
}
@@ -74,7 +80,7 @@ void ecp_tr_close(ECPSocket *sock) {
_ecp_tr_sock = NULL;
}
-ssize_t ecp_tr_send(ECPSocket *sock, ECPBuffer *packet, size_t msg_size, ECPNetAddr *addr, unsigned char flags) {
+ssize_t ecp_tr_send(ECPSocket *sock, ECPBuffer *packet, size_t msg_size, ecp_tr_addr_t *addr, unsigned char flags) {
unsigned char *buf = NULL;
int rv;
@@ -94,7 +100,7 @@ ssize_t ecp_tr_send(ECPSocket *sock, ECPBuffer *packet, size_t msg_size, ECPNetA
return msg_size;
}
-ssize_t ecp_tr_recv(ECPSocket *sock, ECPBuffer *packet, ECPNetAddr *addr, int timeout) {
+ssize_t ecp_tr_recv(ECPSocket *sock, ECPBuffer *packet, ecp_tr_addr_t *addr, int timeout) {
return ECP_ERR;
}
diff --git a/ecp/src/platform/fe310/transport.h b/ecp/src/platform/fe310/transport.h
index 47ad482..213ca11 100644
--- a/ecp/src/platform/fe310/transport.h
+++ b/ecp/src/platform/fe310/transport.h
@@ -1,7 +1,4 @@
#include <eos/sock.h>
-#define ECP_IPv4_ADDR_SIZE 4
-
-typedef EOSNetAddr ECPNetAddr;
-typedef int ECPNetSock;
-
+typedef EOSNetAddr ecp_tr_addr_t;
+typedef int ecp_tr_sock_t;