![]() |
libgpac
Documentation of the core library of GPAC
|
#include <gpac/network.h>#include <gpac/utf.h>#include <unistd.h>#include <fcntl.h>#include <netdb.h>#include <errno.h>#include <sys/time.h>#include <netinet/in.h>#include <netinet/tcp.h>#include <sys/socket.h>#include <sys/types.h>#include <arpa/inet.h>#include <gpac/bitstream.h>#include <gpac/list.h>#include <assert.h>
Include dependency graph for os_net.c:Data Structures | |
| struct | NetCapInfo |
| struct | GF_Socket |
| abstracted socket object More... | |
| struct | NetFilterRule |
| struct | GF_NetcapFilter |
| struct | GetIPInfo |
| struct | GF_SockGroup |
| abstracted socket group object More... | |
Macros | |
| #define | INADDR_NONE ((unsigned long)-1) |
| #define | SOCKET_INVALID(_s) (_s<0) |
| #define | INVALID_SOCKET -1 |
| #define | SOCKET_ERROR -1 |
| #define | LASTSOCKERROR errno |
| #define | closesocket(v) close(v) |
| #define | my_inet_ntop inet_ntop |
| #define | SSO_CAST (const char *) |
| #define | GF_GPC_MAGIC GF_4CC('G','P','C', 0) |
| #define | SKIP_PCAP_PCK |
| #define | sock_close(_s) |
| #define | gf_gethostbyname gethostbyname |
Typedefs | |
| typedef s32 | SOCKET |
Enumerations | |
| enum | { GF_SOCK_IS_TCP = 1<<9 , GF_SOCK_IS_IPV6 = 1<<10 , GF_SOCK_NON_BLOCKING = 1<<11 , GF_SOCK_IS_MULTICAST = 1<<12 , GF_SOCK_IS_LISTENING = 1<<13 , GF_SOCK_HAS_PEER = 1<<14 , GF_SOCK_IS_UN = 1<<15 , GF_SOCK_HAS_CONNECT = 1<<16 } |
| enum | { NETCAP_IS_MCAST = 1 , NETCAP_IS_TCP = 1<<1 , NETCAP_HAS_PEER = 1<<2 , NETCAP_IS_IPV6 = 1<<3 , NETCAP_HAS_EXT = 1<<6 , NETCAP_DROP = 1<<7 } |
| enum | { NETCAP_NONE = 0 , NETCAP_GPAC = 1 , NETCAP_PCAP = 2 , NETCAP_PCAPNG = 3 } |
| enum | { PCAP_LT_LOOPBACK =0 , PCAP_LT_ETHERNET =1 , PCAP_LT_CHAOS =5 } |
Functions | |
| static GF_NetcapFilter * | gf_net_filter_get (const char *id) |
| GF_EXPORT u32 | gf_net_has_ipv6 () |
| gets ipv6 support | |
| GF_EXPORT Bool | gf_net_is_ipv6 (const char *address) |
| checks address type | |
| GF_EXPORT GF_Err | gf_sk_get_host_name (char *buffer) |
| get local host name | |
| GF_EXPORT GF_Err | gf_sk_get_local_ip (GF_Socket *sock, char *buffer) |
| get local IP | |
| GF_BitStream * | gf_bs_from_fd (int fd, u32 mode) |
| void | gf_net_close_capture () |
| static GF_Err | gf_netcap_record (GF_NetcapFilter *nf) |
| static void | gf_netcap_load_pck_gpac (GF_NetcapFilter *nf) |
| static GF_Err | pcapng_load_shb (GF_NetcapFilter *nf, Bool is_init) |
| static void | pcapng_load_idb (GF_NetcapFilter *nf) |
| static void | gf_netcap_load_pck_pcap (GF_NetcapFilter *nf) |
| static GF_Err | gf_netcap_playback (GF_NetcapFilter *nf) |
| GF_Err | gf_netcap_setup (char *rules) |
| static Bool | netcap_filter_pck (GF_Socket *sock, u32 pck_len, Bool for_send) |
| static void | gf_netcap_load_pck (GF_NetcapFilter *nf, u64 now) |
| static GF_Err | gf_netcap_send_pcap (GF_NetcapFilter *nf, GF_Socket *sock, const u8 *buffer, u32 length, u32 *written, Bool is_ng) |
| static GF_Err | gf_netcap_send_gpac (GF_NetcapFilter *nf, GF_Socket *sock, const u8 *buffer, u32 length, u32 *written) |
| static GF_Err | gf_netcap_send (GF_Socket *sock, const u8 *buffer, u32 length, u32 *written) |
| Bool | gf_sk_has_nrt_netcap (GF_Socket *sk) |
| GF_EXPORT GF_Socket * | gf_sk_new_ex (u32 SocketType, const char *netcap_id) |
| socket constructor | |
| GF_EXPORT GF_Socket * | gf_sk_new (u32 SocketType) |
| socket constructor | |
| GF_EXPORT GF_Err | gf_sk_set_buffer_size (GF_Socket *sock, Bool SendBuffer, u32 NewSize) |
| socket buffer size control | |
| GF_EXPORT GF_Err | gf_sk_set_block_mode (GF_Socket *sock, Bool NonBlockingOn) |
| blocking mode control | |
| static void | gf_sk_free (GF_Socket *sock) |
| GF_EXPORT void | gf_sk_del (GF_Socket *sock) |
| socket destructor | |
| GF_EXPORT void | gf_sk_reset (GF_Socket *sock) |
| reset internal buffer | |
| GF_EXPORT s32 | gf_sk_get_handle (GF_Socket *sock) |
| gets socket handle | |
| GF_EXPORT void | gf_sk_set_usec_wait (GF_Socket *sock, u32 usec_wait) |
| static u32 | inet_addr_from_name (const char *local_interface) |
| GF_Err | gf_sk_connect_ex (GF_Socket *sock, const char *PeerName, u16 PortNumber, const char *ifce_ip_or_name, Bool use_udp_connect) |
| GF_EXPORT GF_Err | gf_sk_connect (GF_Socket *sock, const char *PeerName, u16 PortNumber, const char *ifce_ip_or_name) |
| connects a socket | |
| GF_EXPORT GF_Err | gf_sk_bind_ex (GF_Socket *sock, const char *ifce_ip_or_name, u16 port, const char *peer_name, u16 peer_port, u32 options, u8 **dst_sock_addr, u32 *dst_sock_addr_len, u8 **src_sock_addr, u32 *src_sock_addr_len) |
| GF_EXPORT GF_Err | gf_sk_bind (GF_Socket *sock, const char *ifce_ip_or_name, u16 port, const char *peer_name, u16 peer_port, u32 options) |
| socket binding | |
| static GF_Err | poll_select (GF_Socket *sock, GF_SockSelectMode mode, u32 usec, Bool force_select) |
| static GF_Err | gf_sk_send_internal (GF_Socket *sock, const u8 *buffer, u32 length, const u8 *address, u32 address_len, u32 *written) |
| GF_EXPORT GF_Err | gf_sk_send_ex (GF_Socket *sock, const u8 *buffer, u32 length, u32 *written) |
| data emission | |
| GF_EXPORT GF_Err | gf_sk_send (GF_Socket *sock, const u8 *buffer, u32 length) |
| data emission | |
| GF_EXPORT GF_Err | gf_sk_send_to (GF_Socket *sock, const u8 *buffer, u32 length, const u8 *addr, u32 addr_len, u32 *written) |
| GF_Err | gf_sk_select (GF_Socket *sock, GF_SockSelectMode mode) |
| GF_EXPORT u32 | gf_sk_is_multicast_address (const char *multi_IPAdd) |
| multicast address test | |
| static GF_Err | sk_join_ipv4 (GF_Socket *sock, struct ip_mreq *M_req, u32 TTL, const char **src_ip_inc, u32 nb_src_ip_inc, const char **src_ip_exc, u32 nb_src_ip_exc) |
| GF_EXPORT Bool | gf_net_enum_interfaces (gf_net_ifce_enum do_enum, void *enum_cbk) |
| enumerate network interfaces | |
| static Bool | get_ifce_enum (void *cbk, const char *name, const char *IP, u32 flags) |
| Bool | gf_net_get_adapter_ip (const char *ip_or_name, char **ipv4, char **ipv6) |
| GF_EXPORT GF_Err | gf_sk_setup_multicast_ex (GF_Socket *sock, const char *multi_IPAdd, u16 MultiPortNumber, u32 TTL, Bool NoBind, const char *ifce_ip_or_name, const char **src_ip_inc, u32 nb_src_ip_inc, const char **src_ip_exc, u32 nb_src_ip_exc) |
| source-specific multicast setup | |
| GF_EXPORT GF_Err | gf_sk_setup_multicast (GF_Socket *sock, const char *multi_IPAdd, u16 MultiPortNumber, u32 TTL, Bool NoBind, const char *ifce_ip_or_name) |
| multicast setup | |
| GF_SockGroup * | gf_sk_group_new () |
| void | gf_sk_group_del (GF_SockGroup *sg) |
| void | gf_sk_group_register (GF_SockGroup *sg, GF_Socket *sk) |
| void | gf_sk_group_unregister (GF_SockGroup *sg, GF_Socket *sk) |
| GF_Err | gf_sk_group_select (GF_SockGroup *sg, u32 usec_wait, GF_SockSelectMode mode) |
| Bool | gf_sk_group_sock_is_set (GF_SockGroup *sg, GF_Socket *sk, GF_SockSelectMode mode) |
| GF_Err | gf_sk_receive_internal (GF_Socket *sock, char *buffer, u32 length, u32 *BytesRead, Bool do_select) |
| GF_EXPORT GF_Err | gf_sk_receive (GF_Socket *sock, u8 *buffer, u32 length, u32 *BytesRead) |
| data reception | |
| GF_EXPORT GF_Err | gf_sk_receive_no_select (GF_Socket *sock, u8 *buffer, u32 length, u32 *BytesRead) |
| GF_EXPORT GF_Err | gf_sk_listen (GF_Socket *sock, u32 MaxConnection) |
| socket listening | |
| GF_EXPORT GF_Err | gf_sk_accept (GF_Socket *sock, GF_Socket **newConnection) |
| socket accept | |
| GF_EXPORT GF_Err | gf_sk_get_local_info (GF_Socket *sock, u16 *Port, u32 *Familly) |
| get local info | |
| GF_EXPORT GF_Err | gf_sk_server_mode (GF_Socket *sock, Bool serverOn) |
| server socket mode | |
| GF_EXPORT GF_Err | gf_sk_get_remote_address_port (GF_Socket *sock, char *buf, u32 *port) |
| get remote address | |
| GF_EXPORT GF_Err | gf_sk_get_remote_address (GF_Socket *sock, char *buf) |
| get remote address | |
| const u8 * | gf_sk_get_address (GF_Socket *sock, u32 *addr_size) |
| GF_EXPORT GF_Err | gf_sk_probe (GF_Socket *sock) |
| GF_EXPORT char * | gf_net_bump_ip_address (const char *in_ip, u32 increment) |
| GF_EXPORT GF_Err | gf_net_reload_netcap () |
| reloads netcap filters | |
| GF_EXPORT u32 | gf_htonl (u32 val) |
| GF_EXPORT u32 | gf_ntohl (u32 val) |
| GF_EXPORT u16 | gf_htons (u16 val) |
| GF_EXPORT u16 | gf_ntohs (u16 val) |
| GF_EXPORT const char * | gf_errno_str (int errnoval) |
| error code description | |
Variables | |
| u16 | first_tcp_port =30000 |
| static GF_List * | netcap_filters =NULL |
| Bool | gpac_use_poll =GF_TRUE |
| struct NetCapInfo |
| struct __tag_socket |
abstracted socket object
The abstracted socket object allows you to build client and server applications very simply with support for unicast and multicast Available tools are socket and socket groups and some helper functions for network time
Collaboration diagram for GF_Socket:| Data Fields | ||
|---|---|---|
| u32 | flags | |
| SOCKET | socket | |
| struct sockaddr_in | dest_addr | |
| u32 | dest_addr_len | |
| u32 | usec_wait | |
| NetCapInfo * | cap_info | |
| struct NetFilterRule |
| struct __netcap_filter |
| Data Fields | ||
|---|---|---|
| char * | id | |
| char * | src | |
| char * | dst | |
| s32 | loops | |
| Bool | rt | |
| GF_List * | rules | |
| u32 | nb_rules | |
| u32 | nb_reloads | |
| GF_BitStream * | cap_bs | |
| GF_List * | read_socks | |
| GF_Socket * | read_sock_selected | |
| FILE * | file | |
| int | fd | |
| u64 | init_time | |
| Bool | is_eos | |
| u64 | pck_start_offset | |
| s32 | pck_len | |
| u8 | pck_flags | |
| u64 | pck_time | |
| u16 | dst_port | |
| u32 | dst_v4 | |
| bin128 | dst_v6 | |
| u16 | src_port | |
| u32 | src_v4 | |
| bin128 | src_v6 | |
| u32 | cap_mode | |
| Bool | pcap_le | |
| Bool | pcap_nano | |
| u32 | pcap_num_interfaces | |
| u32 | link_types[20] | |
| u32 | pcapng_trail | |
| u32 | pcap_trail | |
| u32 | pck_idx_r | |
| u32 | pck_idx_w | |
| u32 | next_pck_range | |
| u32 | next_rand | |
| u32 | reorder_max_pck | |
| u32 | reorder_nb_pck | |
| u32 | delay_nb_pck | |
| u64 | reorder_seek_pos | |
| u64 | reorder_resume_pos | |
| struct __tag_sock_group |
| #define INADDR_NONE ((unsigned long)-1) |
| #define SOCKET_INVALID | ( | _s | ) | (_s<0) |
| #define INVALID_SOCKET -1 |
| #define SOCKET_ERROR -1 |
| #define LASTSOCKERROR errno |
| #define closesocket | ( | v | ) | close(v) |
| #define my_inet_ntop inet_ntop |
| #define SSO_CAST (const char *) |
| #define SKIP_PCAP_PCK |
| #define sock_close | ( | _s | ) |
| #define gf_gethostbyname gethostbyname |
| anonymous enum |
| anonymous enum |
|
static |
Here is the call graph for this function:
Here is the caller graph for this function:| GF_BitStream * gf_bs_from_fd | ( | int | fd, |
| u32 | mode | ||
| ) |
Here is the caller graph for this function:| void gf_net_close_capture | ( | ) |
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Here is the call graph for this function:
Here is the caller graph for this function:
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Here is the call graph for this function:
Here is the caller graph for this function:| GF_Err gf_netcap_setup | ( | char * | rules | ) |
Here is the call graph for this function:
Here is the caller graph for this function:
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Here is the call graph for this function:
Here is the caller graph for this function:| Bool gf_sk_has_nrt_netcap | ( | GF_Socket * | sk | ) |
Here is the caller graph for this function:
|
static |
Here is the caller graph for this function:
|
static |
Here is the call graph for this function:
Here is the caller graph for this function:| GF_Err gf_sk_connect_ex | ( | GF_Socket * | sock, |
| const char * | PeerName, | ||
| u16 | PortNumber, | ||
| const char * | ifce_ip_or_name, | ||
| Bool | use_udp_connect | ||
| ) |
Here is the call graph for this function:
Here is the caller graph for this function:| GF_EXPORT GF_Err gf_sk_bind_ex | ( | GF_Socket * | sock, |
| const char * | ifce_ip_or_name, | ||
| u16 | port, | ||
| const char * | peer_name, | ||
| u16 | peer_port, | ||
| u32 | options, | ||
| u8 ** | dst_sock_addr, | ||
| u32 * | dst_sock_addr_len, | ||
| u8 ** | src_sock_addr, | ||
| u32 * | src_sock_addr_len | ||
| ) |
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Here is the call graph for this function:
Here is the caller graph for this function:| GF_EXPORT GF_Err gf_sk_send_to | ( | GF_Socket * | sock, |
| const u8 * | buffer, | ||
| u32 | length, | ||
| const u8 * | addr, | ||
| u32 | addr_len, | ||
| u32 * | written | ||
| ) |
Here is the call graph for this function:
|
static |
Here is the call graph for this function:
Here is the caller graph for this function:
Here is the call graph for this function:
Here is the caller graph for this function:| GF_Err gf_sk_receive_internal | ( | GF_Socket * | sock, |
| char * | buffer, | ||
| u32 | length, | ||
| u32 * | BytesRead, | ||
| Bool | do_select | ||
| ) |
Here is the call graph for this function:
Here is the caller graph for this function:| u16 first_tcp_port =30000 |
|
static |