SMO-SFO-0039 H PackIP ReferenceManual



Comments



Description

Référence / Reference : SMO/SFO-0039 Titre /Title: Révision / Revision : H Package IP Reference Manual Programme / Subject : TELIUM Approbation de la révision / Revision Approval : H Nom Name Etabli par : Written by: Fonction Function Vincent Gomes Software Engineer Vérifié ou Approuvé par : Checked or approved by: Jean-Luc Menez SDK Project Manager Autorisé par : Authorized by: Christophe Barthelemy SDK Product leader Révision Issue Date de validité / d’application Validity/application date Nb de pages Nb of pages Nb de pages annexes Nb of appendices Objet et description de la modification Object and description of modification A B C D E F G H September 2005 November 2005 August 2006 January 2007 April 2007 February 2008 April 2008 October 2008 Initial version (PackIP 1.2). Add sample "ExternalGPRS" (PackIP 2.1) Add PING facility and default route settings (PackIP 2.2) Add SMTP and POP3 interfaces (PackIP 3.0) Add HTTP server and attached files for SMTP (PackIP 3.1) Add details on HTTP server functions. Add HTTPS server facility. Add details on Ethernet options. TRES IMPORTANT : la validité du présent document, soumis à signature électronique doit être vérifiée, avant usage, dans le répertoire “Docs Applicables” de PRISMA Programmes. Page : M1 TABLE OF CONTENT 1. 2. 3. INTRODUCTION ..............................................................................................................................................................1 OVERVIEW........................................................................................................................................................................2 PPP INTERFACE ..............................................................................................................................................................3 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10 CONNECTION ................................................................................................................................................................3 OPEN A CONNECTION ....................................................................................................................................................3 CLOSE A CONNECTION .................................................................................................................................................4 START A CONNECTION..................................................................................................................................................4 STOP A CONNECTION ....................................................................................................................................................4 GET THE CONNECTION STATE .......................................................................................................................................5 WAIT FOR A CONNECTION STATE .................................................................................................................................5 CONFIGURE A CONNECTION .........................................................................................................................................6 SET AN OPTION OF THE CONNECTION ...........................................................................................................................7 GET AN OPTION OF THE CONNECTION ...........................................................................................................................7 4. IP CONFIGURATION MANAGEMENT........................................................................................................................8 4.1 4.2 4.3 4.4 4.5 LOAD THE DEFAULT CONFIGURATION ..........................................................................................................................8 UNLOAD A CONFIGURATION .........................................................................................................................................9 READ AN OPTION OF THE DEFAULT CONFIGURATION ....................................................................................................9 SET AN OPTION OF THE DEFAULT CONFIGURATION .....................................................................................................10 SAVE THE DEFAULT CONFIGURATION .........................................................................................................................11 5. ETHERNET MANAGEMENT .......................................................................................................................................12 5.1 5.2 GET AN OPTION OF THE ETHERNET LINK .....................................................................................................................12 SET AN OPTION OF THE ETHERNET LINK .....................................................................................................................12 6. DNS RESOLVER SETTINGS ........................................................................................................................................14 6.1 6.2 GET AN OPTION OF THE DNS RESOLVER ....................................................................................................................14 SET AN OPTION OF THE DNS RESOLVER .....................................................................................................................14 7. DEFAULT ROUTE SETTINGS .....................................................................................................................................15 7.1 7.2 GET THE DEFAULT GATEWAY ADDRESS .....................................................................................................................15 SET THE DEFAULT GATEWAY ADDRESS ......................................................................................................................15 8. UTILITIES FUNCTIONS ...............................................................................................................................................16 8.1 8.2 8.3 ACCESS THE INTERNAL ERROR (ERRNO)....................................................................................................................16 FORMAT A TCP/IP ADDRESS .................................................................................................................................16 PING ...........................................................................................................................................................................18 9. SMTP .................................................................................................................................................................................19 9.1 9.2 9.3 9.4 CONNECTION TO THE SERVER ....................................................................................................................................19 DISCONNECTION FROM THE SERVER...........................................................................................................................19 SEND A MESSAGE .......................................................................................................................................................20 SEND A SINGLE MESSAGE ...........................................................................................................................................21 POP3 .............................................................................................................................................................................23 CONNECTION TO THE SERVER ....................................................................................................................................23 DISCONNECTION FROM THE SERVER...........................................................................................................................23 REQUESTING THE NUMBER OF MESSAGES...................................................................................................................24 REQUESTING A GIVEN MESSAGE ...............................................................................................................................24 DELETING A GIVEN MESSAGE ...................................................................................................................................25 10. 10.1 10.2 10.3 10.4 10.5 SMO/SFO-0039 Rév. : H Page : S1 10.6 11. 11.1 11.2 11.3 11.4 11.5 12. 13. 13.1 13.2 13.3 13.4 13.5 RESET THE SESSION ...................................................................................................................................................26 HTTP/HTTPS SERVER .............................................................................................................................................27 LAUNCH THE SERVER .................................................................................................................................................27 WAIT FOR A REQUEST ................................................................................................................................................28 SEND A RESPONSE ......................................................................................................................................................32 STOP THE SERVER ......................................................................................................................................................33 GET INFORMATION ABOUT SSL SESSION (HTTPS ONLY) ..........................................................................................33 COMPATIBILITY ......................................................................................................................................................35 SAMPLE PROGRAMS...............................................................................................................................................36 PPP SAMPLE ..............................................................................................................................................................36 ETHERNET SAMPLE ....................................................................................................................................................37 ENABLE/DISABLE THE ICMP REPLY FACILITY ...........................................................................................................38 MAIL SAMPLE ............................................................................................................................................................38 HTTP SAMPLE ...........................................................................................................................................................41 SMO/SFO-0039 Rév. : H Page : S2 1. INTRODUCTION The package IP is a static library (named “IP_.lib”) which makes easier the development of Internet programs for EFT POS terminals. This library is static (it must be linked with the application). It is compiled with the three compilers (GCC, RVD and SDT) supported by the Telium SDK. Its interface is composed of several API header files : <IP_.h >, <SMTP_.h>, <PPP_.h>, <POP3_.h>.and <HTTP_.h>. The package provides all the services to perform Internet communications. Its main facilities are : • IP communications. BSD interface. Client and server. TCP/IP. UDP. • PPP Management. • Ethernet Management. • DNS Resolver. • SMTP and POP3 email services. • HTTP server facility • ... Developers shall read the [SMO-SFO-0075_PackIP_SecurityGuidance.pdf] which describes best practises for implementing IP enabled applications, according to the requirements of the POS Terminal Security Program.(PTS) SMO/SFO-0039 Rév. : H Page : 1 h POP3_. SMTP.2. This document does not explain these functions.h SMTP_. OVERVIEW Folder SDK/inc Content IP_. POP3 and HTTP. how to implement a TCP client 2. Source of a sample application which shows: 1.h> regroups mainly the standard BSD definitions. particularly the ones of the interface of the integrated protocols PPP. It shows how to perform a PPP connection. POP3 and SMTP.lib Description The library header files for respectively IP. HTTP.h PPP_.lib IP_. SMO/SFO-0039 Rév. how to implement a TCP server 3.h IP_. SDK/lib_gnu SDK/lib_rvd SDK/lib_sdt SDK/Samples/ExternalGPRS SDK/Samples/TCPIP * SDK/Sample/FTP SDK/Sample/SSL Static IP library for GNU Static IP library for RVD Static IP library for SDT Source of a sample application which manages an external GPRS modem. how to send and receive emails Source of a FTP sample (please refer the FTP documentation) Source of an SSL sample (please refer the SSL documentation) The header file <IP_. : H Page : 2 .lib IP_. PPP. how to retrieve the Ethernet parameters 4.h HTTP_. It describes the specific functions. ).1 PPP INTERFACE CONNECTION Syntax : PPP_HANDLE PPP_Connect ( const char *szComPort.2 OPEN A CONNECTION Syntax : Include : Return : PPP_HANDLE PPP_Open ( const char *szComPort ). unsigned int nTimeout ).h > Include : Parameters : szComPort: szLogin : szPassword : nProfile : nDelay: nTimeout Return : Description : Communication port name (for example : "COM1". Polling delay (in 10 ms) Maximum waiting delay (in 10 ms) Returns the connection handle (>=0) or a negative error code.. Several common connection modes are possible.3. "COM6" . SMO/SFO-0039 Rév. It performs all the process of the connection. The polling delay must be lower than the timeout delay. : H Page : 3 .h > Returns the connection handle (>=0) or a negative error code. It indicates the delay to verify periodically the state of the connection. const char *szLogin. Connection profile. 3. Nota : 3. const char *szPassword. This function establishes a PPP connection through a communication port. Please refer to the function "PPP_Setup" to know the different profiles. unsigned int nDelay. PPP user name PPP password. int nProfile. < PPP_. < PPP_.. 3. 3.h > Returns 0 or a negative error code.5 STOP A CONNECTION Syntax : int PPP_Stop ( PPP_HANDLE handle ).. < PPP_. 3. Description : This function opens a connection through a communication port (physical link).4 START A CONNECTION Syntax : Include : Return : Parameters : nHandle : Description : PPP connection handle.Parameters : szComPort: Communication port name (for example : "COM1". int PPP_Start ( PPP_HANDLE handle ).3 CLOSE A CONNECTION Syntax : Include : Return : Parameters : nHandle : Description : PPP connection handle. < PPP_. This function starts the connection (e.h > Returns 0 or a negative error code. : . : H Page : 4 . int PPP_Close ( PPP_HANDLE handle ).. "COM6" .). The communication port must be previously opened.g. It releases all its allocated resources. the PPP negotiation). The function returns only an handle on the connection. SMO/SFO-0039 Rév. This function closes a connection. h > Returns 0 or a negative error code. This function returns the state of the connection. but it do not close the connection. unsigned long nTimeout ).7 WAIT FOR A CONNECTION STATE Syntax : int PPP_WaitState( PPP_HANDLE nHandle. Include : Return : SMO/SFO-0039 Rév. int nWaitState.h > PPP connection state.h > Returns 0 or a negative error code.6 GET THE CONNECTION STATE Syntax : Include : Return : Parameters : nHandle : Description : PPP connection handle.Include : Return : Parameters : nHandle : Description : < PPP_. : H Page : 5 . This function stops the connection (e. 3. < PPP_. Physical connection in progress Network connection in progress Authentication in progress Disconnected Connection successful. State PPP_STATE_DEAD PPP_STATE_ESTABLISH PPP_STATE_NETWORK PPP_STATE_AUTH PPP_STATE_TERMINATE PPP_STATE_IFUP Comment The physical link is not ready. 3. : it disconnect it). < PPP_. PPP connection handle. int nStateExit. int PPP_GetState ( PPP_HANDLE handle ).g. SMO/SFO-0039 Rév. This function configures the parameters of a connection. 3.Parameters : nHandle : PPP connection handle. const char *szLogin. Returns 0 or a negative error code. They are defined by a specific profile szPassword : nProfile : Return : Description : Nota : Profile PPP_PERSONAL_PROFILE PPP_PSTN_PROFILE Description Minimal configuration (login and password). Connection profile. int nProfile ).. nWaitState : Waited state nStateExit : Exit State nTimeout : Description : Maximum timeout for waiting. PPP user name PPP password. Configuration dedicated to the PSTN communications. with an error. < PPP_.8 CONFIGURE A CONNECTION Syntax : int PPP_Setup ( PPP_HANDLE handle. The user must complete this configuration himself by calling the function "PPP_Set" (described below). This function waits until the connection has reached the given state.h > Include : Parameters : nHandle : szLogin : PPP connection handle. : H Page : 6 . when the 'nStateExit' has been reached or when the waiting timeout expires. const char *szPassword. Several common connection modes are possible. It exits also. 10 GET AN OPTION OF THE CONNECTION Syntax : Include : Parameters : nHandle : nOption: pArg: Return : Description : PPP connection handle.PPP_GPRS _PROFILE Configuration dedicated to the GPRS communications.9 SET AN OPTION OF THE CONNECTION Syntax : Include : Parameters : nHandle : nOption: pArg: Return : Description : PPP connection handle. void *pArg ). < PPP_.h > 3. int nOption. This function gets the current value of an option parameter of a connection. Value. This function sets an option parameter of a connection. Option to set. int PPP_GetOption ( PPP_HANDLE handle.. void *pArg ). Returns 0 or a negative error code. < PPP_. Returns 0 or a negative error code. int nOption. : H Page : 7 . Option to get. int PPP_SetOption ( PPP_HANDLE handle.h > SMO/SFO-0039 Rév. Value. 3. < IP_. Error when reading the default parameter file. IP CONFIGURATION MANAGEMENT The IP package provides functions to monitor the configuration of the IP facility.4. : H Page : 8 . The default parameter file can not be opened.h > SMO/SFO-0039 Rév. They can be read.1 LOAD THE DEFAULT CONFIGURATION Syntax : Include : Parameters : pnError : Output parameter which returns the error code of the loading operation. ETHCONF_HANDLE __LoadDefaultOptions ( int *pnError ). The hardware address (MAC) is missing.3 Enable/disable the ICMP reply facility (page 38) Option __DFL_MAC_ADDRESS __DFL_ETH_LINK_SPEED Value 6 bytes Integer. 10 or 100 __DFL_ETH_BOOT_PROTOCOL DHCP or Static __DFL_ETH_ADDR 4 bytes __DFL_ETH_GATEWAY 4 bytes __DFL_ETH_NETMASK 4 bytes __DFL_ETH_DNS1 4 bytes __DFL_ETH_DNS2 4 bytes __DFL_ICMP_REDIRECT Bool ON or OFF __DFL_ICMP_ECHO_REPLY Bool ON or OFF Access Comments Read MAC Address Read/Write Ethernet link speed __DFL_ETH_LINK_SPEED_10MB __DFL_ETH_LINK_SPEED_100MB Read/Write Ethernet boot protocol (Static or DHCP) __DFL_ETH_BOOT_PROTOCOL_NONE __DFL_ETH_BOOT_PROTOCOL_DHCP Read/Write Ethernet local Address Read/Write Ethernet gateway address Read/Write Ethernet network mask Read/Write Ethernet DNS1 address Read/Write Ethernet DNS2 address Read/Write Activate ICMP redirection __DFL_ON __DFL_OFF Read/Write Activate ICMP reply __DFL_ON __DFL_OFF 4. It is a mandatory parameter. Error Code __DLF_OK __DFL_ERROR_HW_ADDR_FOUND __DFL_ERROR_OPEN_FAILED __DFL_ERROR_LOADING Comment The IP configuration parameters have been successfully loaded. A sample is given in the section : 13. written and saved persistently (to become the default configuration). The different options are listed in the table below. 3 READ AN OPTION OF THE DEFAULT CONFIGURATION Syntax : int __GetDefaultOption ( ETHCONF_HANDLE handle. Error Code __DLF_OK __DFL_ERROR_INVALID_HANDLE Comment The configuration has been successfully unloaed. This function loads the default parameters of the IP Ethernet link. < IP_. void *pArg ).h > Include : Parameters : handle : nOption: Handle on the configuration . < IP_. The list of options is given in table above.Return : Returns an handle on the IP configuration (>=0) or a negative error code. Invalid handle parameter Description : This function unloads a configuration previously loaded using the function “__LoadDefaultOptions”. Option to get. The configuration handle is released. Returns 0 or a negative error code. Description : 4.g it is not saved). It must not be used anymore. : H Page : 9 . SMO/SFO-0039 Rév.2 UNLOAD A CONFIGURATION Syntax : Include : int __UnloadDefaultOptions ( ETHCONF_HANDLE hConf ). 4. int nOption. The configuration is lost (e.h > Parameters : hConf : Return : Handle on the configuration to unload. Returns 0 or a negative error code. : H Page : 10 . Returns 0 or a negative error code.pArg: Return : Value. The list of options is given in table above. < IP_. To make this change persistent. Invalid handle parameter Invalid option parameter Description : This function sets an option parameter in the IP configuration. The option is fixed. int nOption. It can not be changed The option value is invalid. SMO/SFO-0039 Rév. Error Code __DLF_OK __DFL_ERROR_INVALID_HANDLE __DFL_ERROR_INVALID_OPTION Comment The option has been successfully retrieved. Value. the configuration must be saved using the function “__SaveDefaultOptions” (described below).4 SET AN OPTION OF THE DEFAULT CONFIGURATION Syntax : int __SetDefaultOption ( ETHCONF_HANDLE handle.h > Include : Parameters : handle : nOption: pArg: Return : Handle on the configuration Option to set. 4. Invalid handle parameter Invalid option parameter Description : This function gets an option parameter of IP configuration. void *pArg ). Error Code __DLF_OK __DFL_ERROR_FIXED_OPTION __DFL_ERROR_INVALID_VALUE __DFL_ERROR_INVALID_HANDLE __DFL_ERROR_INVALID_OPTION Comment The option has been successfully set. The terminal is automatically rebooted and the new saved configuration is used. Returns the negative error code __DFL_ERROR_INVALID_HANDLE (the handle parameter is invalid ) or never returns.5 SAVE THE DEFAULT CONFIGURATION Syntax : Include : Parameters : handle : Return : Handle on the configuration to save.h > Description : SMO/SFO-0039 Rév. int __SaveDefaultOptions ( ETHCONF_HANDLE handle ). < IP_.4. : H Page : 11 . This function saves the configuration as the default one. DNS address 1 (read-only). Returns 0 or a negative error code. void *pArg ). Returns 0 or a negative error code.h > int nOption.5. ETHERNET MANAGEMENT The IP package provides two functions to monitor the Ethernet configuration. This function sets an option parameter of the Ethernet link. They allow to read and to write the parameters of the Ethernet interface. This function gets an option parameter of the Ethernet link. they can be read-only.1 GET AN OPTION OF THE ETHERNET LINK Syntax : Include : Parameters : nOption: pArg: Return : Description : Option to set. int EthernetGetOption ( < IP_. Network mask. int EthernetSetOption ( < IP_. DNS address 2 (read-only).h > int nOption. 5. Gateway address (read-only). ETH_IFO_DNS1 ETH_IFO_DNS2 5. Value. void *pArg ). The parameters are listed in the following table below. Value. Some of them can not be written.2 SET AN OPTION OF THE ETHERNET LINK Syntax : Include : Parameters : nOption: pArg: Return : Description : Option to set.. Option ETH_IFO_ADDR ETH_IFO_NETMASK ETH_IFO_BRDADDR ETH_IFO_GATEWAY Comment Local address. Broadcast address. : H Page : 12 . SMO/SFO-0039 Rév. : H Page : 13 .SMO/SFO-0039 Rév. 6. Returns 0 or a negative error code. SMO/SFO-0039 Rév. void *pArg ). Returns 0 or a negative error code.h > int nOption.1 GET AN OPTION OF THE DNS RESOLVER Syntax : Include : Parameters : nOption: pArg: Return : Description : 6. SET AN OPTION OF THE DNS RESOLVER Syntax : Include : Parameters : nOption: pArg: Return : Description : Option to set. Value. void *pArg ).6. DNS RESOLVER SETTINGS The Domain Name Server (DNS) resolver settings can be monitored using the the two following functions. int ResolverSetOption ( < IP_. This function sets an option parameter of the DNS resolver.2 Option to set. : H Page : 14 . Value. int ResolverGetOption ( < IP_.h > int nOption. This function gets an option parameter of the DNS resolver. SMO/SFO-0039 Rév. Gateway address to set. 7. DEFAULT ROUTE SETTINGS The gateway address of the embedded TCP/IP stack is managed by the two following functions. Default gateway address.h > unsigned int nGatewayAddress ).7. void __GetDefaultRoute ( unsigned int *nGatewayAddress ).1 GET THE DEFAULT GATEWAY ADDRESS Syntax : Include : Parameters : nGatewayAddress: Return : Description : None.h > 7. < IP_.2 SET THE DEFAULT GATEWAY ADDRESS Syntax : Include : Parameters : nGatewayAddress: Return : Description : None. This function gets the current gateway address of the embedded TCP/IP stack. : H Page : 15 . This function sets the current gateway address of the embedded TCP/IP stack. void __SetDefaultRoute ( < IP_. h > Parameters : None. Rév.2 FORMAT A TCP/IP ADDRESS The following functions are provided to convert and format a TCP/IP address. < IP_.8.h > Parameters : nError : Return : Description : Error code.zzz").TCP/IP address .h > Parameters : szAddress: . This function returns the current value of the internal error code (ERRNO).xxx. None. : H Page : 16 SMO/SFO-0039 . Syntax : Include : void SetErrno (int nError ). Return : Description : The internal error code value (ERRNO). This function sets the value of the internal error code (ERRNO). < IP_. Syntax : Include : int GetErrno (void ). Syntax : Include : unsigned long __inet_addr( const char *szAddress ).yyy. < IP_.ASCII format ("www. 8. UTILITIES FUNCTIONS The package TCP/IP provides other utility functions described in this section.1 ACCESS THE INTERNAL ERROR (ERRNO) The two following functions allow to access the internal error code (ERRNO). 8. TCP/IP address . This function converts a 4 bytes address in its ASCII format. < IP_. struct in_addr *pnAddress ). This function converts an ASCII TCP/IP address to its 4 bytes format (struct in_addr).yyy. SMO/SFO-0039 Rév. Returns 1 if the address has been rightly converted.zzz"). Description : Syntax : Include : char *__inet_ntoa( struct in_addr nAddress ). This function converts an ASCII TCP/IP address to its 4 bytes format (struct in_addr).TCP/IP address . It is allocated by the function "__inet_ntoa" and belongs to this one.h > Parameters : nAddress: Return : Description : . < IP_.4 bytes format. Syntax : Include : int __inet_aton( const char *szAddress.h > Parameters : szAddress: pnAddress: Return : Description : . Converted address .xxx.ASCII format ("www. Inverse of the function "__inet_addr".ASCII format ("www. and 0 otherwise.xxx. Nota : The returned character string is NULL terminated.zzz"). Converted address .yyy. It must copied by the calling function and must not be freed. : H Page : 17 .4 bytes format.Return : Returns the converted address (4 bytes format) or 0 when the ASCII address is not rightly formatted. . int __Ping ( < IP_. : H Page : 18 . This function tests if a remote address is reachable.3 PING Syntax : Include : Parameters : nAddress: nTimeout: Return : Description : Remote address to reach Waiting delay (in 10 ms) for the answer. by sending an ICMP request (Ping). SMO/SFO-0039 Rév.h > unsigned int nAddress.8. int nTimeout ). Returns 0 or a negative error code. 1 SMTP CONNECTION TO THE SERVER Syntax : SMTP_HANDLE SMTP_Connect(const char *szSMTPServer. const char *szLogin. or be anonymous (no user. SMTP port (usually 25). This function connects the terminal to the SMTP server. 9.h > . 9. This function disconnects the terminal from the SMTP server. if no authentication required by the remote SMTP server. : H Page : 19 void SMTP_Disconnect ( SMTP_HANDLE handle ). const char *szSMTPClient ). Password associated to the user name.h > Include : Parameters : szSMTPServer: nPort: szLogin TCP/IP address of the SMTP server. Is NULL when the user name is NULL. nor password). const char *szPassword. None. User name. int nPort.9. or a negative error code. May be set to NULL (or ""). < SMTP_. < SMTP_. Network name of the terminal. szPassword szSMTPClient Return : Description : Returns the connection handle (>=0). This connection can request an identification.2 DISCONNECTION FROM THE SERVER Syntax : Include : Parameters : handle: Return : Description : Handle on the connection to close. SMO/SFO-0039 Rév. List of recipients. put a comma (.9. List of recipients put in blind copy. of the message to send. const char *szTo.) between each address.) between each address. In case of multiple recipients. In case of multiple recipients. put a comma (. The complete path to these files (directory and file name) must be put in this array.h > Handle on an existing connection. SMO/SFO-0039 Rév. May be NULL. Subject of the message. This list can be NULL. const char *pAttachedFilesList[] ). Size. This list can be NULL. in bytes. int nMessageSize. These files must be stored in the FFMS before being sent. const char *szFrom. put a comma (. : H Page : 20 . List of recipients put in copy. Use a valid address to be able to be informed about distribution failures. In any case. const char *szBCC.) between each address. Include : Parameters : handle: < SMTP_. const char *szCC.3 SEND A MESSAGE Syntax : int SMTP_Send ( SMTP_HANDLE handle. Message to send. the last item of this list must be NULL. This list can be NULL (no attached files). E-mail address of the sender. This list can be NULL. const char *szSubject. This address cannot be NULL. In case of multiple recipients. Please note that the global raw message's size (header and content) is limited to 8 kilobytes. const char *szMessage. szMessage: nMessageSize: szSubject: szFrom: szTo: szCC: szBCC: pAttachedFilesList: Array of attachement files' names. 9. szPassword szSMTPClient SMO/SFO-0039 Rév. const char *szTo. Network name of the terminal. or BCC) must not be NULL. const char *szLogin.4 SEND A SINGLE MESSAGE Syntax : int SMTP_SendUniqueMessage (const char *szSMTPServer.Note: At least of one list of recipients (To. or a negative error code. SMTP server port (usually 25). const char *szSubject. const char *szCC. Otherwise no header is added. Is NULL when the user name is NULL. User name. const char *szMessage. const char *szPassword. CC. const char *pAttachedFilesList[] ). as long as this header is not greater than 1024 bytes. : H Page : 21 . int nPort. if no authentication required by the remote SMTP server. const char *szFrom. const char *szBCC. This message has an header formatted according to the standard RFC 822. Password associated to the user name.h > szSMTPServer: nPort: szLogin: TCP/IP address of the SMTP server. const char *szSMTPClient. Send an US-ASCII text message to the lists of specified recipients. Return : Description : Number of attachement files sent (0 if none). Include : Parameters : < SMTP_. May be set to NULL (or ""). int nMessageSize. These files must be stored in the FFMS before being sent. In any case. Use a valid address to be able to be informed about distribution failures. In case of multiple recipients. the last item of this list must be NULL. The complete path to these files (directory and file name) must be put in this array. or BCC) must not be NULL. put a comma (. This list can be NULL. List of recipients. This list can be NULL. In case of multiple recipients. Note: At least of one list of recipients (To. Subject of the message. This list can be NULL (no attached files). In case of multiple recipients. CC. of the message to send. put a comma (. This list can be NULL. List of recipients put in copy.) between each address.) between each address. Return : Description : Number of attachement files sent (0 if none). : H Page : 22 . List of recipients put in blind copy. in bytes. This function can be used to send an unique message. put a comma (. E-mail address of the sender. or an negative error code. nMessageSize: szSubject: szFrom: szTo: szCC: szBCC: pAttachedFilesList: Array of attachement files' names. May be NULL. SMTP_Send(…) SMTP_Disconnect(…) SMO/SFO-0039 Rév. Size.szMessage: Message to send. It automatically performs the sequence: • • • SMTP_Connect(…).) between each address. This address cannot be NULL. Please note that the global raw message's size (header and content) is limited to 8 kilobytes. This connection requires an authentication. This function connects the terminal to the POP3 server. void POP3_Disconnect( < POP3_. SMO/SFO-0039 Rév.2 DISCONNECTION FROM THE SERVER Syntax : Include : Parameters : handle: Return : Handle on the connection to close. POP3 10. : H Page : 23 . const char *szLogin. char bSecuredConnection ). User name. Reserved for future use.h > POP3_HANDLE handle ). < POP3_.10.h > Include : Parameters : szSMTPServer: nPort: szLogin: szPassword: bSecuredConnection: Return : Description : TCP/IP address of the POP3 server. const char *szPassword.1 CONNECTION TO THE SERVER Syntax : POP3_HANDLE POP3_Connect (const char *szPop3Server. int nPort. None. or a negative error code. 10. Password associated to the user name. Description : This function disconnects the terminal from the SMTP server. Returns the connection handle (>=0). POP3 server port (usually 110). : H Page : 24 . nTotalSize: Pointer to an integer to fill with the global size of the messages currently into the open mail account. Number of the message to retrieve from the POP3 server.h > Handle on the connection. A pointer to the structure that will be filled with data extracted from the header. This number includes all the messages (new messages and those already read).4 REQUESTING A GIVEN MESSAGE Syntax : int POP3_GetMessage( POP3_HANDLE handle. Description : 10. If the content nMessageIndex: pPop3Info: SMO/SFO-0039 Rév. if required. int nBufferSize ). and. POP3_INFO *pPop3Info. char *szBufferBody. The index of the first message (oldest one) is 1. and important message characteristics.h > Handle on the connection. Please note that the buffers (see POP3_INFO description below) containing these data are 128 bytes long. Return : The number of messages currently into the mail account. handle. the total size occupied by the messages. This pointer may be NULL if this value is not needed. Include : Parameters : handle: < POP3_.10.3 REQUESTING THE NUMBER OF MESSAGES Syntax : int POP3_GetNbMessages( POP3_HANDLE int *nTotalSize ). This function returns the number of message present on the mail account. int nMessageIndex. Include : Parameters : handle: < POP3_. Note: The content of the body is US-ASCII text only. < POP3_. [_POP3_HEADER_LINE_SIZE]. nSize. any mail containing other elements. nBufferSize: Maximum size of the buffer allocated to receive the body of the message. Return : Description : 0.5 DELETING A GIVEN MESSAGE Syntax : int POP3_DeleteMessage( POP3_HANDLE handle. a new request to this same message is valid. like MIME encoding parts. [_POP3_HEADER_LINE_SIZE]. typedef struct { char szSubject char szFrom char szDate char szTo char szCC char szUIDL int } POP3_INFO. and the body in a separate buffer.h > Include : Parameters : handle: Handle on the connection. [_POP3_HEADER_LINE_SIZE]. Hence. Index of the message to delete from the POP3 server. int nMessageIndex ). szBufferBody: Buffer to fill with the body of the message. or a negative error code. has to be processed by the user. The index of the first message (oldest one) is 1. the data will be truncated to fit with buffer size. [_POP3_HEADER_LINE_SIZE]. [_POP3_HEADER_LINE_SIZE]. // // // // // // // Subject of the message Sender of the message Date Recipicient(s) Recipicient(s) in copy Unique identifier for the message Size of the message (in bytes) Note: this function does not delete the message on the POP3 server. whether only the “info” structure is requested. This parameter can be NULL.in the message's header is longer than 128 bytes. the header on the “info” structure. with. This function returns the given message. : H Page : 25 . 10. nMessageIndex: SMO/SFO-0039 Rév. Thus. [_POP3_HEADER_LINE_SIZE]. Description : This function deletes a given message. int POP3_Reset( POP3_HANDLE handle ).Return : 0.6 RESET THE SESSION Syntax : Include : Parameters : handle: Return : Handle on the connection.h > Description : This function reset the session. 10. or a negative error code. or a negative error code. 0. SMO/SFO-0039 Rév. It cancels the deletion of the messages performed during the current session. < POP3_. : H Page : 26 . 5. Listening port (usually 80 for HTTP and 443 for HTTPS).HTTPS server only. Set to TRUE to use SSL session cache.lib library. int bCheckPeer ). the SSL DLL must be loaded in the terminal and the application must be linked with SSL_. Set to TRUE to check peer certificate (mutual authentication). const char* szSslProfile. Note: to use the HTTPS facility. POST and PUT). : H Page : 27 . It enables to launch a simple HTTP/HTTPS server and to process the incoming requests (GET. the server does not authenticate the client (but the client does authenticate the server). HTTP/HTTPS SERVER The package TCP/IP provides functions to easily manage the HTTP/HTTPS server facility.h > szSslProfile: bUseCache: bCheckPeer: Return : Returns HTTP_SERVER_OK or a negative error code. the server won't store any files. This parameter can be set to NULL: in that case. FALSE otherwise HTTPS server only. int bUseCache. unsigned int nPort.1 LAUNCH THE SERVER Syntax : int HTTP_Server_Open ( HTTP_SERVER_HANDLE *hHandle. const char *szDestDisk ). HTTP sample (page 41). Name of the SSL profile . 11. An HTTP sample is given in the section : 13. int HTTPS_Server_Open ( HTTP_SERVER_HANDLE *hHandle. FALSE otherwise (simple authentication) – HTTPS server only.11. const char *szDestDisk. < HTTP_. Include : Parameters : hHandle: nPort: szDestDisk: Handle on the HTTP(S) server. Disk name where the server stores the downloaded files. SMO/SFO-0039 Rév. unsigned int nPort. With simple authentication. Cannot open the SSL DLL : is it HTTP_SERVER_ERROR_SSL_DLL_NOT_FOUND loaded in the terminal ? Description : This function starts the HTTP server on the given port.h > Returns HTTP_SERVER_OK or a negative error code. int HTTPS_Server_WaitRequest ( HTTP_SERVER_HANDLE hHandle.2 WAIT FOR A REQUEST Syntax : int HTTP_Server_WaitRequest ( HTTP_SERVER_HANDLE hHandle. A handle is allocated and returned. Memory error for the handle allocation. A pointer on the decoded HTTP request. : H Page : 28 . unsigned int nTimeout HTTP_SERVER_DATA **pRequest ). Cannot load the SSL profile. Cannot create or activate the listening socket.Error Code Comment HTTP_SERVER_OK HTTP_SERVER_ERROR_MEMORY HTTP_SERVER_ERROR_SOCKET HTTP_SERVER_ERROR_DISK HTTP_SERVER_ERROR_INVALID_PROFILE The function succeeds. The function mounts the destination disk. < HTTP_. Note: 11. This disk is unmounted when the server is stopped (see function HTTP_Server_Close() described below). unsigned int nTimeout HTTP_SERVER_DATA **pRequest ). Cannot mount the destination disk. SMO/SFO-0039 Rév. Include : Parameters : hHandle: nTimeout: pRequest : Return : Handle on the HTTP/HTTPS server. Duration to wait for a request. The server is launched. // // // // Number of elements in the header Name of the parameter Value of the parameter Internal use only // Number of data SMO/SFO-0039 Rév.1) char m_szURI[HTTP_SERVER_MAX_URI]. // Data short m_nDataNumber. the connection with the client. is automatically closed.Error Code Comment The function succeeds. Timeout expired. a call to HTTP_SendResponse() is mandatory to terminate the dedicated connection properly. HTTP_SERVER_ERROR_CLIENT_SOCKET Error on client socket. Request refused. short m_nBoundaryPos. If the call to HTTP_Server-WaitRequest() function is successful (return code equal to HTTP_SERVER_OK).9. char m_szHeaderParamValue[…][…]. HTTP_SERVER_ERROR_HANDLE Invalid handle parameter. A request has been received. // Address of the requested page // Header parameters short m_nHeaderParamNb. The HTTP_SERVER_ERROR_SOCKET dedicated socket can not be created. typedef struct { // Request char m_nCommand. The request is decoded and returned in the parameter of type HTTP_SERVER_DATA (described below). For any other return codes. Note: The requests sent to the server are automatically decoded and stored in a structure of type HTTP_SERVER_DATA described below. No request HTTP_SERVER_ERROR_TIMEOUT received. Nothing received from the HTTP_SERVER_ERROR_CLIENT_TIMEOUT client in the last 10 seconds. char m_szHeaderParamName […][…]. HTTP_SERVER_OK decoded and returned. The pointer on the request is internally allocated.0 or 1. // HTTP Version (0. 1. Unable to parse the request HTTP_SERVER_ERROR_MALFORMED_REQUEST properly. Description : This function waits for the reception of an HTTP request. it must not be released by the application. if established. // HTTP Command char m_szHttpVersion[4]. : H Page : 29 . The function creates a connection dedicated to the treatment of the request. // HTTP Boundary (if any) // Client information char m_szClientAddress[…]. // Name of the current data // Internal use // Value of the current data // // // // // Number of files in the data Name of the received file Type of the received file Name of the file saved in the file system Length of the file (in bytes) // Added int m_nContentLength. // Address of the client // Client port Common parameters m_nCommand: type of the HTTP command received in the request. A maximum of 32 elements are stored. to be compliant with Telium File System syntax. m_szHeaderParamName[nIndex]: a string storing the name of the nIndexth parameter (for example: "Content Length"). m_szHttpVersion: a string representing the HTTP version of the request. short m_nFileIndex […]. // Files short m_nFileNumber. The maximum length for this value is 64 bytes. The maximum length of this string is 32 bytes. char m_szDataValue[…][…].char m_szDataName […][…]. m_nFileIndex: internal use only. : H Page : 30 . m_szURI: a string representing the address of the requested page ("/" or "/INDEX. Data parameters (for POST and PUT only) m_nDataNumber: the number of data elements in the request. char m_szFilename […][…]. A maximum of 32 elements are stored. } HTTP_SERVER_DATA. HTTP_SERVER_UNKNOWN_COMMAND. HTTP_SERVER_POST. // Value of the Content-Length parameter (if any) char m_szBoundary[…]. char m_szFileType […][…]. char m_szFsFileName[…][…]. SMO/SFO-0039 Rév. HTTP_SERVER_PUT.HTML" for example). m_szDataName[nIndex]: a string storing the name of the nIndexth data element. int m_nClientPort. m_nBoundaryPos: internal use only. This string is always internally set to upper case. The maximum length of this string is 32 bytes. int m_nFileLength […]. m_szHeaderParamValue[nIndex]: a string storing the value of the nIndexth parameter. Can be : o o o o HTTP_SERVER_GET. Header parameters m_nHeaderParamNb: the number of elements in the header. The maximum length for this value is 64 bytes. A maximum of 6 files can be loaded using one request. The maximum length of this string is 32 bytes.bbb. m_szFilename[nIndex]: the name of the nIndexth downloaded file directly taken from the request. and is not added to the data structure. File parameters (for POST and PUT only): m_nFileNumber: number of files retrieved. If the request is sent with a name that includes '/' or '\' (full path to a file). the request is sent using a web browser. In a request containing raw data after the header (not separated by boundaries). : H .txt" is automatically stored in the disk specified in the HTTP_Server_Open() function. only the string after the separator is read and stored in the buffer. the data received by the server is stored in a file named "HTTP_R<n>. The file "test. m_szFileType[nIndex]: a string describing the type of the nIndexth downloaded file. Page : 31 SMO/SFO-0039 Rév.txt". - - Note: the files received through POST and PUT methods are automatically stored in the disk specified when calling HTTP_Server_Open() function. The name is adapted from m_szFileName[nIndex] to be compliant with Telium File System requirements (length of the name and characters supported). The maximum length of this string is 32 bytes. m_szBoundary: HTTP boundary found in the request.- m_szDataValue[nIndex]: a string storing the value of the nIndexth data element. If the file name already exists in the disk.ddd). m_szClientAddress: address of the client (aaa.BIN" when <n> is the file index coded in 4 hexadecimal digits format Other parameters Example The client sends a post request through the HTML form below. <H1> File selection </H1> <FORM ENCTYPE="multipart/form-data" ACTION="ProcessRequest" METHOD=POST> <INPUT TYPE=HIDDEN NAME="DATA_ONE" VALUE="Value of data one"> <INPUT TYPE=FILE SIZE=80 NAME="filename"> <INPUT TYPE=HIDDEN NAME="DATA_TWO" VALUE="2222222"> <INPUT TYPE=SUBMIT VALUE= "Send"> </FORM> m_nContentLength: value of the parameter "Content-Length" of the request. m_nClientPort: port of the client. The data structure is filled with the content of the request: the selected file is "test. m_szFileLength[nIndex]: length of the file (in bytes). The real name of the file saved in flash is put m_szFlashFileName[nIndex] (see below). m_szFsFileName[nIndex]: the name of the file stored in the server disk. the new file is not downloaded to the disk.ccc. txt" "TEST. The server has sent the request.2" "User Agent" "Mozilla/5. Buffer containing the response to send Size of the buffer response Returns HTTP_SERVER_OK or a negative error code.168.1" "/PROCESSREQUEST" 12 "Host" "192. Invalid handle parameter SMO/SFO-0039 Rév. Comment HTTP_SERVER_OK HTTP_SERVER_ERROR_HANDLE The function succeeds. const char *pcBuffer. unsigned int nDataSize).3 SEND A RESPONSE Syntax : int HTTP_Server_SendResponse ( HTTP_SERVER_HANDLE hHandle.0…" 3 "DATA_ONE" "Value of data one" "filename" "" "DATA_TWO" "2222222" 1 "test. : H Page : 32 .TXT" 146 314 "---------------------------AZY845S" "192. Include : Parameters : hHandle: pcBuffer : nDataSize : Return : Error Code < HTTP_.h > Handle on the HTTP server.61" 32718 11. const char *pcBuffer. int HTTPS_Server_SendResponse ( HTTP_SERVER_HANDLE hHandle.168.45. unsigned int nDataSize).m_nCommand: m_szHttpVersion: m_szURI: m_nHeaderParamNb: m_szHeaderParamName[0]: m_szHeaderParamValue[0]: m_szHeaderParamName[1]: m_szHeaderParamValue[1]: … m_nDataNumber: m_szDataName[0]: m_szDataValue[0]: m_szDataName[1]: m_szDataValue[1]: m_szDataName[2]: m_szDataValue[2]: m_nFileNumber: m_szFileName[0]: m_szFsFileName[0]: m_nFileLength[0]: … m_nContentLength: m_szBoundary: m_szClientAddress: m_nClientPort: HTTP_SERVER_POST "1.45. 4 STOP THE SERVER Syntax : int HTTP_Server_Close ( HTTP_SERVER_HANDLE hHandle ).5 GET INFORMATION ABOUT SSL SESSION (HTTPS ONLY) Syntax : int HTTPS_Server_GetHandles ( HTTP_SERVER_HANDLE hHandle. HTTP_SERVER_ERROR_SERVER_CLOSED The server is not running. Comment HTTP_SERVER_OK HTTP_SERVER_ERROR_HANDLE Description : The function succeeds. SSL_HANDLE* phSession. Note : 11. SSL_PROFILE_HANDLE* phProfile ) Include : Parameters : hHandle: < HTTP_. HTTP_SERVER_ERROR_SOCKET Error on server listening socket. 11. Description : This function sends an HTTP response and then close the dedicated connection.h > Handle on the HTTP server. : H Page : 33 . int HTTPS_Server_Close ( HTTP_SERVER_HANDLE hHandle ). Include : Parameters : hHandle: Return : Error Code < HTTP_. Returns HTTP_SERVER_OK or a negative error code. Invalid handle parameter This function stops the HTTP server and releases the handle and all the resources used by the server. SMO/SFO-0039 Rév.h > Handle on the HTTP server. The server has been stopped. It must be called after the success of the call to the function HTTP_Server_WaitRequest(). The destination folder is unmounted.HTTP_SERVER_ERROR_NO_REQUEST No request is currently in progress. Returns HTTP_SERVER_OK or a negative error code. Handle on the server SSL profile. Comment HTTP_SERVER_OK HTTP_SERVER_ERROR_HANDLE Description : The function succeeds. Invalid handle parameter This function retrieves the handles on the SSL connection and on the server SSL profile.phSession: phProfile: Return : Error Code Handle on the current SSL connection. phProfile will return a non-NULL value ever since the HTTPS server is successfully launched. : H Page : 34 . Note : SMO/SFO-0039 Rév. phSession will only return a non NULL value while a connection with a client is established (between a successful call to HTTPS_Server_ WaitRequest() and HTTPS_Server_SendResponse()). it exists some differences. "inet_aton" and "inet_ntoa" are deprecatated and replaced respectively by the functions :"__inet_addr". • • • • The "shutdown" function is renamed "shutdownsocket".12. The "select" function is renamed "selectsocket". The functions "gethostbyname" and "gethostbyaddr" are deprecated and replaced respectively by the functions : "gethostbyname_r" and "gethostbyaddr_r". "__inet_aton" and "__inet_ntoa". The functions "inet_addr". COMPATIBILITY The package TCP/IP is compatible with BSD interface. listed below. : H Page : 35 . SMO/SFO-0039 Rév. However. SAMPLE PROGRAMS 13. just call the following function. PPP_PERSONAL_PROFILE ). // The minimal configuration : // Just the login and the password are set. return 0. if( nState == PPP_STATE_IFUP) { // Connection success. PPP_Start( nHandle ). PPP_HANDLE nHandle = 0.. do { nState = PPP_GetState( nHandle ). void *arg = 0. PPP_Setup( nHandle. nHandle = PPP_Open( "DGPRS" ). SMO/SFO-0039 Rév. } while(( i < 60 ) && ( nState != PPP_STATE_IFUP) && ( nState != PPP_STATE_DEAD)). } } return -1. if( nHandle != 0 ) { PPP_Setup( nHandle. . int PPP_Connect( char *szLogin.1 PPP SAMPLE This section provides a simply sample to show how to perform a PPP connection through the GSM link. szPassword. ttestall( 0. : H Page : 36 . 100 ). After connecting the PSTN provider in GSM. szLogin. int i = 0. PPP_PSTN_PROFILE ).13. } The PPP configuration can be made accurately by the user.. szLogin. char *szPassword ) { int nState = 0. szPassword. PPP_SetOption( nHandle. p[1]. . unsigned int local_addr = 0. p[3] ). p[0].%d. p[2]. "Local Addr: %d.. arg = PPP_INT(0). EthernetGetOption( ETH_IFO_NETMASK.// Set several options. arg = PPP_TRUE. &arg). PPP_INFO_LCP_AUTH. unsigned int netmask_addr = 0. : H Page : 37 . void PrintNetworkInfos() { char szTemp[BUFFER_SIZE]... sprintf( szTemp. p[3] ).2 ETHERNET SAMPLE The following code shows how to get the information of the Ethernet link (local IP address and the network mask). PPP_SetOption( nHandle.%d. p[0]. .PPP_INFO_IPCP_DNS2. . PPP_SetOption( nHandle. PPP_INFO_IPCP_DNS1_ADDR. &arg ). "Netmask: %d.%d. p = (char *) &netmask_addr.%d. arg = PPP_FALSE. p[1]. &arg ). &netmask_addr ).%d\n". sprintf( szTemp. 13. PPP_SetOption ( nHandle. EthernetGetOption( ETH_IFO_ADDR. } SMO/SFO-0039 Rév. //-----------------------------// Ask for peer authentication. // Negociate DNS1 address. &arg )...%d\n". PPP_INFO_IPCP_DNS1.. unsigned char *p. but not DNS2 arg = PPP_TRUE. p = (char *) &local_addr. &local_addr ). p[2]. char szFrom[] = "myaccount@myprovider. __DFL_ICMP_ECHO_REPLY. char szLogin[] = "myaccount".123".com".BIN". __DFL_ICMP_ECHO_REPLY.com".13. The terminal reboots automatically. if( hConf != NULL ) { int bEchoReply. SMO/SFO-0039 Rév. &bEchoReply ) == __DLF_OK ) { if( bEchoReply != bOn ) { // Modify the option.3 ENABLE/DISABLE THE ICMP REPLY FACILITY This sample code below shows how to enable or disable the ICMP reply [email protected]. void ActivateReplyICMP( int bOn ) { ETHCONF_HANDLE hConf = __LoadDefaultOptions( NULL ).4 MAIL SAMPLE The sample code below shows how to send and receive an email using the dedicated interface. const char* szMessage ) { int nReturn. char szPassword[] = "mypassword". int nPort = 25.com".TXT".com. void SendMail( const char* szSubject. &bOn ). char szSmtpAddress[] = "123. It demonstrates how to modify the default parameters. __SaveDefaultOptions( hConf ). NULL // Last item must be NULL !!! }. "/TEMP/FILE2. : H Page : 38 . if( __GetDefaultOption( hConf. const char *pList[] = { "/HOST/FILE1. char szCC[] = "recipientcc@server. char szSmtpClient[] = "TELIUM_CLIENT".123. // Save the configuration. __SetDefaultOption( hConf. } } __UnloadDefaultOptions( hConf ). } } 13. char szTo[] = "recipient1@server. // No recipient in blind copy pList ).123. int bDeleteFromServer = FALSE. char* pcBuffer. szFrom. char szPopAddress[] = "123. int nReturn. szLogin. int nIndex. szMessage. nPort. &nTotalSize )..123. SMO/SFO-0039 Rév. char szLogin[] = "mylogin". strlen( szMessage ). szPassword.. hPop = POP3_Connect( szPopAddress. szCC. szLogin.nReturn = SMTP_SendUniqueMessage( szSmtpAddress. . nPort. int nMessages. FALSE ). int nTotalSize. : H Page : 39 . szTo. szSmtpClient.123". char szPassword[] = "mypassword". NULL. int nPort = 110. if( nReturn == 2 ) { // Both attached files where successfully sent } else { if( nReturn >= 0) { // At least one attached file was not sent // The message is sent without this (these) file(s) … } else { // The mail was not sent } } } void ReceiveMail( void ) { POP3_HANDLE hPop. if( hPop >= 0 ) { // Retrieve the number of message on the account nMessages = POP3_GetNbMessages( hPop. szSubject. szPassword. POP3_INFO Info. if( nReturn == 0 ) { // A message is received . } else { // Can't connect to server } } SMO/SFO-0039 Rév. nIndex. nIndex <= nMessages. nTotalSize ). } else { // Can't allocate memory } } else { // No message } POP3_Disconnect( hPop ). pcBuffer. // Erase the message from the server if( bDeleteFromServer == TRUE ) { POP3_DeleteMessage( hPop.. } } else { // Error on receiving the message } } ufree( pcBuffer ). : H Page : 40 .. nIndex ).if( ( nMessages > 0 ) && ( nTotalSize > 0 ) ) { // Allocate buffer for the total size of the messages // to avoid any overflow… pcBuffer = umalloc( nTotalSize ). &Info. nIndex++ ) { // Retrieve the message nReturn = POP3_GetMessage( hPop. if( pcBuffer != NULL ) { for( nIndex = 1. // The folder which the folder HOST for destination directory. } else { // Request a given page. strcat( szFullURI. FS_mount( "/HOST". unsigned int char char unsigned int S_FS_FILE nMode. … if ( nError == HTTP_SERVER_OK ) { strcpy( szFullURI. "/INDEX. nError = HTTP_Server_WaitRequest ( hServerHTTP. static void ServerHTTP() { int nError. &pRequest ). } // Open the page file. while(1) { // Wait for a request. "/HOST" ). return. if( HTTP_Server_Open( &hServerHTTP. "/HOST" ) != HTTP_SERVER_OK ) { // Error. strcat(szFullURI.13. hFile = FS_open(szFullURI.HTML" ). … if ( pRequest->m_nCommand == HTTP_SERVER_GET ) { // GET Command if ( strcmp( pRequest->m_szURI. szFullURI[200]. pRequest->m_szURI). "/" ) == 0 ) { // Request the default web page. } // Mount the disk with the HTTP Files. *hFile. HTTP_SERVER_HANDLE hServerHTTP. "r").5 HTTP SAMPLE The following code shows how to launch an HTTP server and how to process the GET requests. // Launch the HTTP server. 80. szDataToSend[4096]. if (hFile == NULL) { SMO/SFO-0039 Rév. 80. : H Page : 41 . nDataSize. &nMode ). HTTP_SERVER_DATA *pRequest. HTTP_SERVER_PAGE_404). nDataSize = strlen(HTTP_SERVER_PAGE_404). : H Page : 42 .// Problem to open the file. FS_close(hFile). nDataSize += FS_read( szDataToSend + nDataSize. 1. strcpy(szDataToSend. hFile). HTTP_SERVER_HTTP_200). strcpy(szDataToSend. 4096. szDataToSend. } // Send the page response HTTP_Server_SendResponse( hServerHTTP. nDataSize = strlen(HTTP_SERVER_HTTP_200). // Return the default error page. } else { // Read the page file. } } } SMO/SFO-0039 Rév. nDataSize ).
Copyright © 2024 DOKUMEN.SITE Inc.