network
[utils]

IP Network Functions. More...


Defines

#define GF_NTP_SEC_1900_TO_1970
 NTP seconds from 1900 to 1970.
#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
typedef GF_Err(* gf_net_mobileip_ctrl_cbk )(Bool start)
 MobileIP Callback.

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.
char * gf_url_get_absolute_path (const char *pathName, const char *parentPath)
 gets absolute file path
char * gf_url_concatenate (const char *parentName, const char *pathName)
 URL concatenation.
void gf_url_to_fs_path (char *url)
 URL to file system.
void gf_utc_time_since_1970 (u32 *sec, u32 *msec)
 gets UTC time
void gf_net_get_ntp (u32 *sec, u32 *frac)
 gets NTP time
GF_Socketgf_sk_new (u32 SocketType)
 socket constructor
void gf_sk_del (GF_Socket *sock)
 socket destructor
void gf_sk_reset (GF_Socket *sock)
 reset internal buffer
GF_Err gf_sk_set_buffer_size (GF_Socket *sock, Bool send_buffer, u32 new_size)
 socket buffer size control
GF_Err gf_sk_set_block_mode (GF_Socket *sock, Bool NonBlockingOn)
 blocking mode control
GF_Err gf_sk_bind (GF_Socket *sock, char *local_ip, u16 port, char *peer_name, u16 peer_port, u32 options)
 socket binding
GF_Err gf_sk_connect (GF_Socket *sock, char *peer_name, u16 port, char *local_ip)
 connects a socket
GF_Err gf_sk_send (GF_Socket *sock, char *buffer, u32 length)
 data emission
GF_Err gf_sk_receive (GF_Socket *sock, char *buffer, u32 length, u32 start_from, u32 *read)
 data reception
GF_Err gf_sk_listen (GF_Socket *sock, u32 max_conn)
 socket listening
GF_Err gf_sk_accept (GF_Socket *sock, GF_Socket **new_conn)
 socket accept
GF_Err gf_sk_server_mode (GF_Socket *sock, Bool server_on)
 server socket mode
GF_Err gf_sk_get_host_name (char *buffer)
 get local host name
GF_Err gf_sk_get_local_ip (GF_Socket *sock, char *buffer)
 get local IP
GF_Err gf_sk_get_local_info (GF_Socket *sock, u16 *port, u32 *sock_type)
 get local info
GF_Err gf_sk_get_remote_address (GF_Socket *sock, char *buffer)
 get remote address
GF_Err gf_sk_set_remote (GF_Socket *sock, char *address, u16 port)
 set remote address
GF_Err gf_sk_setup_multicast (GF_Socket *sock, char *multi_ip_add, u16 multi_port, u32 TTL, Bool no_bind, char *local_interface_ip)
 multicast setup
u32 gf_sk_is_multicast_address (char *multi_ip_add)
GF_Err gf_sk_send_wait (GF_Socket *sock, char *buffer, u32 length, u32 delay_sec)
 send data with wait delay
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
s32 gf_sk_get_handle (GF_Socket *sock)
 gets socket handle
u32 gf_net_has_ipv6 ()
 gets ipv6 support
Bool gf_net_is_ipv6 (char *address)
 checks address type
void gf_net_mobileip_set_callback (gf_net_mobileip_ctrl_cbk _mobip_cbk, const char *MobileIP)
 Assigns MobileIP callback.


Detailed Description

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

Define 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 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)

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_set_mobileip_callback function. By default no mobileip is used

Parameters:
cbck Opaque user data.
start boolean indicating wether the MobileIP subsystem should be started or stoped.
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:
url the url to analyze
Returns:
1 if the URL describes a local file, 0 otherwise

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:
pathName the relative path name of a file
parentPath the 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

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

Concatenates a relative URL with its parent URL

Parameters:
parentName URL of the parent service
pathName URL 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

void gf_url_to_fs_path ( char *  url  ) 

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

Parameters:
url url to convert

void gf_utc_time_since_1970 ( u32 *  sec,
u32 *  msec 
)

Gets UTC time since midnight Jan 1970

Parameters:
sec number of seconds
msec number of milliseconds

void gf_net_get_ntp ( u32 *  sec,
u32 *  frac 
)

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

Parameters:
sec NTP time in seconds
frac fractional NTP time expressed in 1 / (1<<32 - 1) seconds units

GF_Socket* gf_sk_new ( u32  SocketType  ) 

Constructs a socket object

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

void gf_sk_del ( GF_Socket sock  ) 

Deletes a socket object

Parameters:
sock the socket object

void gf_sk_reset ( GF_Socket sock  ) 

Forces the internal socket buffer to be reseted (discarded)

Parameters:
sock the socket object

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:
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.
Warning:
This operation may fail depending on the provider, hardware...

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:
sock the socket object
NonBlockingOn set to 1 to use on-blocking sockets, 0 otherwise

GF_Err gf_sk_bind ( GF_Socket sock,
char *  local_ip,
u16  port,
char *  peer_name,
u16  peer_port,
u32  options 
)

Binds the given socket to the specified port.

Parameters:
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
peer_port remote port number to connect the socket to
options list of option for the bind operation.

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

Connects a socket to a remote peer on a given port

Parameters:
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.

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

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

Parameters:
sock the socket object
buffer the data buffer to send
length the data length to send

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:
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

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:
sock the socket object
max_conn the 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:
sock the socket object
new_conn the resulting connection socket object

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:
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.

Parameters:
buffer destination buffer for name. Buffer must be GF_MAX_IP_NAME_LEN long

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:
sock the socket object
buffer destination buffer for IP address. Buffer must be GF_MAX_IP_NAME_LEN long

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

Gets local socket info of a socket

Parameters:
sock the socket object
port local port number of the socket
sock_type socket type (UDP or TCP)

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:
sock the socket object
buffer destination buffer for IP address. Buffer must be GF_MAX_IP_NAME_LEN long

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:
sock the socket object
address the remote peer address
port the remote peer port

GF_Err gf_sk_setup_multicast ( GF_Socket sock,
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:
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 ( char *  multi_ip_add  ) 

brief multicast address test

tests whether an IP address is a multicast one or not

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

GF_Err gf_sk_send_wait ( GF_Socket sock,
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:
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
Returns:
If the operation timeed out, the function will return a GF_IP_SOCK_WOULD_BLOCK error.

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:
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
Returns:
If the operation timeed out, the function will return a GF_IP_SOCK_WOULD_BLOCK error.

s32 gf_sk_get_handle ( GF_Socket sock  ) 

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

Parameters:
sock the socket object
Returns:
the socket handle

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

Bool gf_net_is_ipv6 ( char *  address  ) 

Checks if an address is an IPV6 or IPV4 one.

Returns:
true 1 if address is IPV6 one, 0 otherwise

void gf_net_mobileip_set_callback ( gf_net_mobileip_ctrl_cbk  _mobip_cbk,
const char *  MobileIP 
)

Assigns the MobileIP control callback.

Parameters:
_mobip_cbk MobileIP control callback


Generated on Mon Feb 23 09:16:35 2009 for libgpac by  doxygen 1.5.7.1