@CHIP-RTOS C Library V2.06 - BIOS API
BIOS_Connection_Handler
Install a system server
connection handler function. int BIOS_Connection_Handler ( CONN_HANDLER handler,
SERVER_SPEC which_server ); Parameters
handler
- Vector to callback function
which_server
- Enumerator:
SS_FTP_SERVER = 0
SS_TELNET_SERVER = 1
SS_WEB_SERVER = 2
Return Value
- 0: Success
-1: Invalid which_server
parameter
Comments
- A connection handler function must be declared in the following way:
int huge UserConnectionHandler(
struct sockaddr far *sockptr );
The connection handler will be called if a client establishes a connection
to the server (FTP, WEB, Telnet). The handler could read the IP Address
and the port number from the
sockaddr_in
structure referenced by the sockptr input parameter.
The TCP/IP API function
InetToAscii might be of use here.
Because of the supported IPv4 and IPv6 protocol, this function has the
generic parameter sockaddr *
. For avoiding a compiler warning
("Suspicious pointer conversion"), it is recommended to cast the used
struct sockaddr_in *
into struct sockaddr *
.
If the connection handler returns zero the connection will be established.
If it returns a non-zero value, the connection will be abort.
Example usage:
The implemented handler function could check the source IP address
(Client's IP), comparing this IP with an application internal list of
allowed IP addresses and reject the connection by returning a non-zero
value if the source IP is not in the list.
A connection handler can be removed by calling BIOS_Connection_Handler
with a null pointer for the handler parameter.
SC1x3 Comments- For IPv6 connections, the sockptr parameter passed to the
callback function is a pointer to a
sockaddr_in6
type data structure.
See Also
RTOS API
- This library function invokes a RTOS software interrupt.
Refer to this RTOS API function's
documentation
for more details.
Supported since or modified in @CHIP-RTOS version-
SC12 | SC13 | SC11 | SC1x3 |
-
V1.02 | V1.00 | V1.00 | V0.90 |
This API List
List of C Libraries
@CHIP-RTOS Main Index
End of document
|