| 1 | #ifndef LO_INTERNAL_H |
| 2 | #define LO_INTERNAL_H |
| 3 | |
| 4 | #include "config.h" |
| 5 | |
| 6 | #include "lo_osc_types.h" |
| 7 | |
| 8 | /** |
| 9 | * \brief Validate raw OSC string data. Where applicable, data should be |
| 10 | * in network byte order. |
| 11 | * |
| 12 | * This function is used internally to parse and validate raw OSC data. |
| 13 | * |
| 14 | * Returns length of string or < 0 if data is invalid. |
| 15 | * |
| 16 | * \param data A pointer to the data. |
| 17 | * \param size The size of data in bytes (total bytes remaining). |
| 18 | */ |
| 19 | ssize_t lo_validate_string(void *data, ssize_t size); |
| 20 | |
| 21 | /** |
| 22 | * \brief Validate raw OSC blob data. Where applicable, data should be |
| 23 | * in network byte order. |
| 24 | * |
| 25 | * This function is used internally to parse and validate raw OSC data. |
| 26 | * |
| 27 | * Returns length of blob or < 0 if data is invalid. |
| 28 | * |
| 29 | * \param data A pointer to the data. |
| 30 | * \param size The size of data in bytes (total bytes remaining). |
| 31 | */ |
| 32 | ssize_t lo_validate_blob(void *data, ssize_t size); |
| 33 | |
| 34 | /** |
| 35 | * \brief Validate raw OSC bundle data. Where applicable, data should be |
| 36 | * in network byte order. |
| 37 | * |
| 38 | * This function is used internally to parse and validate raw OSC data. |
| 39 | * |
| 40 | * Returns length of bundle or < 0 if data is invalid. |
| 41 | * |
| 42 | * \param data A pointer to the data. |
| 43 | * \param size The size of data in bytes (total bytes remaining). |
| 44 | */ |
| 45 | ssize_t lo_validate_bundle(void *data, ssize_t size); |
| 46 | |
| 47 | /** |
| 48 | * \brief Validate raw OSC argument data. Where applicable, data should be |
| 49 | * in network byte order. |
| 50 | * |
| 51 | * This function is used internally to parse and validate raw OSC data. |
| 52 | * |
| 53 | * Returns length of argument data or < 0 if data is invalid. |
| 54 | * |
| 55 | * \param type The OSC type of the data item (eg. LO_FLOAT). |
| 56 | * \param data A pointer to the data. |
| 57 | * \param size The size of data in bytes (total bytes remaining). |
| 58 | */ |
| 59 | ssize_t lo_validate_arg(lo_type type, void *data, ssize_t size); |
| 60 | |
| 61 | int lo_address_resolve(lo_address a); |
| 62 | |
| 63 | /** |
| 64 | * \internal \brief Look up a given interface by name or by IP and |
| 65 | * store the found information in a lo_inaddr. Usually either iface |
| 66 | * or ip will be zero, but not both. |
| 67 | * |
| 68 | * \param t Location to store interface information. |
| 69 | * \param fam Family, either AF_INET or AF_INET6. |
| 70 | * \param iface The interface to look for by name. |
| 71 | * \param ip The IP to find an interface for. |
| 72 | */ |
| 73 | int lo_inaddr_find_iface(lo_inaddr t, int fam, |
| 74 | const char *iface, const char *ip); |
| 75 | |
| 76 | /** \internal \brief Add a socket to this server's list of sockets. |
| 77 | * \param s The lo_server |
| 78 | * \param socket The socket number to add. |
| 79 | * \return The index number of the added socket, or -1 on failure. |
| 80 | */ |
| 81 | int lo_server_add_socket(lo_server s, int socket, lo_address a, |
| 82 | struct sockaddr_storage *addr, |
| 83 | socklen_t addr_len); |
| 84 | |
| 85 | /** \internal \brief Delete a socket from this server's list of sockets. |
| 86 | * \param s The lo_server |
| 87 | * \param index The index of the socket to delete, -1 if socket is provided. |
| 88 | * \param socket The socket number to delete, -1 if index is provided. |
| 89 | */ |
| 90 | void lo_server_del_socket(lo_server s, int index, int socket); |
| 91 | |
| 92 | /** \internal \brief Copy a lo_address into pre-allocated memory. */ |
| 93 | void lo_address_copy(lo_address to, lo_address from); |
| 94 | |
| 95 | /** \internal \brief Initialize a pre-allocated lo_address from a |
| 96 | * sockaddr. */ |
| 97 | void lo_address_init_with_sockaddr(lo_address a, |
| 98 | void *sa, size_t sa_len, |
| 99 | int sock, int prot); |
| 100 | |
| 101 | /** \internal \brief Free memory owned by an address, without freeing |
| 102 | * actual lo_address structure. */ |
| 103 | void lo_address_free_mem(lo_address a); |
| 104 | |
| 105 | #endif |