diff options
Diffstat (limited to 'rpc_server_loopback.c')
-rw-r--r-- | rpc_server_loopback.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/rpc_server_loopback.c b/rpc_server_loopback.c index a39e12b..4ca7467 100644 --- a/rpc_server_loopback.c +++ b/rpc_server_loopback.c @@ -41,47 +41,47 @@ #include "hal.h" #include "hal_internal.h" -static int sock; +static int fd; -hal_error_t rpc_server_transport_init(void) +hal_error_t hal_rpc_server_transport_init(void) { struct sockaddr_in sin; - sock = socket(AF_INET, SOCK_DGRAM, 0); - if (sock == -1) + fd = socket(AF_INET, SOCK_DGRAM, 0); + if (fd == -1) return perror("socket"), HAL_ERROR_RPC_TRANSPORT; sin.sin_family = AF_INET; sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); sin.sin_port = 17425; - if (bind(sock, (const struct sockaddr *)&sin, sizeof(sin)) != 0) + if (bind(fd, (const struct sockaddr *)&sin, sizeof(sin)) != 0) return perror("bind"), HAL_ERROR_RPC_TRANSPORT; return HAL_OK; } -hal_error_t rpc_server_transport_close(void) +hal_error_t hal_rpc_server_transport_close(void) { - if (close(sock) != 0) + if (close(fd) != 0) return perror("close"), HAL_ERROR_RPC_TRANSPORT; return HAL_OK; } -hal_error_t rpc_sendto(const uint8_t * const buf, const size_t len, void *opaque) +hal_error_t hal_rpc_sendto(const uint8_t * const buf, const size_t len, void *opaque) { struct sockaddr_in *sin = (struct sockaddr_in *)opaque; int ret; - if ((ret = sendto(sock, buf, len, 0, (struct sockaddr *)sin, sizeof(*sin))) == -1) + if ((ret = sendto(fd, buf, len, 0, (struct sockaddr *)sin, sizeof(*sin))) == -1) return perror("sendto"), HAL_ERROR_RPC_TRANSPORT; return HAL_OK; } -hal_error_t rpc_recvfrom(uint8_t * const buf, size_t * const len, void **opaque) +hal_error_t hal_rpc_recvfrom(uint8_t * const buf, size_t * const len, void **opaque) { static struct sockaddr_in sin; socklen_t sin_len = sizeof(sin); int ret; - if ((ret = recvfrom(sock, buf, *len, 0, (struct sockaddr *)&sin, &sin_len)) == -1) + if ((ret = recvfrom(fd, buf, *len, 0, (struct sockaddr *)&sin, &sin_len)) == -1) return HAL_ERROR_RPC_TRANSPORT; *opaque = (void *)&sin; *len = ret; |