From 58f1c9a91226f4954a4799fab082f186923aa806 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Sat, 3 Oct 2020 16:25:48 +0200 Subject: Add libraries from Osmocom-Analog --- src/libosmocc/socket.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/libosmocc/socket.h (limited to 'src/libosmocc/socket.h') diff --git a/src/libosmocc/socket.h b/src/libosmocc/socket.h new file mode 100644 index 0000000..a0f96ed --- /dev/null +++ b/src/libosmocc/socket.h @@ -0,0 +1,44 @@ +#ifndef OSMO_CC_SOCKET_H +#define OSMO_CC_SOCKET_H + +#define OSMO_CC_DEFAULT_PORT 4200 +#define OSMO_CC_DEFAULT_PORT_MAX 4299 + +#define OSMO_CC_SOCKET_TX_KEEPALIVE 10.0 +#define OSMO_CC_SOCKET_RX_KEEPALIVE 20.0 + +struct osmo_cc_socket; + +typedef struct osmo_cc_conn { + struct osmo_cc_conn *next; + struct osmo_cc_socket *os; + int socket; + uint32_t callref; + int read_setup; + int read_version; + char read_version_string[sizeof(OSMO_CC_VERSION)]; /* must include 0-termination */ + int read_version_pos; + int write_version; + osmo_cc_msg_t read_hdr; + osmo_cc_msg_t *read_msg; + int read_pos; + osmo_cc_msg_list_t *write_list; + struct timer tx_keepalive_timer; + struct timer rx_keepalive_timer; +} osmo_cc_conn_t; + +typedef struct osmo_cc_socket { + int socket; + osmo_cc_conn_t *conn_list; + osmo_cc_msg_list_t *write_list; + void (*recv_msg_cb)(void *priv, uint32_t callref, osmo_cc_msg_t *msg); + void *priv; + uint8_t location; +} osmo_cc_socket_t; + +int osmo_cc_open_socket(osmo_cc_socket_t *os, const char *host, uint16_t port, void *priv, void (*recv_msg_cb)(void *priv, uint32_t callref, osmo_cc_msg_t *msg), uint8_t location); +void osmo_cc_close_socket(osmo_cc_socket_t *os); +int osmo_cc_sock_send_msg(osmo_cc_socket_t *os, uint32_t callref, osmo_cc_msg_t *msg, const char *host, uint16_t port); +int osmo_cc_handle_socket(osmo_cc_socket_t *os); + +#endif /* OSMO_CC_SOCKET_H */ -- cgit v1.2.3