diff options
Diffstat (limited to 'openbsc/include/openbsc')
-rw-r--r-- | openbsc/include/openbsc/gtphub.h | 98 |
1 files changed, 1 insertions, 97 deletions
diff --git a/openbsc/include/openbsc/gtphub.h b/openbsc/include/openbsc/gtphub.h index 9cb7605f8..08f66ca9a 100644 --- a/openbsc/include/openbsc/gtphub.h +++ b/openbsc/include/openbsc/gtphub.h @@ -27,106 +27,10 @@ #include <osmocom/core/select.h> #include <osmocom/core/timer.h> #include <osmocom/core/rate_ctr.h> +#include <osmocom/core/sockaddr.h> #include <openbsc/gprs_sgsn.h> - -/* support */ - -/* TODO move to osmocom/core/socket.c ? */ -#include <netdb.h> /* for IPPROTO_* etc */ -struct osmo_sockaddr { - struct sockaddr_storage a; - socklen_t l; -}; - -/* TODO move to osmocom/core/socket.c ? */ -/*! \brief Initialize a sockaddr - * \param[out] addr Valid osmo_sockaddr pointer to write result to - * \param[in] family Address Family like AF_INET, AF_INET6, AF_UNSPEC - * \param[in] type Socket type like SOCK_DGRAM, SOCK_STREAM - * \param[in] proto Protocol like IPPROTO_TCP, IPPROTO_UDP - * \param[in] host Remote host name or IP address in string form - * \param[in] port Remote port number in host byte order - * \returns 0 on success, otherwise an error code (from getaddrinfo()). - * - * Copy the first result from a getaddrinfo() call with the given parameters to - * *addr and *addr_len. On error, do not change *addr and return nonzero. - */ -int osmo_sockaddr_init(struct osmo_sockaddr *addr, - uint16_t family, uint16_t type, uint8_t proto, - const char *host, uint16_t port); - -/* Conveniently pass AF_UNSPEC, SOCK_DGRAM and IPPROTO_UDP to - * osmo_sockaddr_init(). */ -static inline int osmo_sockaddr_init_udp(struct osmo_sockaddr *addr, - const char *host, uint16_t port) -{ - return osmo_sockaddr_init(addr, AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, - host, port); -} - -/*! \brief convert sockaddr to human readable string. - * \param[out] addr_str Valid pointer to a buffer of length addr_str_len. - * \param[in] addr_str_len Size of buffer addr_str points at. - * \param[out] port_str Valid pointer to a buffer of length port_str_len. - * \param[in] port_str_len Size of buffer port_str points at. - * \param[in] addr Binary representation as returned by osmo_sockaddr_init(). - * \param[in] flags flags as passed to getnameinfo(). - * \returns 0 on success, an error code on error. - * - * Return the IPv4 or IPv6 address string and the port (a.k.a. service) string - * representations of the given struct osmo_sockaddr in two caller provided - * char buffers. Flags of (NI_NUMERICHOST | NI_NUMERICSERV) return numeric - * address and port. Either one of addr_str or port_str may be NULL, in which - * case nothing is returned there. - * - * See also osmo_sockaddr_to_str() (less flexible, but much more convenient). */ -int osmo_sockaddr_to_strs(char *addr_str, size_t addr_str_len, - char *port_str, size_t port_str_len, - const struct osmo_sockaddr *addr, - int flags); - - -/*! \brief concatenate the parts returned by osmo_sockaddr_to_strs(). - * \param[in] addr Binary representation as returned by osmo_sockaddr_init(). - * \param[in] buf A buffer to use for string operations. - * \param[in] buf_len Length of the buffer. - * \returns Address string (in buffer). - * - * Compose a string of the numeric IP-address and port represented by *addr of - * the form "<ip-addr> port <port>". The returned string is valid until the - * next invocation of this function. - */ -const char *osmo_sockaddr_to_strb(const struct osmo_sockaddr *addr, - char *buf, size_t buf_len); - -/*! \brief conveniently return osmo_sockaddr_to_strb() in a static buffer. - * \param[in] addr Binary representation as returned by osmo_sockaddr_init(). - * \returns Address string in static buffer. - * - * See osmo_sockaddr_to_strb(). - * - * Note: only one osmo_sockaddr_to_str() call will work per print/log - * statement. For two or more, use osmo_sockaddr_to_strb() with a separate - * buffer each. - */ -const char *osmo_sockaddr_to_str(const struct osmo_sockaddr *addr); - -/*! \brief compare two osmo_sockaddr. - * \param[in] a The first address to compare. - * \param[in] b The other address to compare. - * \returns 0 if equal, otherwise -1 or 1. - */ -int osmo_sockaddr_cmp(const struct osmo_sockaddr *a, - const struct osmo_sockaddr *b); - -/*! \brief Overwrite *dst with *src. - * Like memcpy(), but copy only the valid bytes. */ -void osmo_sockaddr_copy(struct osmo_sockaddr *dst, - const struct osmo_sockaddr *src); - - /* general */ enum gtphub_plane_idx { |