On 07 Oct 2015, at 16:18, Neels Hofmeyr <nhofmeyr@sysmocom.de> wrote:
+/* TODO move to osmocom/core/socket.c ? */
where did you take this from?
+/* TODO move to osmocom/core/socket.c ? */
+int osmo_sockaddr_init(struct sockaddr_storage *addr, socklen_t *addr_len, + uint16_t family, uint16_t type, uint8_t proto, + const char *host, uint16_t port) +{
ah yeah. the by hostname is a good idea. But this should only be used at the beginning of an application as we don't want to block on a DNS query.
+static struct log_info_cat gtphub_categories[] = {
+static const struct log_info gtphub_log_info = { + .filter_fn = gtphub_log_filter_fn, + .cat = gtphub_categories, + .num_cat = ARRAY_SIZE(gtphub_categories), +};
nothing else will be used as debug log? Depending on the answer it might be better to just always initialize the GTPHUB area..
+int gtp_relay(struct osmo_fd *from, struct sockaddr_storage *from_addr, socklen_t *from_addr_len, + struct osmo_fd *to, struct sockaddr_storage *to_addr, socklen_t to_addr_len) +{ + static uint8_t buf[4096]; + + errno = 0; + ssize_t received = recvfrom(from->fd, buf, sizeof(buf), 0, + (struct sockaddr*)from_addr, from_addr_len); +
When the first gbproxy was built our buffer was smaller and we truncated messages. Now 4k is pretty big and bigger than our expectation for a UDP message. If you use recvmsg then the msg_flags will have MSG_TRUNC set or not. Not sure if you want to use it.
+ rc = osmo_sock_init_ofd(&clients_ofd, AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, clients_addr_str, clients_port, OSMO_SOCK_F_BIND); + rc = osmo_sock_init_ofd(&server_ofd, AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, server_rx_addr_str, server_rx_port, OSMO_SOCK_F_BIND);
Who is the server? who is the client? Maybe give it names to what we expect on the side? One is the SGSN, the other is the GGSN?