|
libgpac
Documentation of the core library of GPAC. For more information, check out http://gpac.wp.mines-telecom.fr
|
IP Network Functions. More...
Collaboration diagram for network:Macros | |
| #define | GF_NTP_SEC_1900_TO_1970 |
| NTP seconds from 1900 to 1970. More... | |
| #define | GF_MAX_IP_NAME_LEN 516 |
| #define | GF_SOCK_TYPE_TCP 0x01 |
| #define | GF_SOCK_TYPE_UDP 0x02 |
Typedefs | |
| typedef struct __tag_socket | GF_Socket |
| abstracted socket object More... | |
| typedef GF_Err(* | gf_net_mobileip_ctrl_cbk )(Bool start) |
| MobileIP Callback. More... | |
Enumerations | |
| enum | { GF_SOCK_REUSE_PORT = 1, GF_SOCK_FORCE_IPV6 = 1<<1 } |
Functions | |
| Bool | gf_url_is_local (const char *url) |
| URL local test. More... | |
| char * | gf_url_get_absolute_path (const char *pathName, const char *parentPath) |
| gets absolute file path More... | |
| char * | gf_url_concatenate (const char *parentName, const char *pathName) |
| URL concatenation. More... | |
| char * | gf_url_percent_encode (const char *path) |
| URL encodin. More... | |
| void | gf_url_to_fs_path (char *url) |
| URL to file system. More... | |
| const char * | gf_url_get_resource_name (const char *url) |
| Extract resource name from URL. More... | |
| Bool | gf_url_get_resource_path (const char *url, char *res_path) |
| Extract resource path from URL. More... | |
| Bool | gf_url_remove_last_delimiter (const char *sURL, char *res_path) |
| Remove last delimenter from URL. More... | |
| const char * | gf_url_get_ressource_extension (const char *sURL) |
| Extract extension from a resource path in URL. More... | |
| s32 | gf_gettimeofday (struct timeval *tp, void *tz) |
| void | gf_utc_time_since_1970 (u32 *sec, u32 *msec) |
| gets UTC time More... | |
| void | gf_net_get_ntp (u32 *sec, u32 *frac) |
| gets NTP time More... | |
| void | gf_net_set_ntp_shift (s32 sec) |
| offsets NTP time by a given amount of seconds More... | |
| u64 | gf_net_get_ntp_ts () |
| gets NTP time More... | |
| s32 | gf_net_get_ntp_diff_ms (u64 ntp) |
| GF_Socket * | gf_sk_new (u32 SocketType) |
| socket constructor More... | |
| void | gf_sk_del (GF_Socket *sock) |
| socket destructor More... | |
| void | gf_sk_reset (GF_Socket *sock) |
| reset internal buffer More... | |
| GF_Err | gf_sk_set_buffer_size (GF_Socket *sock, Bool send_buffer, u32 new_size) |
| socket buffer size control More... | |
| GF_Err | gf_sk_set_block_mode (GF_Socket *sock, Bool NonBlockingOn) |
| blocking mode control More... | |
| GF_Err | gf_sk_bind (GF_Socket *sock, const char *local_ip, u16 port, const char *peer_name, u16 peer_port, u32 options) |
| socket binding More... | |
| GF_Err | gf_sk_connect (GF_Socket *sock, const char *peer_name, u16 port, const char *local_ip) |
| connects a socket More... | |
| GF_Err | gf_sk_send (GF_Socket *sock, const char *buffer, u32 length) |
| data emission More... | |
| GF_Err | gf_sk_receive (GF_Socket *sock, char *buffer, u32 length, u32 start_from, u32 *read) |
| data reception More... | |
| GF_Err | gf_sk_listen (GF_Socket *sock, u32 max_conn) |
| socket listening More... | |
| GF_Err | gf_sk_accept (GF_Socket *sock, GF_Socket **new_conn) |
| socket accept More... | |
| GF_Err | gf_sk_server_mode (GF_Socket *sock, Bool server_on) |
| server socket mode More... | |
| GF_Err | gf_sk_get_host_name (char *buffer) |
| get local host name More... | |
| GF_Err | gf_sk_get_local_ip (GF_Socket *sock, char *buffer) |
| get local IP More... | |
| GF_Err | gf_sk_get_local_info (GF_Socket *sock, u16 *port, u32 *sock_type) |
| get local info More... | |
| GF_Err | gf_sk_get_remote_address (GF_Socket *sock, char *buffer) |
| get remote address More... | |
| GF_Err | gf_sk_set_remote (GF_Socket *sock, char *address, u16 port) |
| set remote address More... | |
| GF_Err | gf_sk_setup_multicast (GF_Socket *sock, const char *multi_ip_add, u16 multi_port, u32 TTL, Bool no_bind, char *local_interface_ip) |
| multicast setup More... | |
| u32 | gf_sk_is_multicast_address (const char *multi_ip_add) |
| GF_Err | gf_sk_send_wait (GF_Socket *sock, const char *buffer, u32 length, u32 delay_sec) |
| send data with wait delay More... | |
| GF_Err | gf_sk_receive_wait (GF_Socket *sock, char *buffer, u32 length, u32 start_from, u32 *read, u32 delay_sec) |
| receive data with wait delay More... | |
| s32 | gf_sk_get_handle (GF_Socket *sock) |
| gets socket handle More... | |
| u32 | gf_net_has_ipv6 () |
| gets ipv6 support More... | |
| Bool | gf_net_is_ipv6 (const char *address) |
| checks address type More... | |
| u32 | gf_htonl (u32 val) |
| u32 | gf_ntohl (u32 val) |
| u16 | gf_htons (u16 val) |
| u16 | gf_tohs (u16 val) |
| void | gf_net_mobileip_set_callback (gf_net_mobileip_ctrl_cbk _mobip_cbk, const char *MobileIP) |
| Assigns MobileIP callback. More... | |
This section documents the IP network functions of the GPAC framework.
| #define GF_NTP_SEC_1900_TO_1970 |
Macro giving the number of seconds from from 1900 to 1970
| #define GF_MAX_IP_NAME_LEN 516 |
Buffer size to pass for IP address retrieval
| #define GF_SOCK_TYPE_TCP 0x01 |
socket is a TCP socket
| #define GF_SOCK_TYPE_UDP 0x02 |
socket is a UDP socket
| typedef struct __tag_socket GF_Socket |
The abstracted socket object allows you to build client and server applications very simply with support for unicast and multicast (no IPv6 yet)
The gf_net_mobileip_ctrl_cbk type is the type for the callback of the gf_net_mobileip_set_callback function. By default no mobileip is used
| cbck | Opaque user data. |
| start | boolean indicating wether the MobileIP subsystem should be started or stopped. |
| anonymous enum |
| Bool gf_url_is_local | ( | const char * | url | ) |
Tests whether a URL describes a local file or not
| url | the url to analyze |
| char* gf_url_get_absolute_path | ( | const char * | pathName, |
| const char * | parentPath | ||
| ) |
Gets the absolute file path from a relative path and its parent absolute one. This can only be used with file paths.
| pathName | the relative path name of a file |
| parentPath | the absolute parent path name |
| char* gf_url_concatenate | ( | const char * | parentName, |
| const char * | pathName | ||
| ) |
Concatenates a relative URL with its parent URL
| parentName | URL of the parent service |
| pathName | URL of the service |
| char* gf_url_percent_encode | ( | const char * | path | ) |
Encodes URL by replacing special characters with their % encodings.
| path | URL of the service |
| void gf_url_to_fs_path | ( | char * | url | ) |
Converts a local URL to a file system value. Removes all white spaces and similar
| url | url to convert |
| const char* gf_url_get_resource_name | ( | const char * | url | ) |
Extracts the resource name from the URL
| url | input url |
| Bool gf_url_get_resource_path | ( | const char * | url, |
| char * | res_path | ||
| ) |
Extracts the reource path from the URL
| url | input url |
| res_path | buffer for resulting path storage |
| Bool gf_url_remove_last_delimiter | ( | const char * | sURL, |
| char * | res_path | ||
| ) |
Remove last delimenter from URL
| sURL | input url |
| res_path | buffer for resulting path storage |
| const char* gf_url_get_ressource_extension | ( | const char * | sURL | ) |
Extract a resource path of URL and analyze its extension
| sURL | input url |
| s32 gf_gettimeofday | ( | struct timeval * | tp, |
| void * | tz | ||
| ) |
Gets UTC time since midnight Jan 1970
| sec | number of seconds |
| msec | number of milliseconds |
Gets NTP (Network Time Protocol) in seconds and fractional side
| sec | NTP time in seconds |
| frac | fractional NTP time expressed in 1 / (1<<32 - 1) seconds units |
| void gf_net_set_ntp_shift | ( | s32 | sec | ) |
Offsets NTP time of the system by a given amount of seconds in the future or the past (default value is 0).
| sec | seconds to add or remove to the system NTP |
| u64 gf_net_get_ntp_ts | ( | ) |
Gets NTP (Network Time Protocol) timestamp (high 32 bit is seconds, low 32 bit is fraction)
Gets diff in milliseconds between NTP time and current time
| ntp | NTP timestamp |
Constructs a socket object
| SocketType | the socket type to create, either UDP or TCP |
| void gf_sk_del | ( | GF_Socket * | sock | ) |
Deletes a socket object
| sock | the socket object |
| void gf_sk_reset | ( | GF_Socket * | sock | ) |
Forces the internal socket buffer to be reseted (discarded)
| sock | the socket object |
Sets the size of the internal buffer of the socket. The socket MUST be bound or connected before.
| sock | the socket object |
| send_buffer | if 0, sets the size of the reception buffer, otherwise sets the size of the emission buffer |
| new_size | new size of the buffer in bytes. |
Sets the blocking mode of a socket on or off. A blocking socket will wait for the net operation to be possible while a non-blocking one would return an error. By default, sockets are created in blocking mode
| sock | the socket object |
| NonBlockingOn | set to 1 to use on-blocking sockets, 0 otherwise |
| GF_Err gf_sk_bind | ( | GF_Socket * | sock, |
| const char * | local_ip, | ||
| u16 | port, | ||
| const char * | peer_name, | ||
| u16 | peer_port, | ||
| u32 | options | ||
| ) |
Binds the given socket to the specified port.
| local_ip | the local interface IP address if desired. If NULL, the default interface will be used. |
| sock | the socket object |
| port | port number to bind this socket to |
| peer_name | the remote server address, if NULL, will use localhost |
| peer_port | remote port number to connect the socket to |
| options | list of option for the bind operation. |
Connects a socket to a remote peer on a given port
| sock | the socket object |
| peer_name | the remote server address (IP or DNS) |
| port | remote port number to connect the socket to |
| local_ip | the local (client) address (IP or DNS) if any, NULL otherwise. |
Sends a buffer on the socket. The socket must be in a bound or connected mode
| sock | the socket object |
| buffer | the data buffer to send |
| length | the data length to send |
Fetches data on a socket. The socket must be in a bound or connected state
| sock | the socket object |
| buffer | the recpetion buffer where data is written |
| length | the allocated size of the reception buffer |
| start_from | the offset in the reception buffer where to start writing |
| read | the actual number of bytes received |
Sets the socket in a listening state. This socket must have been bound to a port before
| sock | the socket object |
| max_conn | the maximum number of simultaneous connection this socket will accept |
Accepts an incomming connection on a listening socket
| sock | the socket object |
| new_conn | the resulting connection socket object |
Disable the Nable algo (e.g. set TCP_NODELAY) and set the KEEPALIVE on
| sock | the socket object |
| server_on | sets server mode on or off |
| GF_Err gf_sk_get_host_name | ( | char * | buffer | ) |
Retrieves local host name.
| buffer | destination buffer for name. Buffer must be GF_MAX_IP_NAME_LEN long |
Gets local IP address of a connected socket, typically used for server after an ACCEPT
| sock | the socket object |
| buffer | destination buffer for IP address. Buffer must be GF_MAX_IP_NAME_LEN long |
Gets local socket info of a socket
| sock | the socket object |
| port | local port number of the socket |
| sock_type | socket type (UDP or TCP) |
Gets the remote address of a peer. The socket MUST be connected.
| sock | the socket object |
| buffer | destination buffer for IP address. Buffer must be GF_MAX_IP_NAME_LEN long |
Sets the remote address of a socket. This is used by connectionless sockets using SendTo and ReceiveFrom
| sock | the socket object |
| address | the remote peer address |
| port | the remote peer port |
| GF_Err gf_sk_setup_multicast | ( | GF_Socket * | sock, |
| const char * | multi_ip_add, | ||
| u16 | multi_port, | ||
| u32 | TTL, | ||
| Bool | no_bind, | ||
| char * | local_interface_ip | ||
| ) |
Performs multicast setup (BIND and JOIN) for the socket object
| sock | the socket object |
| multi_ip_add | the multicast IP address |
| multi_port | the multicast port number |
| TTL | the multicast TTL (Time-To-Live) |
| no_bind | if sets, only join the multicast |
| local_interface_ip | the local interface IP address if desired. If NULL, the default interface will be used. |
| u32 gf_sk_is_multicast_address | ( | const char * | multi_ip_add | ) |
brief multicast address test
tests whether an IP address is a multicast one or not
| multi_ip_add | the multicast IP address to test |
Sends data with a max wait delay. This is used for http / ftp sockets mainly. The socket must be connected.
| sock | the socket object |
| buffer | the data buffer to send |
| length | the data length to send |
| delay_sec | the maximum delay in second to wait before aborting |
| GF_Err gf_sk_receive_wait | ( | GF_Socket * | sock, |
| char * | buffer, | ||
| u32 | length, | ||
| u32 | start_from, | ||
| u32 * | read, | ||
| u32 | delay_sec | ||
| ) |
Fetches data with a max wait delay. This is used for http / ftp sockets mainly. The socket must be connected.
| sock | the socket object |
| buffer | the recpetion buffer where data is written |
| length | the allocated size of the reception buffer |
| start_from | the offset in the reception buffer where to start writing |
| read | the actual number of bytes received |
| delay_sec | the maximum delay in second to wait before aborting |
Gets the socket low-level handle as used by OpenSSL.
| sock | the socket object |
| u32 gf_net_has_ipv6 | ( | ) |
Returns IPV6 support information.
| Bool gf_net_is_ipv6 | ( | const char * | address | ) |
Checks if an address is an IPV6 or IPV4 one.
| address | Adress to check |
host to network conversion of integer
| integrer | to convert |
network to host conversion of integer
| integrer | to convert |
host to network conversion of short integer
| short | integrer to convert |
network to host conversion of short integer
| short | integrer to convert |
| void gf_net_mobileip_set_callback | ( | gf_net_mobileip_ctrl_cbk | _mobip_cbk, |
| const char * | MobileIP | ||
| ) |
Assigns the MobileIP control callback.
| _mobip_cbk | MobileIP control callback |
| MobileIP | MobileIP address |