298 void *native_profile;
493__swi_end(0x43F, LMAN_SetProfile, (cid, profile));
576uint8_t WSP_GetConnectionState(
int bearer,
int nap)
577__swi_end(0x44F, WSP_GetConnectionState, (bearer, nap));
595 void (*packet_available)(
ENIP_MODULE *module, uint8_t pool))
842 uint32_t header_size, uint32_t fragment,
int source)
1096__swi_end(0x497, enip_sockh_from_ipheader, (iface, header));
#define __swi_end(number, func, call)
#define __swi_begin(number)
uint16_t _0xFFFF
Set to 0xFFFF.
ENIP_ZDLL_HEAD packets
Queued packets.
void(* run)(ENIP_MODULE *module)
ENIP_ZDLL_ITEM item
In the port list of the module.
uint16_t selector
See REGSOCKCEPID_DATA.
ENIP_MODULE *void(* callback)(ENIP_PORT *port, ENIP_PKT *packet)
< Owning module
int keep
See LMAN_SetSocketReg.
void(* packet_available)(ENIP_MODULE *module, uint8_t pool)
ENIP_ZDLL_ITEM item
In the timer list of the module.
uint8_t state
Bits 7..6: 2 = up, 0 = down.
uint8_t bearer
See LMAN_AllocContext, 0xFF = free.
uint8_t * buffer
Start of the buffer.
ENIP_IP_DRIVER driver
Copy of the registered driver.
int(* up)(ENIP_MODULE *module)
uint16_t app_flags
See LMAN_SOCKET_DESTINATION.
uint8_t pool
Allocating pool.
uint16_t cepid
Process, 0xFFFF = free.
ENIP_PORT * ip_port
Input port of the IP layer.
char body[0x204]
Binary data of the NAP profile.
uint16_t _0x0000
Set to 0x0000.
uint32_t allocation_size
Buffer size.
uint8_t headroom
Bytes reserved before the IP header.
uint16_t iface
Interface index.
uint8_t * data
Current data.
uint8_t tailroom
Bytes reserved after the data.
uint16_t _0x0080
Set to 0x0080.
uint16_t unk_06
See LMAN_AttachInterface.
ENIP_MODULE ENIP_PORT port
uint16_t iface
See LMAN_AttachInterface.
uint16_t iface
Receiving interface index.
uint8_t bearer
See LMAN_SOCKET_DESTINATION.
uint16_t selector
See LMAN_SOCKET_DESTINATION.
uint16_t app_flags
See REGSOCKCEPID_DATA.
uint8_t * transport
Transport header, set by the IP layer.
ENIP_ZDLL_HEAD timers
See ENIP_TIMER.
uint8_t bearer
Bearer ID, 0xFF = no context.
uint8_t state
See LMAN_SetState.
ENIP_MODULE *ENIP_PORT * port_rx
< Module of the driver
REGSOCKCEPID_DATA data
See LMAN_SetSocketReg.
uint16_t iface
See LMAN_SOCKET_DESTINATION.
uint16_t cepid
Owner process.
uint16_t iface
Interface index.
void(* post_run)(ENIP_MODULE *module)
uint8_t bearer
Receiving bearer ID.
ENIP_ZDLL_HEAD ports
See ENIP_PORT.
ENIP_MODULE *uint32_t start
Start tick.
uint8_t type
See LMAN_AllocContext.
uint32_t local_ip
IPv4 address.
void(* down)(ENIP_MODULE *module, uint32_t reason)
uint16_t next_port
Next local port for automatic binding.
void(* notify)(ENIP_MODULE *module, int event)
ENIP_PORT * port_tx
Port of the driver for outgoing packets.
uint8_t bearer
Bearer ID, 0xFF = none.
void ResetGPRSTraffic(void)
Reset the GPRS traffic counter.
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.
int WSP_ReadProperty(const char *key, void *value, unsigned *length)
Read a WSP property.
char IsGPRSEnabled(void)
Check if GPRS enabled.
uint32_t * RamLmanRefs(void)
Get the LMAN process-to-context reference 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.
void RefreshGPRSTraffic()
Refresh the GPRS traffic counter.
int enip_nsapi_init_module(ENIP_NSAPI_MODULE *module)
Initialise an NSAPI (PDP context) module named "NSAPI".
ENIP_IPH_INTERFACE * ENIP_FindInterface(uint32_t bearer, uint16_t iface)
Find the IP interface of a bearer.
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.
void ENIP_PacketFree(ENIP_PKT *packet)
Free an ENIP packet.
void LMAN_FreeContext(unsigned cid)
Reset and release a native LMAN context without disconnecting a physical bearer.
int enip_packet_max_size(void)
Get the largest ENIP packet size (a firmware constant).
void enip_tcph_frame_read(ENIP_IPH_INTERFACE *iface, ENIP_PKT *packet)
Process a received TCP segment.
int RequestLMANDisconnect(const uint8_t *req)
Request disconnection of a native LMAN context.
void enip_timer_init(ENIP_TIMER *timer, ENIP_MODULE *module)
Initialise an ENIP timer.
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_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.
void enip_tcph_update_SACK_block_list(ENIP_SOCKET *socket)
Remove the SACK blocks that are already acknowledged.
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.
LMAN_CONTEXT * RamLmanContexts(void)
Get the LMAN context table.
void * enip_memory_allocate(uint32_t unused, int size)
Allocate memory from the ENIP pool, falling back to the second ENIP pool.
ENIP_IP_DRIVER * RamPdpDrivers(void)
Get the GPRS PDP driver table (the DNS resolver takes servers for bearer 1 from it).
unsigned LMAN_AllocContext(unsigned bearer, uint8_t type)
Allocate a native LMAN context.
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.
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_timer_start(ENIP_TIMER *timer, uint32_t timeout)
Start or restart an ENIP timer and schedule its module.
void enip_sockh_IF_init(ENIP_IPH_INTERFACE *iface)
Pick a pseudo-random first local port for an interface.
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.
int RequestLMANConnect(LMAN_DATA *data)
Connect to the GPRS.
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.
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.
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.
const char * RamActiveGPRSProfileName(void)
Get name of the current internet profile.
int enip_tcph_sock_init(ENIP_SOCKET *socket)
Initialise the TCP state of a socket: initial sequence number, windows and MSS.
void ENIP_PDP_NET_UP_CNF(uint16_t context, int result)
ENIP handler of the PDP NET_UP confirmation.
void LMAN_SetState(unsigned cid, int state)
Change a native LMAN context state and notify its registered owners.
LMAN_SOCKET_REG * RamSocketRegs(void)
Get the LMAN socket registration table.
void enip_iph_packet_avail(void)
Notify the IP layer that a packet buffer is free again.
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.
char IsGPRSConnected(void)
Check if the GPRS session is established.
int RegisterCepidForSocketWork(REGSOCKCEPID_DATA *reg)
Register current CEPID for sockets.
unsigned GetSocketRegIndex(unsigned cepid)
Find the socket-registration slot for a CEPID.
int enip_sockh_dgram_connect(ENIP_SOCKET *socket, int address, uint32_t unused, uint16_t port)
Set the peer of a datagram socket.
void enip_memory_release(void *block)
Release a block allocated with enip_memory_allocate.
int SetCurrentGPRSProfile(int profile_id)
Change current internet profile.
unsigned GetServiceCepid(unsigned service)
Get the process identifier assigned to a native service.
int enip_init_csd_iface(ENIP_MODULE *module, ENIP_IP_DRIVER *driver)
Fill an IP driver description for the CSD (PPP dial-up) interface.
void ENIP_PortInit(ENIP_PORT *port, ENIP_MODULE *module)
Initialize the packet port of an ENIP network module.
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.
void LMAN_SetRef(unsigned reg_index, unsigned cid, int on)
Attach or detach a registered process from an LMAN context.
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).
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.
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.
uint8_t ENIP_ModuleRun(ENIP_MODULE *module, uint32_t *result)
Run an ENIP network module once.
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 proce...
void enip_iph_frame_read(ENIP_PKT *packet)
Process a received IP packet: check the IPv4 header, find the interface, reassemble fragments and pas...
int ActivateDialUpProfile(uint32_t cepid, int profile_id)
Activate internet profile.
void ENIP_PDP_STOP_REQ(uint16_t context, int mode)
ENIP handler of the PDP stop request.
void enip_tcph_run(void)
Check the TCP timers of all sockets: retransmit, time out or move on in the close states.
unsigned LMAN_GetOrAllocSocketRegIndex(unsigned cepid)
Find the LMAN socket registration (see RamSocketRegs) of a process or take a free one.
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.
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.
int enip_nsapi_init_iface(ENIP_NSAPI_MODULE *module)
Create and register the IP interface of a PDP context (NSAPI module).
LmanEventID
LinkManager GBS events.
int GetCurrentGPRSProfile(void)
Get an ID of the active internet profile.
void LMAN_LINK_UP_CNF(void)
LMAN handler of the link-up confirmation: mark the waiting connection as up and notify the owner.
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 ...
void * zDLL_RemHead(ENIP_ZDLL_HEAD *list)
Remove the first item of an ENIP list (packet queue).
int ENIP_RegisterDriver(ENIP_IP_DRIVER *driver, int flags)
Register an IP driver (network interface) in the ENIP IP layer.
int GetDisconnectTime(void)
Get internet connection timeout for disconnect when there is no activity.
void LMAN_AttachInterface(unsigned cid, unsigned iface, unsigned unk)
Attach an IP interface to a native LMAN context.
uint8_t LMAN_GetBearerIdForCi(uint16_t cid)
Get the bearer ID of an LMAN context.
uint16_t LMAN_FindContext(uint16_t bearer, uint16_t iface)
Find the LMAN context with the given bearer ID and interface.
void enip_module_nsapi_post_init(ENIP_NSAPI_MODULE *module)
Reset the per-context fields of an NSAPI module after enip_nsapi_init_module.
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...
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,...
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.
void zDLL_Init(ENIP_ZDLL_HEAD *list)
Initialise an empty ENIP double-linked list (two pointers: first, last).
void GPRS_OnOff(int enable, int unk)
Enable or disable GPRS internet.
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.
void ENIP_PDP_NET_UP_REJ_IND(uint16_t context, int result)
ENIP handler of the PDP NET_UP reject indication.
struct ENIP_SOCKET ENIP_SOCKET
ENIP socket.
void RegisterCepIdForCurProfile(uint32_t cepid, int profile_id, uint32_t is_gprs)
Register CEPID for internet profile.
void ENIP_ModuleDown(ENIP_MODULE *module, uint32_t reason)
Bring an ENIP network module down.
void ENIP_PortSend(ENIP_PORT *port, ENIP_PKT *packet)
Queue a packet on an ENIP port.
void enip_icmp_frame_read(ENIP_IPH_INTERFACE *iface, ENIP_PKT *packet)
Process a received ICMP packet and release it.
void * WSP_GetObject(unsigned id)
Get a WSP object.
void enip_timer_cancel(ENIP_TIMER *timer)
Stop an ENIP timer if it is running.
void ENIP_UnregisterDriver(ENIP_MODULE *module)
Unregister the IP driver of an ENIP network module.
ENIP_IPH_INTERFACE * enip_siph_find_IF(int address)
Find the IP interface with the given local address.
void enip_iph_run(ENIP_MODULE *module)
Run procedure of the IP module: expire socket timers and handle queued packets.
int * GetGPRSTrafficPointer()
Get traffic used by GPRS.
void enip_tcph_change_sock_state(ENIP_SOCKET *socket, uint32_t state)
Change the TCP state of a socket and notify its owner.
ENIP_PKT * ENIP_PacketAlloc(ENIP_MODULE *module, int size, uint32_t pool, int offset, int quota)
Allocate an ENIP packet.
void enip_iph_rheader_init(void *slot)
Reset an IPv4 reassembly slot and its timer.
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.
EnipEventID
ENIP GBS events.
char IsGPRSAvailable(void)
Check if GPRS available in the current network.
void LMAN_FreeSocketReg(unsigned index)
Free an LMAN socket registration (see RamSocketRegs).
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.
int ENIP_ModuleUp(ENIP_MODULE *module)
Bring an ENIP network module up.
char IsEDGEAvailable(void)
Check if EDGE is available in the current network.
@ ENIP_SOCK_REMOTE_CLOSED
Network Access Point data.
ENIP IP driver: the network side of an interface (see ENIP_RegisterDriver).
ENIP IP interface: a registered driver (see ENIP_FindInterface).
ENIP network module (see ENIP_ModuleInit).
ENIP NSAPI module (see enip_nsapi_init_module).
ENIP packet header (see ENIP_PacketAlloc).
ENIP port: packet input of a module (see ENIP_PortInit).
Socket destination passed to enip_sock_create.
ENIP timer (see enip_timer_init).
ENIP list (see zDLL_Init).
ENIP list item, the first field of a listed object.
LMAN context (see RamLmanContexts).
Where sockets of a process go (see LMAN_GetSocketDestination).
LMAN socket registration of a process (see RamSocketRegs).
Network Access Point data container.
CEPID registration data for sockets.
int socket(int domain, int type, int protocol)