|
SWILIB API (ELKA)
|
GPRS related functions.
See GprsD.elf sources for more info.
Usage: #include <swilib.h> or #include <swilib/gprs.h>
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... | |
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. | |
| struct REGSOCKCEPID_DATA |
| struct LMAN_SOCKET_REG |
| struct LMAN_CONTEXT |
| struct LMAN_SOCKET_DESTINATION |
| struct ENIP_SOCKET_DESTINATION |
| struct ENIP_ZDLL_ITEM |
| struct ENIP_ZDLL_HEAD |
| struct ENIP_MODULE |
| struct ENIP_PORT |
| struct ENIP_PKT |
| struct ENIP_TIMER |
| struct ENIP_NSAPI_MODULE |
| struct ENIP_IP_DRIVER |
| struct ENIP_IPH_INTERFACE |
| struct CTX_NAPDEF |
| struct NAP_PARAM_CONT |
| struct LMAN_DATA |
| typedef struct LMAN_SOCKET_DESTINATION LMAN_SOCKET_DESTINATION |
| typedef struct ENIP_SOCKET_DESTINATION ENIP_SOCKET_DESTINATION |
| typedef struct ENIP_SOCKET ENIP_SOCKET |
| enum LmanEventID |
| enum EnipEventID |
| 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.
| enable | 1 or 0 |
| unk | set to 1 |
| int GetCurrentGPRSProfile | ( | void | ) |
Get an ID of the active internet profile.
| int SetCurrentGPRSProfile | ( | int | profile_id | ) |
Change current internet profile.
| profile_id | ID of the profile |
| int ActivateDialUpProfile | ( | uint32_t | cepid, |
| int | profile_id ) |
Activate internet profile.
| cepid | current CEPID, use GBS_GetCurCepid |
| profile_id | GPRS profile ID, use GetCurrentGPRSProfile |
| void RegisterCepIdForCurProfile | ( | uint32_t | cepid, |
| int | profile_id, | ||
| uint32_t | is_gprs ) |
Register CEPID for internet profile.
| cepid | current CEPID, use GBS_GetCurCepid |
| profile_id | GPRS profile ID, use GetCurrentGPRSProfile |
| is_gprs | connection type, 1: GPRS, 0: CSD |
| int GetDisconnectTime | ( | void | ) |
Get internet connection timeout for disconnect when there is no activity.
| int RegisterCepidForSocketWork | ( | REGSOCKCEPID_DATA * | reg | ) |
Register current CEPID for sockets.
| reg | pointer to the REGSOCKCEPID_DATA |
| int RequestLMANConnect | ( | LMAN_DATA * | data | ) |
Connect to the GPRS.
| data | pointer to the LMAN_DATA |
| int RequestLMANDisconnect | ( | const uint8_t * | req | ) |
Request disconnection of a native LMAN context.
| req | two request bytes: context ID, then disconnect cause |
| unsigned GetSocketRegIndex | ( | unsigned | cepid | ) |
Find the socket-registration slot for a CEPID.
| cepid | GBS process identifier |
| unsigned GetServiceCepid | ( | unsigned | service | ) |
Get the process identifier assigned to a native service.
| service | firmware service index; 3 selects the Java service |
| unsigned LMAN_AllocContext | ( | unsigned | bearer, |
| uint8_t | type ) |
Allocate a native LMAN context.
| bearer | native bearer kind; 1 selects GPRS |
| type | context subtype |
| void LMAN_SetProfile | ( | unsigned | cid, |
| const CTX_NAPDEF * | profile ) |
Copy a NAP profile into an allocated LMAN context.
| cid | context index 0..7 |
| profile | profile with a terminated name and native bearer settings |
| void LMAN_SetRef | ( | unsigned | reg_index, |
| unsigned | cid, | ||
| int | on ) |
Attach or detach a registered process from an LMAN context.
| reg_index | socket-registration index 0..13 |
| cid | context index 0..7 |
| on | 1 to attach, 0 to detach |
| void LMAN_SetState | ( | unsigned | cid, |
| int | state ) |
Change a native LMAN context state and notify its registered owners.
| cid | context index 0..7 |
| state | native state value; 4 means connected |
| void LMAN_FreeContext | ( | unsigned | cid | ) |
Reset and release a native LMAN context without disconnecting a physical bearer.
| cid | context index 0..7 |
| 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.
| id | object ID, 0x17: preferences, 0x18: network policy |
| int WSP_ReadProperty | ( | const char * | key, |
| void * | value, | ||
| unsigned * | length ) |
Read a WSP property.
| key | property name |
| value | output buffer |
| length | buffer size, receives the value length |
| uint8_t WSP_GetConnectionState | ( | int | bearer, |
| int | nap ) |
Get the WSP connection state.
| bearer | bearer ID |
| nap | NAP profile ID |
| 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).
| module | module object, filled by the firmware |
| name | module name |
| up | called when the module goes up |
| down | called when the module goes down |
| run | module run callback |
| notify | event callback (module, event) |
| post_run | called after run |
| packet_available | called when a packet is queued on the module port |
| uint8_t ENIP_ModuleRun | ( | ENIP_MODULE * | module, |
| uint32_t * | result ) |
Run an ENIP network module once.
Call from the ENIP process.
| module | module object | |
| [out] | result | run result |
| int ENIP_ModuleUp | ( | ENIP_MODULE * | module | ) |
Bring an ENIP network module up.
| module | module object |
| void ENIP_ModuleDown | ( | ENIP_MODULE * | module, |
| uint32_t | reason ) |
Bring an ENIP network module down.
| module | module object |
| reason | reason code, 0: normal |
| void ENIP_PortInit | ( | ENIP_PORT * | port, |
| ENIP_MODULE * | module ) |
Initialize the packet port of an ENIP network module.
| port | port object inside the module |
| module | owning module |
Queue a packet on an ENIP port.
The port takes ownership of the packet.
| port | destination port |
| packet | packet from ENIP_PacketAlloc |
| ENIP_PKT * ENIP_PacketAlloc | ( | ENIP_MODULE * | module, |
| int | size, | ||
| uint32_t | pool, | ||
| int | offset, | ||
| int | quota ) |
Allocate an ENIP packet.
| module | owning module |
| size | buffer size |
| pool | buffer pool |
| offset | data offset in the buffer |
| quota | allocation quota (ignored on SG/X75) |
| void ENIP_PacketFree | ( | ENIP_PKT * | packet | ) |
Free an ENIP packet.
| packet | packet from ENIP_PacketAlloc |
| int ENIP_RegisterDriver | ( | ENIP_IP_DRIVER * | driver, |
| int | flags ) |
Register an IP driver (network interface) in the ENIP IP layer.
| driver | driver object: ports, addresses, DNS, MTU, bearer and interface index |
| flags | 0 (ignored on SG/X75) |
| void ENIP_UnregisterDriver | ( | ENIP_MODULE * | module | ) |
Unregister the IP driver of an ENIP network module.
| module | module of the registered driver |
| ENIP_IPH_INTERFACE * ENIP_FindInterface | ( | uint32_t | bearer, |
| uint16_t | iface ) |
Find the IP interface of a bearer.
| bearer | bearer ID |
| iface | interface index |
| void LMAN_AttachInterface | ( | unsigned | cid, |
| unsigned | iface, | ||
| unsigned | unk ) |
Attach an IP interface to a native LMAN context.
| cid | context ID from LMAN_AllocContext |
| iface | interface index |
| unk | 0xFFFF |
| void * zDLL_RemHead | ( | ENIP_ZDLL_HEAD * | list | ) |
Remove the first item of an ENIP list (packet queue).
| list | list head |
| 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.
| module | ENIP module |
| void enip_module_nsapi_post_init | ( | ENIP_NSAPI_MODULE * | module | ) |
Reset the per-context fields of an NSAPI module after enip_nsapi_init_module.
| module | NSAPI module |
Append a packet to an ENIP port's queue and schedule the port's module if the queue was empty.
| port | ENIP port |
| packet | ENIP packet |
| void * enip_memory_allocate | ( | uint32_t | unused, |
| int | size ) |
Allocate memory from the ENIP pool, falling back to the second ENIP pool.
| unused | not read by the function |
| size | size in bytes |
| void enip_memory_release | ( | void * | block | ) |
Release a block allocated with enip_memory_allocate.
NULL is a fatal error.
| block | memory block |
| 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.
| post_run | post-run procedure of the IP module (see ENIP_MODULE) |
| 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.
| driver | ENIP IP driver |
Fill the IPv4 header checksum of a packet, set its size and send it to a port.
| port | pointer to the destination ENIP port pointer |
| packet | ENIP packet with an IPv4 header at its data |
| size | packet size in bytes |
| 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.
| seed | checksum of preceding data, 0 to start |
| data | data, summed as big-endian 16-bit words |
| size | size in bytes |
| 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.
| socket | ENIP socket |
| 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.
| packet | ENIP packet |
| 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.
| iface | receiving IP interface |
| packet | ENIP packet with the fragment |
| header | IPv4 header of the fragment |
| total_size | IPv4 total length |
| header_size | IPv4 header length |
| fragment | IPv4 flags and fragment offset field |
| source | value matched against the slot owner (probably the source address) |
| 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.
| slot | reassembly slot |
| void enip_iph_run | ( | ENIP_MODULE * | module | ) |
Run procedure of the IP module: expire socket timers and handle queued packets.
| module | IP module |
Send a packet from the IP layer: fill the header checksum and pass it to the port.
| port | pointer to the destination ENIP port pointer |
| packet | ENIP packet, NULL only runs the pending output |
| size | packet size in bytes |
| 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".
| iface | receiving IP interface |
| packet | ENIP packet |
| ENIP_IPH_INTERFACE * enip_siph_find_IF | ( | int | address | ) |
Find the IP interface with the given local address.
| address | local IPv4 address, network byte order |
| void enip_icmp_frame_read | ( | ENIP_IPH_INTERFACE * | iface, |
| ENIP_PKT * | packet ) |
Process a received ICMP packet and release it.
Replies to echo requests (type 8) and handles destination unreachable messages (type 3); other types are dropped.
| iface | receiving IP interface |
| packet | ENIP packet, data at the ICMP header |
| 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.
| iface | receiving IP interface |
| packet | ENIP packet, data at the UDP header |
| int enip_init_csd_iface | ( | ENIP_MODULE * | module, |
| ENIP_IP_DRIVER * | driver ) |
Fill an IP driver description for the CSD (PPP dial-up) interface.
| module | CSD module |
| driver | ENIP IP driver to fill |
| int enip_nsapi_init_iface | ( | ENIP_NSAPI_MODULE * | module | ) |
Create and register the IP interface of a PDP context (NSAPI module).
| module | NSAPI module |
| int enip_nsapi_init_module | ( | ENIP_NSAPI_MODULE * | module | ) |
Initialise an NSAPI (PDP context) module named "NSAPI".
| module | NSAPI module |
| void ENIP_PDP_NET_UP_CNF | ( | uint16_t | context, |
| int | result ) |
ENIP handler of the PDP NET_UP confirmation.
| context | PDP context index |
| result | 1: OK |
| void ENIP_PDP_NET_UP_REJ_IND | ( | uint16_t | context, |
| int | result ) |
ENIP handler of the PDP NET_UP reject indication.
| context | PDP context index |
| result | meaning not known; 1 releases the context |
| 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.
| context | PDP context index |
| mode | meaning not known (0 and 1 handled differently) |
| 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.
| context | PDP context index |
| mode | meaning not known (0: create the interface) |
| void ENIP_PDP_STOP_REQ | ( | uint16_t | context, |
| int | mode ) |
ENIP handler of the PDP stop request.
| context | PDP context index |
| mode | meaning not known (0 and 1 handled differently) |
| 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.
| bearer | meaning not known (selects one of two interface types) |
| 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.
| family | 1: IPv4 | |
| type | 0: datagram, 1: stream | |
| protocol | 0, 17 (UDP) or 6 (TCP) | |
| [out] | socket_id | receives the socket ID, must not be NULL |
| param | passed to enip_sockh_create_internal; meaning not known | |
| destination | socket destination |
| 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.
| socket | socket ID |
| address | peer IPv4 address, network byte order |
| unknown | meaning not known |
| port | peer port, network byte order |
| timeout | TCP connect timeout |
| void enip_sockh_IF_init | ( | ENIP_IPH_INTERFACE * | iface | ) |
Pick a pseudo-random first local port for an interface.
| iface | IP 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.
| family | 1: IPv4 | |
| type | 0: datagram, 1: stream | |
| protocol | 17 (UDP) or 6 (TCP) | |
| [out] | socket_id | receives the socket ID |
| param1 | meaning not known | |
| param2 | meaning not known |
| 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.
| socket | ENIP socket |
| address | peer IPv4 address, 0 or -1 for none |
| 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.
| socket | ENIP socket bound to an interface |
| size | payload size in bytes |
| pool | buffer pool (see ENIP_PacketAlloc) |
| packet | receives the ENIP packet |
| timeout | meaning not known |
| int enip_sockh_dgram_connect | ( | ENIP_SOCKET * | socket, |
| int | address, | ||
| uint32_t | unused, | ||
| uint16_t | port ) |
Set the peer of a datagram socket.
| socket | ENIP socket |
| address | peer IPv4 address, network byte order |
| unused | not read by the function |
| port | peer port, network byte order |
| 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.
| iface | receiving IP interface |
| header | IPv4 header |
| 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.
| index | index of the outgoing packet in the firmware's table |
| socket | ENIP socket |
| address | destination IPv4 address, network byte order |
| 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).
| socket | ENIP socket |
| int enip_tcph_sock_init | ( | ENIP_SOCKET * | socket | ) |
Initialise the TCP state of a socket: initial sequence number, windows and MSS.
| socket | ENIP socket bound to an interface |
| 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.
| socket | ENIP socket |
| address | peer IPv4 address, network byte order |
| unknown | meaning not known |
| port | peer port, network byte order |
| timeout | connect timeout, 0 for the default |
| 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.
| socket | ENIP socket |
| flags | TCP flags (2: SYN) |
| data | payload or NULL |
| size | payload size in bytes |
| packet | preallocated ENIP packet or NULL |
| unknown | meaning not known |
| 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.
Only partly reversed.
| socket | ENIP socket |
| packet | ENIP packet with the IPv4 and TCP headers |
| use_sequence | nonzero: keep the sequence number of the segment (retransmission), 0: take it from the socket |
| void enip_tcph_change_sock_state | ( | ENIP_SOCKET * | socket, |
| uint32_t | state ) |
Change the TCP state of a socket and notify its owner.
| socket | ENIP socket |
| state | new state in firmware numbering (0: closed, 8: SYN sent, 10: established) |
| void enip_tcph_frame_read | ( | ENIP_IPH_INTERFACE * | iface, |
| ENIP_PKT * | packet ) |
Process a received TCP segment.
| iface | receiving IP interface |
| packet | ENIP packet |
| 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.
| socket | ENIP socket |
| count | maximum number of blocks |
| option | output buffer |
| void enip_tcph_update_SACK_block_list | ( | ENIP_SOCKET * | socket | ) |
Remove the SACK blocks that are already acknowledged.
| socket | ENIP socket |
| void enip_timer_init | ( | ENIP_TIMER * | timer, |
| ENIP_MODULE * | module ) |
Initialise an ENIP timer.
| timer | timer |
| module | ENIP module whose timer list it will use |
| void enip_timer_cancel | ( | ENIP_TIMER * | timer | ) |
Stop an ENIP timer if it is running.
| timer | timer |
| void enip_timer_start | ( | ENIP_TIMER * | timer, |
| uint32_t | timeout ) |
Start or restart an ENIP timer and schedule its module.
| timer | timer |
| timeout | timeout |
| 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).
| index | registration index |
| uint16_t LMAN_FindContext | ( | uint16_t | bearer, |
| uint16_t | iface ) |
Find the LMAN context with the given bearer ID and interface.
| bearer | bearer ID (see LMAN_AllocContext) |
| iface | interface index (see LMAN_AttachInterface) |
| uint8_t LMAN_GetBearerIdForCi | ( | uint16_t | cid | ) |
Get the bearer ID of an LMAN context.
| cid | context index 0..7 |
| 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.
| cepid | process ID |
| destination | receives the destination |
| void zDLL_Init | ( | ENIP_ZDLL_HEAD * | list | ) |
Initialise an empty ENIP double-linked list (two pointers: first, last).
| list | list head |
| const char * RamActiveGPRSProfileName | ( | void | ) |
Get name of the current internet profile.
| void RefreshGPRSTraffic | ( | ) |
Refresh the GPRS traffic counter.
| void ResetGPRSTraffic | ( | void | ) |
Reset the GPRS traffic counter.
| int * GetGPRSTrafficPointer | ( | ) |
| unsigned LMAN_GetOrAllocSocketRegIndex | ( | unsigned | cepid | ) |
Find the LMAN socket registration (see RamSocketRegs) of a process or take a free one.
| cepid | CEPID of the process |
| 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.
| index | registration index 0..13 (see LMAN_GetOrAllocSocketRegIndex); larger values raise a firmware assertion |
| reg | registration data, the first field must be below 800 |
| keep | nonzero: keep the registration when the process releases its last context; 0 leaves this flag unchanged |