GPAC
Open Source Multimedia Framework. For more information, check out http://gpac.wp.mines-telecom.fr
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups
network

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 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...
 
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...
 
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...
 
void gf_net_mobileip_set_callback (gf_net_mobileip_ctrl_cbk _mobip_cbk, const char *MobileIP)
 Assigns MobileIP callback. More...
 

Detailed Description

This section documents the IP network functions of the GPAC framework.

Macro Definition Documentation

#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 Documentation

typedef GF_Err(* gf_net_mobileip_ctrl_cbk)(Bool start)

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

Parameters
cbckOpaque user data.
startboolean indicating wether the MobileIP subsystem should be started or stopped.
Returns
Error code if needed.

Enumeration Type Documentation

anonymous enum

Socket options

Enumerator
GF_SOCK_REUSE_PORT 

Reuses port.

GF_SOCK_FORCE_IPV6 

Forces IPV6 if available.

Function Documentation

Bool gf_url_is_local ( const char *  url)

Tests whether a URL describes a local file or not

Parameters
urlthe url to analyze
Returns
1 if the URL describes a local file, 0 otherwise

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Parameters
pathNamethe relative path name of a file
parentPaththe absolute parent path name
Returns
absolute path name of the file, or NULL if bad paths are provided.
Note
the returned string must be freed by user

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

char* gf_url_concatenate ( const char *  parentName,
const char *  pathName 
)

Concatenates a relative URL with its parent URL

Parameters
parentNameURL of the parent service
pathNameURL of the service
Returns
absolute path name of the service, or NULL if bad paths are provided or if the service path is already an absolute one.
Note
the returned string must be freed by user

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

char* gf_url_percent_encode ( const char *  path)

Encodes URL by replacing special characters with their % encodings.

Parameters
pathURL of the service
Returns
encoded path name , or NULL if bad paths are provided.
Note
the returned string must be freed by user

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void gf_url_to_fs_path ( char *  url)

Converts a local URL to a file system value. Removes all white spaces and similar

Parameters
urlurl to convert

+ Here is the caller graph for this function:

const char* gf_url_get_resource_name ( const char *  url)

Extracts the resource name from the URL

Parameters
urlinput url
Returns
resource name.

+ Here is the caller graph for this function:

Bool gf_url_get_resource_path ( const char *  url,
char *  res_path 
)

Extracts the reource path from the URL

Parameters
urlinput url
res_pathbuffer for resulting path storage
Returns
1 if path was extracted, 0 if url is a single file name.

+ Here is the caller graph for this function:

Bool gf_url_remove_last_delimiter ( const char *  sURL,
char *  res_path 
)

Remove last delimenter from URL

Parameters
sURLinput url
res_pathbuffer for resulting path storage
Returns
GF_TRUE if delimiter was extracted, otherwise GF_FALSE.
const char* gf_url_get_ressource_extension ( const char *  sURL)

Extract a resource path of URL and analyze its extension

Parameters
sURLinput url
Returns
The corresponding extension if exists, otherwise NULL.
void gf_utc_time_since_1970 ( u32 sec,
u32 msec 
)

Gets UTC time since midnight Jan 1970

Parameters
secnumber of seconds
msecnumber of milliseconds

+ Here is the caller graph for this function:

void gf_net_get_ntp ( u32 sec,
u32 frac 
)

Gets NTP (Network Time Protocol) in seconds and fractional side

Parameters
secNTP time in seconds
fracfractional NTP time expressed in 1 / (1<<32 - 1) seconds units

+ Here is the caller graph for this function:

GF_Socket* gf_sk_new ( u32  SocketType)

Constructs a socket object

Parameters
SocketTypethe socket type to create, either UDP or TCP
Returns
the socket object or NULL if network initialization failure

+ Here is the caller graph for this function:

void gf_sk_del ( GF_Socket *  sock)

Deletes a socket object

Parameters
sockthe socket object

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void gf_sk_reset ( GF_Socket *  sock)

Forces the internal socket buffer to be reseted (discarded)

Parameters
sockthe socket object

+ Here is the caller graph for this function:

GF_Err gf_sk_set_buffer_size ( GF_Socket *  sock,
Bool  send_buffer,
u32  new_size 
)

Sets the size of the internal buffer of the socket. The socket MUST be bound or connected before.

Parameters
sockthe socket object
send_bufferif 0, sets the size of the reception buffer, otherwise sets the size of the emission buffer
new_sizenew size of the buffer in bytes.
Warning
This operation may fail depending on the provider, hardware...

+ Here is the caller graph for this function:

GF_Err gf_sk_set_block_mode ( GF_Socket *  sock,
Bool  NonBlockingOn 
)

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

Parameters
sockthe socket object
NonBlockingOnset to 1 to use on-blocking sockets, 0 otherwise

+ Here is the caller graph for this function:

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.

Parameters
local_ipthe local interface IP address if desired. If NULL, the default interface will be used.
sockthe socket object
portport number to bind this socket to
peer_namethe remote server address, if NULL, will use localhost
peer_portremote port number to connect the socket to
optionslist of option for the bind operation.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

GF_Err gf_sk_connect ( GF_Socket *  sock,
const char *  peer_name,
u16  port,
const char *  local_ip 
)

Connects a socket to a remote peer on a given port

Parameters
sockthe socket object
peer_namethe remote server address (IP or DNS)
portremote port number to connect the socket to
local_ipthe local (client) address (IP or DNS) if any, NULL otherwise.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

GF_Err gf_sk_send ( GF_Socket *  sock,
const char *  buffer,
u32  length 
)

Sends a buffer on the socket. The socket must be in a bound or connected mode

Parameters
sockthe socket object
bufferthe data buffer to send
lengththe data length to send

+ Here is the caller graph for this function:

GF_Err gf_sk_receive ( GF_Socket *  sock,
char *  buffer,
u32  length,
u32  start_from,
u32 read 
)

Fetches data on a socket. The socket must be in a bound or connected state

Parameters
sockthe socket object
bufferthe recpetion buffer where data is written
lengththe allocated size of the reception buffer
start_fromthe offset in the reception buffer where to start writing
readthe actual number of bytes received

+ Here is the caller graph for this function:

GF_Err gf_sk_listen ( GF_Socket *  sock,
u32  max_conn 
)

Sets the socket in a listening state. This socket must have been bound to a port before

Parameters
sockthe socket object
max_connthe maximum number of simultaneous connection this socket will accept
GF_Err gf_sk_accept ( GF_Socket *  sock,
GF_Socket **  new_conn 
)

Accepts an incomming connection on a listening socket

Parameters
sockthe socket object
new_connthe resulting connection socket object

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

GF_Err gf_sk_server_mode ( GF_Socket *  sock,
Bool  server_on 
)

Disable the Nable algo (e.g. set TCP_NODELAY) and set the KEEPALIVE on

Parameters
sockthe socket object
server_onsets server mode on or off

+ Here is the caller graph for this function:

GF_Err gf_sk_get_host_name ( char *  buffer)

Retrieves local host name.

Parameters
bufferdestination buffer for name. Buffer must be GF_MAX_IP_NAME_LEN long

+ Here is the caller graph for this function:

GF_Err gf_sk_get_local_ip ( GF_Socket *  sock,
char *  buffer 
)

Gets local IP address of a connected socket, typically used for server after an ACCEPT

Parameters
sockthe socket object
bufferdestination buffer for IP address. Buffer must be GF_MAX_IP_NAME_LEN long

+ Here is the caller graph for this function:

GF_Err gf_sk_get_local_info ( GF_Socket *  sock,
u16 port,
u32 sock_type 
)

Gets local socket info of a socket

Parameters
sockthe socket object
portlocal port number of the socket
sock_typesocket type (UDP or TCP)

+ Here is the caller graph for this function:

GF_Err gf_sk_get_remote_address ( GF_Socket *  sock,
char *  buffer 
)

Gets the remote address of a peer. The socket MUST be connected.

Parameters
sockthe socket object
bufferdestination buffer for IP address. Buffer must be GF_MAX_IP_NAME_LEN long

+ Here is the caller graph for this function:

GF_Err gf_sk_set_remote ( GF_Socket *  sock,
char *  address,
u16  port 
)

Sets the remote address of a socket. This is used by connectionless sockets using SendTo and ReceiveFrom

Parameters
sockthe socket object
addressthe remote peer address
portthe 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

Parameters
sockthe socket object
multi_ip_addthe multicast IP address
multi_portthe multicast port number
TTLthe multicast TTL (Time-To-Live)
no_bindif sets, only join the multicast
local_interface_ipthe local interface IP address if desired. If NULL, the default interface will be used.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Parameters
multi_ip_addthe multicast IP address to test
Returns
1 if the address is a multicast one, 0 otherwise

+ Here is the caller graph for this function:

GF_Err gf_sk_send_wait ( GF_Socket *  sock,
const char *  buffer,
u32  length,
u32  delay_sec 
)

Sends data with a max wait delay. This is used for http / ftp sockets mainly. The socket must be connected.

Parameters
sockthe socket object
bufferthe data buffer to send
lengththe data length to send
delay_secthe maximum delay in second to wait before aborting
Returns
If the operation timeed out, the function will return a GF_IP_SOCK_WOULD_BLOCK error.

+ Here is the caller graph for this function:

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.

Parameters
sockthe socket object
bufferthe recpetion buffer where data is written
lengththe allocated size of the reception buffer
start_fromthe offset in the reception buffer where to start writing
readthe actual number of bytes received
delay_secthe maximum delay in second to wait before aborting
Returns
If the operation timeed out, the function will return a GF_IP_SOCK_WOULD_BLOCK error.

+ Here is the caller graph for this function:

s32 gf_sk_get_handle ( GF_Socket *  sock)

Gets the socket low-level handle as used by OpenSSL.

Parameters
sockthe socket object
Returns
the socket handle

+ Here is the caller graph for this function:

u32 gf_net_has_ipv6 ( )

Returns IPV6 support information.

Returns
2 if the machine has IPV6 support, 1 if the library was compiled with IPV6 support, 0 otherwise

+ Here is the caller graph for this function:

Bool gf_net_is_ipv6 ( const char *  address)

Checks if an address is an IPV6 or IPV4 one.

Returns
true 1 if address is IPV6 one, 0 otherwise

+ Here is the caller graph for this function:

void gf_net_mobileip_set_callback ( gf_net_mobileip_ctrl_cbk  _mobip_cbk,
const char *  MobileIP 
)

Assigns the MobileIP control callback.

Parameters
_mobip_cbkMobileIP control callback
MobileIPMobileIP address