SWILIB API (NSG)    
Loading...
Searching...
No Matches
gprs.h File Reference
#include "base.h"

Go to the source code of this file.

Data Structures

struct  REGSOCKCEPID_DATA
 CEPID registration data for sockets. More...
 
struct  LMAN_SOCKET_REG
 LMAN socket registration of a process (see RamSocketRegs). More...
 
struct  LMAN_CONTEXT
 LMAN context (see RamLmanContexts). More...
 
struct  LMAN_SOCKET_DESTINATION
 Where sockets of a process go (see LMAN_GetSocketDestination). More...
 
struct  ENIP_SOCKET_DESTINATION
 Socket destination passed to enip_sock_create. More...
 
struct  ENIP_ZDLL_ITEM
 ENIP list item, the first field of a listed object. More...
 
struct  ENIP_ZDLL_HEAD
 ENIP list (see zDLL_Init). More...
 
struct  ENIP_MODULE
 ENIP network module (see ENIP_ModuleInit). More...
 
struct  ENIP_PORT
 ENIP port: packet input of a module (see ENIP_PortInit). More...
 
struct  ENIP_PKT
 ENIP packet header (see ENIP_PacketAlloc). More...
 
struct  ENIP_TIMER
 ENIP timer (see enip_timer_init). More...
 
struct  ENIP_NSAPI_MODULE
 ENIP NSAPI module (see enip_nsapi_init_module). More...
 
struct  ENIP_IP_DRIVER
 ENIP IP driver: the network side of an interface (see ENIP_RegisterDriver). More...
 
struct  ENIP_IPH_INTERFACE
 ENIP IP interface: a registered driver (see ENIP_FindInterface). More...
 
struct  CTX_NAPDEF
 Network Access Point data. More...
 
struct  NAP_PARAM_CONT
 Network Access Point data container. More...
 
struct  LMAN_DATA
 LinkManager data. More...
 

Typedefs

typedef struct REGSOCKCEPID_DATA REGSOCKCEPID_DATA
 
typedef struct CTX_NAPDEF CTX_NAPDEF
 
typedef struct NAP_PARAM_CONT NAP_PARAM_CONT
 
typedef struct LMAN_DATA LMAN_DATA
 
typedef struct LMAN_SOCKET_REG LMAN_SOCKET_REG
 
typedef struct LMAN_CONTEXT LMAN_CONTEXT
 
typedef struct LMAN_SOCKET_DESTINATION LMAN_SOCKET_DESTINATION
 
typedef struct ENIP_ZDLL_ITEM ENIP_ZDLL_ITEM
 
typedef struct ENIP_ZDLL_HEAD ENIP_ZDLL_HEAD
 
typedef struct ENIP_MODULE ENIP_MODULE
 
typedef struct ENIP_PORT ENIP_PORT
 
typedef struct ENIP_PKT ENIP_PKT
 
typedef struct ENIP_TIMER ENIP_TIMER
 
typedef struct ENIP_NSAPI_MODULE ENIP_NSAPI_MODULE
 
typedef struct ENIP_IP_DRIVER ENIP_IP_DRIVER
 
typedef struct ENIP_IPH_INTERFACE ENIP_IPH_INTERFACE
 
typedef struct ENIP_SOCKET_DESTINATION ENIP_SOCKET_DESTINATION
 
typedef struct ENIP_SOCKET ENIP_SOCKET
 ENIP socket.
 

Enumerations

enum  LmanEventID {
  LMAN_CONNECT_CNF = 0x80 ,
  LMAN_CONNECT_REJ_IND = 0x81 ,
  LMAN_DISCONNECT_IND = 0x82 ,
  LMAN_DISCONNECT_CNF = 0x84 ,
  LMAN_LINK_UP_IND = 0x89
}
 LinkManager GBS events. More...
 
enum  EnipEventID {
  ENIP_BUFFER_FREE = 0x8A ,
  ENIP_BUFFER_FREE1 = 0x8B ,
  ENIP_SOCK_DATA_READ = 0x8C ,
  ENIP_SOCK_CONNECTED = 0x8D ,
  ENIP_SOCK_CLOSED = 0x8E ,
  ENIP_SOCK_REMOTE_CLOSED = 0x8F ,
  ENIP_SOCK_ACCEPTED = 0x90 ,
  ENIP_SOCK_ICMP_ERROR = 0x91 ,
  ENIP_DNR_HOST_BY_NAME = 0x94
}
 ENIP GBS events. More...
 

Functions

General functions
char IsGPRSEnabled (void)
 Check if GPRS enabled.
 
char IsGPRSAvailable (void)
 Check if GPRS available in the current network.
 
char IsEDGEAvailable (void)
 Check if EDGE is available in the current network.
 
char IsGPRSConnected (void)
 Check if the GPRS session is established.
 
void GPRS_OnOff (int enable, int unk)
 Enable or disable GPRS internet.
 
int GetCurrentGPRSProfile (void)
 Get an ID of the active internet profile.
 
int SetCurrentGPRSProfile (int profile_id)
 Change current internet profile.
 
SGOLD-only functions
int ActivateDialUpProfile (uint32_t cepid, int profile_id)
 Activate internet profile.
 
void RegisterCepIdForCurProfile (uint32_t cepid, int profile_id, uint32_t is_gprs)
 Register CEPID for internet profile.
 
int GetDisconnectTime (void)
 Get internet connection timeout for disconnect when there is no activity.
 
NewSGOLD-only functions
int RegisterCepidForSocketWork (REGSOCKCEPID_DATA *reg)
 Register current CEPID for sockets.
 
int RequestLMANConnect (LMAN_DATA *data)
 Connect to the GPRS.
 
int RequestLMANDisconnect (const uint8_t *req)
 Request disconnection of a native LMAN context.
 
unsigned GetSocketRegIndex (unsigned cepid)
 Find the socket-registration slot for a CEPID.
 
unsigned GetServiceCepid (unsigned service)
 Get the process identifier assigned to a native service.
 
unsigned LMAN_AllocContext (unsigned bearer, uint8_t type)
 Allocate a native LMAN context.
 
void LMAN_SetProfile (unsigned cid, const CTX_NAPDEF *profile)
 Copy a NAP profile into an allocated LMAN context.
 
void LMAN_SetRef (unsigned reg_index, unsigned cid, int on)
 Attach or detach a registered process from an LMAN context.
 
void LMAN_SetState (unsigned cid, int state)
 Change a native LMAN context state and notify its registered owners.
 
void LMAN_FreeContext (unsigned cid)
 Reset and release a native LMAN context without disconnecting a physical bearer.
 
LMAN_CONTEXT * RamLmanContexts (void)
 Get the LMAN context table.
 
uint32_t * RamLmanRefs (void)
 Get the LMAN process-to-context reference table.
 
LMAN_SOCKET_REG * RamSocketRegs (void)
 Get the LMAN socket registration table.
 
void * WSP_GetObject (unsigned id)
 Get a WSP object.
 
int WSP_ReadProperty (const char *key, void *value, unsigned *length)
 Read a WSP property.
 
uint8_t WSP_GetConnectionState (int bearer, int nap)
 Get the WSP connection state.
 
void ENIP_ModuleInit (ENIP_MODULE *module, const char *name, int(*up)(ENIP_MODULE *module), void(*down)(ENIP_MODULE *module, uint32_t reason), void(*run)(ENIP_MODULE *module), void(*notify)(ENIP_MODULE *module, int event), void(*post_run)(ENIP_MODULE *module), void(*packet_available)(ENIP_MODULE *module, uint8_t pool))
 Initialize an ENIP network module (the driver side of a network interface).
 
uint8_t ENIP_ModuleRun (ENIP_MODULE *module, uint32_t *result)
 Run an ENIP network module once.
 
int ENIP_ModuleUp (ENIP_MODULE *module)
 Bring an ENIP network module up.
 
void ENIP_ModuleDown (ENIP_MODULE *module, uint32_t reason)
 Bring an ENIP network module down.
 
void ENIP_PortInit (ENIP_PORT *port, ENIP_MODULE *module)
 Initialize the packet port of an ENIP network module.
 
void ENIP_PortSend (ENIP_PORT *port, ENIP_PKT *packet)
 Queue a packet on an ENIP port.
 
ENIP_PKT * ENIP_PacketAlloc (ENIP_MODULE *module, int size, uint32_t pool, int offset, int quota)
 Allocate an ENIP packet.
 
void ENIP_PacketFree (ENIP_PKT *packet)
 Free an ENIP packet.
 
int ENIP_RegisterDriver (ENIP_IP_DRIVER *driver, int flags)
 Register an IP driver (network interface) in the ENIP IP layer.
 
void ENIP_UnregisterDriver (ENIP_MODULE *module)
 Unregister the IP driver of an ENIP network module.
 
ENIP_IPH_INTERFACE * ENIP_FindInterface (uint32_t bearer, uint16_t iface)
 Find the IP interface of a bearer.
 
void LMAN_AttachInterface (unsigned cid, unsigned iface, unsigned unk)
 Attach an IP interface to a native LMAN context.
 
void * zDLL_RemHead (ENIP_ZDLL_HEAD *list)
 Remove the first item of an ENIP list (packet queue).
 
ENIP_IP_DRIVER * RamPdpDrivers (void)
 Get the GPRS PDP driver table (the DNS resolver takes servers for bearer 1 from it).
 
void enip_module_post_run (ENIP_MODULE *module)
 Schedule a run of an ENIP module: mark it as needing a run and call its post-run procedure if one is set, the module is up and no run is already posted or in progress.
 
void enip_module_nsapi_post_init (ENIP_NSAPI_MODULE *module)
 Reset the per-context fields of an NSAPI module after enip_nsapi_init_module.
 
void enip_port_handle_pkt (ENIP_PORT *port, ENIP_PKT *packet)
 Append a packet to an ENIP port's queue and schedule the port's module if the queue was empty.
 
void * enip_memory_allocate (uint32_t unused, int size)
 Allocate memory from the ENIP pool, falling back to the second ENIP pool.
 
void enip_memory_release (void *block)
 Release a block allocated with enip_memory_allocate.
 
int enip_packet_max_size (void)
 Get the largest ENIP packet size (a firmware constant).
 
int enip_ip_init (void(*post_run)(ENIP_MODULE *module))
 Initialise the ENIP IP module, its interface slots (8 on NSG/ELKA, 16 on SG/X75) and the 2 reassembly slots.
 
ENIP_IPH_INTERFACE * enip_find_iface_by_driver (ENIP_IP_DRIVER *driver)
 Find the IP interface whose registered driver belongs to the same module as the given driver.
 
void enip_iph_calc_chk_and_port_send (ENIP_PORT **port, ENIP_PKT *packet, uint32_t size)
 Fill the IPv4 header checksum of a packet, set its size and send it to a port.
 
uint16_t enip_iph_compute_checksum (uint16_t seed, const void *data, uint16_t size)
 Compute the Internet (one's complement) checksum of a buffer.
 
ENIP_IPH_INTERFACE * enip_iph_find_IF_for_socket (ENIP_SOCKET *socket)
 Find the IP interface whose bearer ID and interface index equal the socket's LMAN destination.
 
void enip_iph_frame_read (ENIP_PKT *packet)
 Process a received IP packet: check the IPv4 header, find the interface, reassemble fragments and pass the packet to the protocol handler.
 
int enip_iph_manage_reassembly (ENIP_IPH_INTERFACE *iface, ENIP_PKT *packet, uint8_t *header, uint32_t total_size, uint32_t header_size, uint32_t fragment, int source)
 Add an IPv4 fragment to its reassembly slot.
 
void enip_iph_packet_avail (void)
 Notify the IP layer that a packet buffer is free again.
 
void enip_iph_rheader_init (void *slot)
 Reset an IPv4 reassembly slot and its timer.
 
void enip_iph_run (ENIP_MODULE *module)
 Run procedure of the IP module: expire socket timers and handle queued packets.
 
int enip_iph_write (ENIP_PORT **port, ENIP_PKT *packet, uint32_t size)
 Send a packet from the IP layer: fill the header checksum and pass it to the port.
 
int enip_siph_crypt_frame_read (ENIP_IPH_INTERFACE *iface, ENIP_PKT *packet)
 Receive handler of the secure IP layer: answers a special 8-byte ICMP probe (type 0x49, code 0x44, id 1) in place with "SCRN\3\0".
 
ENIP_IPH_INTERFACE * enip_siph_find_IF (int address)
 Find the IP interface with the given local address.
 
void enip_icmp_frame_read (ENIP_IPH_INTERFACE *iface, ENIP_PKT *packet)
 Process a received ICMP packet and release it.
 
void enip_udph_frame_read (ENIP_IPH_INTERFACE *iface, ENIP_PKT *packet)
 Process a received UDP packet: check it and queue it on the matching socket.
 
int enip_init_csd_iface (ENIP_MODULE *module, ENIP_IP_DRIVER *driver)
 Fill an IP driver description for the CSD (PPP dial-up) interface.
 
int enip_nsapi_init_iface (ENIP_NSAPI_MODULE *module)
 Create and register the IP interface of a PDP context (NSAPI module).
 
int enip_nsapi_init_module (ENIP_NSAPI_MODULE *module)
 Initialise an NSAPI (PDP context) module named "NSAPI".
 
void ENIP_PDP_NET_UP_CNF (uint16_t context, int result)
 ENIP handler of the PDP NET_UP confirmation.
 
void ENIP_PDP_NET_UP_REJ_IND (uint16_t context, int result)
 ENIP handler of the PDP NET_UP reject indication.
 
void ENIP_PDP_NET_DOWN_IND (uint16_t context, int mode)
 ENIP handler of the PDP NET_DOWN indication: take the context's interface down.
 
void ENIP_PDP_START_REQ (int context, int mode)
 ENIP handler of the PDP start request: initialise and bring up the context's NSAPI module.
 
void ENIP_PDP_STOP_REQ (uint16_t context, int mode)
 ENIP handler of the PDP stop request.
 
void ENIP_PDP_START_CSD_INT_REQ (int bearer)
 ENIP handler of the CSD (PPP dial-up) start request: set up the "PPP CSD" module.
 
int enip_sock_create (int family, int type, int protocol, int *socket_id, uint32_t param, const ENIP_SOCKET_DESTINATION *destination)
 Create an ENIP socket.
 
int enip_socket_connect (int socket, int address, int unknown, uint16_t port, uint32_t timeout)
 Connect a socket: set the peer of a datagram socket or start a TCP connection.
 
void enip_sockh_IF_init (ENIP_IPH_INTERFACE *iface)
 Pick a pseudo-random first local port for an interface.
 
ENIP_SOCKET * enip_sockh_create_internal (int family, int type, int protocol, int *socket_id, uint32_t param1, uint32_t param2)
 Allocate and initialise a socket in a free slot of the socket table.
 
int enip_sockh_autobind_IF (ENIP_SOCKET *socket, int address)
 Bind a socket to an IP interface: the one matching its LMAN destination, or the first usable one.
 
int enip_sockh_packet_allocate (ENIP_SOCKET *socket, uint32_t size, uint32_t pool, ENIP_PKT **packet, int timeout)
 Allocate an outgoing packet for a socket with room for the interface headers.
 
int enip_sockh_dgram_connect (ENIP_SOCKET *socket, int address, uint32_t unused, uint16_t port)
 Set the peer of a datagram socket.
 
ENIP_SOCKET * enip_sockh_from_ipheader (ENIP_IPH_INTERFACE *iface, const uint8_t *header)
 Find the socket for a received packet by protocol, ports and address.
 
int enip_sockh_prepare_send (int index, ENIP_SOCKET *socket, uint32_t address)
 Fill the IPv4 header of an outgoing packet from the socket's settings.
 
int enip_sockh_tcp_packet_allocate (ENIP_SOCKET *socket)
 Check that a TCP segment of the socket's maximum size can be allocated (allocates it and frees it at once).
 
int enip_tcph_sock_init (ENIP_SOCKET *socket)
 Initialise the TCP state of a socket: initial sequence number, windows and MSS.
 
int enip_tcph_sock_connect (ENIP_SOCKET *socket, int address, uint32_t unknown, uint16_t port, uint32_t timeout)
 Start a TCP connection: send SYN and start the connect timer.
 
int enip_tcph_send_segment (ENIP_SOCKET *socket, uint32_t flags, const void *data, uint32_t size, ENIP_PKT *packet, int unknown)
 Build and send one TCP segment.
 
void enip_tcph_write_segment (ENIP_SOCKET *socket, ENIP_PKT *packet, int use_sequence)
 Fill in the TCP header of an outgoing segment of the socket and send it.
 
void enip_tcph_change_sock_state (ENIP_SOCKET *socket, uint32_t state)
 Change the TCP state of a socket and notify its owner.
 
void enip_tcph_frame_read (ENIP_IPH_INTERFACE *iface, ENIP_PKT *packet)
 Process a received TCP segment.
 
void enip_tcph_run (void)
 Check the TCP timers of all sockets: retransmit, time out or move on in the close states.
 
uint32_t enip_tcph_get_SACK_option_from_list (ENIP_SOCKET *socket, uint32_t count, uint8_t *option)
 Write a TCP SACK option (NOP, NOP, SACK) from the socket's SACK blocks.
 
void enip_tcph_update_SACK_block_list (ENIP_SOCKET *socket)
 Remove the SACK blocks that are already acknowledged.
 
void enip_timer_init (ENIP_TIMER *timer, ENIP_MODULE *module)
 Initialise an ENIP timer.
 
void enip_timer_cancel (ENIP_TIMER *timer)
 Stop an ENIP timer if it is running.
 
void enip_timer_start (ENIP_TIMER *timer, uint32_t timeout)
 Start or restart an ENIP timer and schedule its module.
 
void LMAN_LINK_UP_CNF (void)
 LMAN handler of the link-up confirmation: mark the waiting connection as up and notify the owner.
 
void LMAN_FreeSocketReg (unsigned index)
 Free an LMAN socket registration (see RamSocketRegs).
 
uint16_t LMAN_FindContext (uint16_t bearer, uint16_t iface)
 Find the LMAN context with the given bearer ID and interface.
 
uint8_t LMAN_GetBearerIdForCi (uint16_t cid)
 Get the bearer ID of an LMAN context.
 
int LMAN_GetSocketDestination (uint16_t cepid, LMAN_SOCKET_DESTINATION *destination)
 Get where sockets of a process go: application flags, selector, bearer ID and interface index.
 
void zDLL_Init (ENIP_ZDLL_HEAD *list)
 Initialise an empty ENIP double-linked list (two pointers: first, last).
 
Profile
const char * RamActiveGPRSProfileName (void)
 Get name of the current internet profile.
 
Statistic
void RefreshGPRSTraffic ()
 Refresh the GPRS traffic counter.
 
void ResetGPRSTraffic (void)
 Reset the GPRS traffic counter.
 
int * GetGPRSTrafficPointer ()
 Get traffic used by GPRS.
 
unsigned LMAN_GetOrAllocSocketRegIndex (unsigned cepid)
 Find the LMAN socket registration (see RamSocketRegs) of a process or take a free one.
 
int LMAN_SetSocketReg (unsigned index, const REGSOCKCEPID_DATA *reg, int keep)
 Set the data of an LMAN socket registration, as RegisterCepidForSocketWork does for the current process.