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