Home

Precise/RTCS™ User's Guide

image

Contents

1. uint_32 ST RX TOTAL uint 32 ST RX MISSED uint 32 ST RX DISCARDED uint 32 ST RX ERRORS uint 32 ST TX TOTAL uint 32 ST TX MISSED uint 32 ST TX DISCARDED uint 32 ST TX ERRORS wint 32 ST RX OCTETS uint 32 ST RX UNICAST uint 32 ST RX BROADCAST uint 32 ST RX MULTICAST uint 32 ST TX UNICAST uint 32 ST TX BROADCAST uint 32 ST TX PADITRANSMITTED uint 32 ST TX PADOTRANSMITTED uint 32 ST TX PADRTRANSMITTED uint 32 ST TX PADSTRANSMITTED uint 32 ST TX PADTTRANSMITED uint 32 ST TX GENERIC ERRORS TRANSMITTED uint 32 ST RX PADIREJECTED uint 32 ST RX PADRREJECTED uint 32 ST RX PADSRECEIVED uint 32 ST RX PADORECEIVED uint 32 ST RX PADTRECEIVED uint 32 ST RX GENERICE ERRORS RECEIVED uint 32 ST RX MALFORMED PACKETS uint 32 ST RX MULTIPLE PADO RECEIVED uint 32 ST RX SERVICENAMEERRORS uint 32 ST RX ACSYSTEMERRORS uint 32 ST RX PADI uint 16 SERVICE NAME ERROR TAG LENGTH char ptr SERVICE NAME ERROR DATA uint 16 AC SYSTEM ERROR TAG LENGTH char ptr AC SYSTEM ERROR DATA uint 16 GENERIC ERROR TAG LENGTH char ptr GENERIC ERROR DATA PPPOEIF STATS STRUCT PTR PPPOEIF STATS STRUCT PTR ST RX TOTAL Total number of received packets to the driver ST RX MISSED Freescale M
2. If ACCEPT REMOTE ADDR is IPCP does this TRUE Allows the peer to negotiate a different peer IP address FALSE Accepts only REMOTE ADDR as its peer IP address NETMASK DEFAULT NETMASK If DEFAULT NETMASK is IPCP does this TRUE Dynamically calculates the link s netmask based on the negotiated local and peer IP addresses FALSE IPCP always uses NETMASK as the netmask DEFAULT ROUTE If DEFAULT ROUTE is TRUE IPCP installs the peer as a default gateway in the IP routing table ACCEPT LOCAL DNS NEG LOCAL DNS LOCAL DNS Controls whether RTCS negotiates the address of a DNS server to be used by the local resolver If ACCEPT LOCAL DNS is TRUE a peer can override LOCAL DNS If NEG LOCAL DNS is IPCP does this TRUE Attempts to negotiate LOCAL DNS as the DNS server address that is to be used by the local resolver FALSE Does not attempt to negotiate a DNS server address for the local resolver ACCEPT REMOTE DNS NEG REMOTE DNS REMOTE DNS Freescale MQX RTCS User s Guide Rev 10 362 Freescale Semiconductor Data Types Controls whether RTCS negotiates the address of a DNS server to be used by the peer resolver If ACCEPT REMOTE DNS is TRUE a peer can override REMOTE DNS If NEG REMOTE DNS is IPCP does this TRUE Attempts to negotiate REMOTE DNS as the DNS server address that is to be used by the peer resolver FALSE Does not attempt to ne
3. ipcp data IP UP PPP session up down ipcp data IP DOWN PPP session up down ipcp data IP PARAM amp GLOBAL APP CFG i ipcp data ACCEPT LOCAL ADDR FALSE ipcp data ACCEPT REMOTE ADDR FALSE ipcp data LOCAL ADDR GLOBAL APP CFG i LOCAL ADDRESS ipcp data REMOTE ADDR GLOBAL APP CFG i REMOTE ADDRESS ipcp data DEFA ipcp data NETMASK ipcp data DEFA ULT NETMASK TRUE OxFFFFFFFF ULT ROUTE FALSE error RTCS i if error f bind IPCP ihandle amp ipcp data printf AnIF bind failed error 1x error Endif Endbody void remove ppp Body uint 32 i fine the se session pointer pio pointer phandle pointer parm ssion we are removing for i 0 i lt MAX CONNECTION i Freescale MQX RTCS User s Guide Rev 10 66 Freescale Semiconductor Point to Point Drivers if GLOBAL APP CFG i PPP HANDLE phandle break y Endif Endfor OBAL APP CFG i PPP HANDLE NULL OBAL APP CFG i IO PCB HANDLE NULL OBAL APP CFG i IF HANDLE NULL NONO E Endbody 4 3 2 2 Example Initializing the Ethernet Device and PPPoE Client enet address enet local ENET ENETADDR static void PPP linkup pointer lwsem lwsem post lwsem Endbody TASK TEMPLATE STRUCT MOX templat
4. DNS init Starts DNS services 5 4 2 Using DNS Resolver DNS Resolver retrieves information such as a host address or mail information based on a domain name The DNS server to which DNS Resolver sends its queries depends on the local server name To change cc 99 the default value of the local server name see Section 5 4 2 1 Changing Default Names If a guery is successful the DNS server sends a reply to DNS Resolver DNS Resolver caches the reply so that it needs not to make the guery again for the lifetime of the resource record which is defined in the reply DNS Resolver checks the cache before it makes any guery to a DNS server Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 73 RTCS Applications 5 4 2 1 Changing Default Names If you want DNS Resolver to append a local domain name other than the default modify the global variable DNS_Local_network_name If you want to use a DNS server other than the default modify the global variable DNS_Local_server_name Name Defined in sourcelifidhshosts c as Default value global variable Local domain DNS_Local_network_name Local server DNS_Local_server_name 5 4 3 Communicating with a DNS Server DNS Resolver communicates with a DNS server the server is not a part of RTCS The DNS server either provides the answer to a query or a referral to another DNS server 5 4 4 Using DNS Services RTCS pr
5. Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 249 Function Reference 7 1 129 RTCS_if_bind_BOOTP Gets an IP address using BootP and binds it to the device interface Synopsis uint 32 RTCS if bind BOOTP _rtcs if handle rtcs if handle BOOTP DATA STRUCT PTR data ptr Parameters rtcs if handle in RTCS interface handle from data ptr in out Pointer to BootP data Description This function uses BootP to assign an IP address determines a boot file to download and determines the server from which to download it Parameter rtcs_if handle is returned by RTCS if add Return Value e RTCS OK success Error code failure See Also RTCS if add RTCS if bind RTCS if bind DHCP RTCS if bind IPCP BOOTP DATA STRUCT Example BOOTP DATA STRUCT boot data uint 32 boot function void BOOTP DATA STRUCT boot data enet handle ehandle rtcs if handle ihandle uint 32 error error ENET initialize 0 enet local 0 amp ehandle if error return error error RTCS create if error return error error RTCS if add ehandle RTCS IF ENET amp ihandle if error return error memset amp boot data 0 sizeof boot data error RTCS if bind BOOTP ihandle amp boot data if error return error Freescale MQX RTCS User s Guide Rev 10 250 Freescale Semiconductor Function Reference rror RTCS exec TFTP SREC boot data
6. Start the telnet server result TELNETSRV_init Telnet server SHELL TELNETD PRIO SHELL TELNETD STACK amp Telnetd shell template ha 3 Return Value RTCS OK success Error code failure See Also TELNET connect RTCS TASK Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 321 Function Reference 7 1 170 TFTPSRV access Decides whether to allow access to a TFTP client Synopsis boolean TFTPSRV_access char ptr string ptr uint 16 request type Parameters string ptr in String name that identifies requested device request type in Type of access requested one of the following TFTPOP RRQ TFTPOP WRQ Description TFTP Server calls the function every time a TFTP client initiates a read request or a write request The function that accompanies RTCS allows all read access and denies all write access If you want to enforce different access restriction you can supply your own function to override the one that accompanies RTCS Return Value TRUE allow access FALSE deny access See Also TFTPSRV init Freescale MQX RTCS User s Guide Rev 10 322 Freescale Semiconductor Function Reference 7 1 171 TFTPSRV init Starts TFTP Server Synopsis uint 32 TFTPSRV init char ptr name uint 32 priority uint 32 stacksize Parameters name in String name to assign to TFTP Server task priority in Priority to assign to TFTP Server
7. 26 Freescale Semiconductor Setting Up the RTCS At initialization time space for an internal configuration structure is allocated The configuration structure e Partitions the address space Maintains state information Points to a list of application level gateways Provides connection timeout settings for inactive sessions Identifies the ports and ICMP query IDs that are managed through NAT on the private network 2 15 1 Changing Inactivity Timeouts Once started NAT uses the RTCS event queue to monitor sessions between a private and public host An event timer is used to determine when a session is over The amount of time to wait before terminating an inactive UDP or TCP session is defined in the nat h header file and is dynamically configurable through the setsockopt function When setsockopt is called the application passes to it the address of the NAT timeout structure nat timeouts The structure provides three inactivity timeout values for e TCP sessions default timeout is 15 minutes UDP or ICMP sessions default timeout is five minutes TCP sessions in which a FIN or RST bit has been set default timeout is two minutes All three values are overwritten each time the application provides a nat timeouts structure To avoid changing an existing timeout value the application must supply a zero value for that particular timeout 2 15 2 Specifying Port Ranges During a session NAT u
8. Attach the socket to this task printf WnCHILD about to attach the socket Socket handle RTCS attachsock socket handle Freescale MQX RTCS User s Guide Rev 10 234 Freescale Semiconductor Function Reference if socket handle RTCS SOCKET ERROR Continue managing the socket eise Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 235 Function Reference 7 1 117 RTCS_create Creates RTCS Synopsis uint 32 RTCS_create void Description This function allocates resources that RTCS needs and creates TCP IP task Return Value e RTCS_OK success Error code failure See Also e RTCS if add e RTCS if bind Example See Section 2 15 6 Example Setting Up RTCS Freescale MQX RTCS User s Guide Rev 10 236 Freescale Semiconductor 7 1 118 RTCS_detachsock Relinquishes ownership of the socket Synopsis uint_32 RTCS detachsock uint 32 socket Parameters socket in Socket handle Description The function removes the calling task from the socket s list of owners Parameter socket is returned by one of the following e socket e accept e RTCS attachsock This function blocks although the command is serviced and responded to immediately Return Value RTCS_OK success e Specific error code failure See Also accept e RTCS attachsock socket Example See RTCS attachsock Freescale M
9. To enable IP forwarding and Network Address Translation IP forward required for NAT or IPShield To not verify the TCP checksums on incoming packets TCP bypass rx To not generate the TCP checksums on outgoing packets TCP bypass tx 2 8 1 Enabling IP Forwarding This parameter provides the ability to route packets between network interfaces required for NAT or IPShield Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 23 Setting Up the RTCS 2 8 2 Bypassing TCP Checksums In isolated networks if the performance of data transfer is an issue you might want to bypass the generation and verification of TCP checksums If you bypass the verification of TCP checksums on incoming packets RTCS does not detect errors that occur in the data stream However the probability of these errors is low because the underlying layer also includes a checksum that detects errors in the data stream If you bypass the generation of TCP Note checksums on outgoing packets you violate the TCP specification 2 9 lnitializing Device Interfaces RTCS supports any driver written to a published standard such as PPP IPCP and PPP over Ethernet Because RTCS is independent of devices it has no built in knowledge of the device or devices that an application is using or plans to use to connect to a network Therefore an application must Initialize each interface to each device
10. Freescale MQX RTCS User s Guide Rev 10 178 Freescale Semiconductor Function Reference 7 1 66 ipcfg_bind_dhcp Binds Ethernet device to network using DHCP protocol polling mode Synopsis uint 32 ipcfg bind dhcp uint_32 device boolean try auto ip Parameters device in device identification try auto ip in try the auto ip automatic assign address 1f DHCP binding fails Description This function initiates the process of binding the device to network using the DHCP protocol As the DHCP address resolving may take up to one minute there are two separate non blocking functions related to the DHCP binding ipcfg bind dhcp must be called first repeatedly till it returns a result other than RTCSERR IPCFG BUSY In case this function returns IPCFG OK the process may continue by calling ipcfg poll dhcp periodically again until the result is other than RTCSERR IPCFG BUSY Both functions must be called with same value of the first two parameters According to second parameter additional auto IP binding can take place after DHCP fails The polling process should be aborted if any of the two functions return result other than RTCS OK or RTCSERR IPCFG BUSY In this case the network interface is left in unbound state An alternative blocking method of DHCP bind is ipefg bind dhcp wait See the example below how this call is implemented internally Return Value e IPCFG OK success RTCSERR IPC
11. scan for networks iwcfg set scan DEFAULT DEVICE NULL Example output ssid tplink bssid 94 c 6d a5 51 b channel 1 strength indicator 183 Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 219 A a E Function Reference ssid Faz bssid 0 21 91 12 da cc channel 1 strength indicator 172 scan done Freescale MQX RTCS User s Guide Rev 10 220 Freescale Semiconductor Function Reference 7 1 105 listen Puts the stream socket into the listening state Synopsis uint 32 listen uint 32 socket uint 16 backlog Parameters socket in Socket handle backlog in Ignored Description Putting the stream into the listening state allows incoming connection requests from remote endpoints After the application calls listen it should call accept to attach new sockets to the incoming requests This function blocks but the command is immediately serviced and replied to Return Value RTCS OK success e Specific error code failure See Also accept bind socket Example See accept Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 221 Function Reference 7 1 106 MIB1213 init Initializes the MIB 1213 Synopsis void MIB1213 init void Description The function installs the standard MIBs defined in RFC 1213 If the function is not called SNMP Agen
12. Error code failure See Also RTCS exec TFTP BIN e RTCS if bind BOOTP BOOTP DATA STRUCT Freescale MQX RTCS User s Guide Rev 10 266 Freescale Semiconductor Function Reference 7 1 138 RTCS_load_TFTP_COFF Downloads the COFF boot file Synopsis uint 32 RTCS load TFTP COFF ip address Server char ptr filename Parameters server in IP address of the TFTP Server filename in Name of the file to download Description This function downloads the binary file from the TFTP Server This function is the same as RTCS exec TFTP COFFYQ with the exception that it does not run the file after it downloads the file For information on the values of server and filename see Table 7 1 Return Value RTCS OK success Error code failure See Also RTCS exec TFTP COFF e RTGS if bind BOOTP BOOTP DATA STRUCT Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 267 Function Reference 7 1 139 RTCS_load_TFTP_SREC Downloads the S Record file Synopsis uint 32 RTCS load TFTP SREC ip address Server char ptr filename Parameter server in IP address of the TFTP Server filename in Name of the file to download Description This function downloads the S Record file from the TFTP Server This function is the same as RTCS exec TFTP SRECY with the exception that it does not run the file after it downloads the file For information on the values
13. bind recvfrom e RTCS geterror e socket Freescale MQX RTCS User s Guide Rev 10 280 Freescale Semiconductor Function Reference Examples a Send 500 bytes of data to IP address 192 203 0 54 port number 678 uint_32 handle sockaddr_in remote sin uint_32 count char my buffer 500 for i20 i lt 500 i my buffer il i amp Oxff memset char amp remote sin 0 sizeof sockaddr in remote sin sin family AF INET remote sin sin port 678 remote sin sin addr s addr 0xC0CB0036 count sendto handle my buffer 500 0 struct sockaddr amp remote sin sizeof sockaddr in if count 500 printf Ansendto failed with count ld and error lx count RTCS geterror handle b Send Hello world to FE80 2e0 4cFF FE68 2343 port 7007 using IPv6 UDP protocol uint 32 socket udp struct addrinfo foreign addrv6 res pointer to PC IPv6 address struct addrinfo local addrv6 res pointer to Board IPv6 address struct addrinfo hints hints used for getaddrinfo hints ai family AF UNSPEC hints ai socktype SOCK DGRAM hints ai flags AI NUMERICHOST AI CANONNAME getaddrinfo FE80 0200 5EFF FEA8 0016 2 7007 amp hints amp local addrv6 res hints ai family AF UNSPEC hints ai socktype SOCK DGRAM hints ai flags AI NUMERICHOST AI CANONNAME getaddrinfo FE80 260 4cFF FE68 2343 7007 amp hints amp f
14. uchar ptr optptr uint 32 optlen uint 32 error Start DHCP Server error DHCPSRV init DHCP server 7 2000 if error RTCS OK printf AnFailed to initialize DHCP Server error x error return Freescale MQX RTCS User s Guide Rev 10 128 Freescale Semiconductor Function Reference printf NnDHCP Server running Fill in the required parameters 192 168 0 1 dhcpsrv data SERVERID 0xC0A80001 Infinite leases dhcpsrv data LEASE OxFFFFFFFF Joe 255 2557255 Dg o7 dhcpsrv data MASK 0xFFFFFFO0 TFTP server address dhcpsrv data SADDR 0xC0A80002 memset dhcpsrv data SNAME 0 sizeof dhcpsrv data SNAME memset dhcpsrv data FILE 0 sizeof dhcpsrv data FILE Fill in the options optptr dhcpsrv options optlen sizeof dhcpsrv options Default IP TTL HCPSRV option int8 amp optptr amp optlen 23 64 MTU HCPSRV option intl6 amp optptr amp optlen 26 1500 Renewal time HCPSRV option int32 amp optptr amp optlen 58 3600 Rebinding time HCPSRV option int32 amp optptr amp optlen 59 5400 Domain name HCPSRV option string amp optptr amp optlen 15 arc com Broadcast address HCPSRV option addr amp optptr amp optlen 28 0xC0A800FF Router list ters 0 0xC0A80004 ters 1 0xC0A80005 routers 2 0xC0A80006 DHCPSRV option addrlist amp optptr amp op
15. MIB find objectname MIB set objectname SNTP Client SNTP init SNTP oneshot Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 327 Function Reference Table 7 2 continued Sockets accept bind connect getpeername getsockname getsockopt listen recv recvfrom RTCS attachsock RTCS detachsock RTCS geterror RTCS selectall RTCS selectset send sendto setsockopt shutdown socket Statistics ARP stats ENET get stats part of MQX ICMP stats IGMP_stats inet_pton IPIF_stats NAT_stats TCP_stats UDP_stats Telnet Client TELNET_connect Telnet Server TELNETSRV_init TFTP Server TFTPSRV_access TFTPSRV_init Freescale MQX RTCS User s Guide Rev 10 328 Freescale Semiconductor Chapter 8 Data Types 8 1 Data Types for Compiler Portability Name Bytes From To Description boolean 4 0 Not zero Non zero TRUE Zero FALSE ieee double 8 2 225074 1 7976923 Double precision IEEE E 308 E 308 floating point number ieee single 4 8 43E 37 3 37E 38 Single precision IEEE floating point number pointer 4 0 OxFFFFFFFF Generic pointer char 1 128 127 Signed character char ptr 4 0 OxFFFFFFFF Pointer to char uchar 1 0 255 Unsigned character uchar ptr 4 0 OxFFFFFFFF Pointer to uchar int 8 1 128 127 Signed
16. RTCS User s Guide Rev 10 Freescale Semiconductor 147 Function Reference 7 1 42 gethostbyaddr Gets the HOSTENT_STRUCT structure for an IP address Synopsis hostent PTR_ gethostbyadar const char PTR addr ptr uint 32 len uint 32 type Parameters addr ptr in Pointer to the IP address in numeric form len in Length of the address must be sizeof struct in addr type in Type of address must be AF INET Description If the function is successful a static HOSTENT STRUCT is overwritten every time that the function is called Return Value Pointer to a HOSTENT STRUCT structure success NULL failure See Also gethostbyname e HOSTENT STRUCT Example struct in addr my ip address struct hostent PTR hostname Initialize my ip address s addr hostname gethostbyaddr amp my ip address sizeof my ip address AF INET printf Hostname is s n hostname h name Freescale MQX RTCS User s Guide Rev 10 148 Freescale Semiconductor Function Reference 7 1 43 gethostbyname Gets the HOSTENT STRUCT structure for a host name Synopsis HOSTENT STRUCT PTR gethostbyname char ptr name Parameters name in Pointer to a string that is a properly formatted domain name see description Pointer to a string that is a properly formatted domain name see description Return Value Pointer to a HOSTENT STRUCT structure success NULL failure see
17. ST RX MISSED Received discarded due to lack of resources ST RX DISCARDED Received discarded for all other reasons ST RX ERRORS Received with internal errors ST TX TOTAL Transmitted total ST TX MISSED Transmitted discarded due to lack of resources ST TX DISCARDED Transmitted discarded for all other reasons ST TX ERRORS Freescale MQX RTCS User s Guide Rev 10 Data Types Freescale Semiconductor 333 Data Types Transmitted with internal errors ERR_RX RX error information ERR_TX TX error information ST_RX_REQUESTS Valid ARP requests received ST RX REPLIES Valid ARP replies received ST TX REQUESTS ARP requests sent ST TX REPLIES ARP replies sent ST ALLOCS FAILED ARP alloc returned NULL ST CACHE HITS ARP cache hits ST CACHE MISSES ARP cache misses ST PKT DISCARDS Data packets discarded due to a missing ARP entry Freescale MQX RTCS User s Guide Rev 10 334 Freescale Semiconductor A Data Types 8 3 3 BOOTP_DATA_STRUCT A pointer to this structure is an input parameter to RTCS if bind BOOTP typedef struct bootp data struct _ip address SADDR uchar SNAME 64 uchar BOOTFILE 128 uchar OPTIONS 64 BOOTP DATA STRUCT PTR BOOTP DATA STRUCT PTR SADDR IP address of the boot file server SNAME Host name that corresponds to SADDR BOOTFILE Boot file to load OPTIONS BootP options Freescale MQX RTCS
18. Using Sockets 3 23 Establishing Stream Socket Connections An application can establish a connection to a stream socket in one of the following ways e Passively by listening for incoming connection requests by calling listen followed by accept e Actively by generating a connection request by calling connect 3 23 4 Establishing Stream Socket Connections Passively By calling listen an application can passively put an unconnected socket into a listening state after which the local socket endpoint responds to a single incoming connection request After it calls listen the application calls accept which returns a new socket handle and lets the application accept the incoming connection request Usually the application calls accept immediately after it calls listen The application uses the new socket handle for all communication with the specified remote endpoint until one or both endpoints close the connection The original socket remains in the listening state and continues to be referenced by the initial socket handle that socket returned The new socket that the listen accept mechanism creates inherits the socket options of the parent socket 3 23 2 Establishing Stream Socket Connections Actively By calling connect an application can actively establish a stream socket connection to the remote endpoint that the function specifies If the remote endpoint is not in the listening state connect fa
19. connection based buffered Freescale MQX RTCS User s Guide Rev 10 398 Freescale Semiconductor Protocols and Policies Sequence port number Sequence number Acknowledgement number HLen Code bits Checksum Urgent pointer Figure A 10 TCP Segment In an IP datagram that contains a TCP segment the Protocol field contains six TCP segment TCP segment L i Ethernet frame Data Figure A 11 TCP Segment in an Ethernet Frame AT BootP Bootstrap Protocol RFC 951 is used to get an IP address based on an ethernet address load an executable boot file and run that file BootP is built on top of UDP IP and one of FTP TFTP or SFTP The RTCS implementation of BootP uses TFTP Applications that use BootP require a client and a server RTCS provides the BootP client Bootstrapping consists of two phases Phase one The client determines its IP address the server s IP address and the boot filename using BootP The client can override any of these values by specifying any of them Phase two The client transfers the file using TFTP Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 399 Protocols and Policies BootP packet BootP packet UDP datagram Data Ethernet frame Data Figure A 12 BootP Packet in an Ethernet Frame cic II A 8 HDLC To encapsulate datagrams PPP uses HDLC like framing RFC 1662 HDLC is an ISO protocol defined in ISO IEC
20. nt_32 OPT CHECKSUM BYPASS opt length failed with error 1x status Example 7 4 Changing Maximum Port Number Option Change the maximum port number used by Freescale MQX NAT to 30000 and do not change the minimum port number nat ports ports uint 32 error ports port min 0 No modification ports port max 30000 error setsockopt RTCS SOCKET ERROR SOL NAT RTCS SO NAT PORTS amp ports sizeof ports Change the TCP and UDP inactivi ty timeouts Change the TCP and UDP inactivity timeout values and do not change the FIN timeout value Freescale MQX RTCS User s Guide Rev 10 296 Freescale Semiconductor Function Reference nat_timeouts nat_touts uint 32 error nat touts timeout tcp 700000 Time in milliseconds nat touts timeout udp 500000 Time in milliseconds nat touts timeout fin 0 No modification ll error setsockopt RTCS SOCKET ERROR SOL NAT RTCS SO nat timeouts amp nat_ touts sizeof nat touts Example 7 5 Changing the TX TTL uint 32 handle uint 32 status uint 8 opt value 64 status setsockopt handle SOL IP RTCS SO IP TX TTL void amp opt value sizeof opt value if status RTCS OK printf inError setsockopt failed with error 1x status Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 297 Function Reference 7 1 149 shutdown Shuts down the soc
21. optlen in out Pointer to the number of bytes remaining in the option list Passed in before optval is added Passed out after optval is added opttype in Option type to add to the list see RFC 2132 optval in Value to add Description Function DHCP option int32 adds a 32 bit value to the list of DHCP options for DHCP Server The application subsequently passes parameter optptr pointer to the option list to DHCPSRV ippool add Return Value TRUE success FALSE failure not enough room in the option list See Also DHCPCLNT find option e DHCPSRV ippool add e DHCP option addr DHCP option addrlist e DHCP option int8 e DHCP option int16 e DHCP option string e DHCP option variable Example See RTCS if bind DHCP and DHCPSRV init Freescale MQX RTCS User s Guide Rev 10 122 Freescale Semiconductor Function Reference 7 1 22 DHCP_option_int8 Adds an 8 bit value to the list of DHCP options for DHCP Server Synopsis boolean DHCP option int8 uchar ptr PTR_ optptr uint 32 PTR optlen uchar opttype uchar optval Description Function DHCP option int8 adds an 8 bit value to the list of DHCP options for DHCP Server The application subsequently passes parameter optptr pointer to the option list to DHCPSRV ippool add Parameters optptr in out Pointer to the option list optlen in out Pointer to the number of bytes remaining in
22. uint 32 ST RX DELIVERED uint 32 ST RX FORWARDED uint 32 ST RX BAD VERSION uint 32 ST RX BAD CHECKSUM uint 32 ST RX BAD SOURCE uint 32 ST RX SMALL HDR uint 32 ST RX SMALL DGRAM uint 32 ST RX SMALL PKT uint 32 ST RX TTL EXCEEDED uint 32 ST RX FRAG RECVD uint 32 ST RX FRAG REASMD uint 32 ST RX FRAG DISCARDED uint 32 ST TX FRAG SENT uint 32 ST TX FRAG FRAGD uint 32 ST TX FRAG DISCARDED IP STATS PTR IP STATS PTR ST RX TOTAL Total number of received packets ST RX MISSED Incoming packets discarded due to lack of resources ST RX DISCARDED Incoming packets discarded for all other reasons ST RX ERRORS Internal errors detected while processing an incoming packet ST TX TOTAL Total number of transmitted packets Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 357 Data Types ST_TX_MISSED Packets to be sent that were discarded due to lack of resources ST_TX_DISCARDED Packets to be sent that were discarded for all other reasons ST_TX_ERRORS Internal errors detected while trying to send a packet ERR_RX RX error information ERR_TX TX error information ST RX HDR ERRORS Discarded error in the IP header ST RX ADDR ERRORS Discarded illegal destination ST RX NO PROTO Datagrams larger than the frame ST RX DELIVERED Datagrams delivered to the upper layer ST RX FORWARDED Datagrams forwarded The following are included in S7 RX DISCARDED and ST RX HDR ER
23. 233 Function Reference 7 1 116 RTCS attachsock Takes ownership of the socket Synopsis uint 32 RTCS attachsock uint 32 socket Parameters socket in Socket handle Description The function adds the calling task to the socket s list of owners This function blocks although the command is serviced and responded to immediately Return Value New socket handle success e RTCS SOCKET ERROR failure See Also accept e RTCS detachsock Example A main task loops to accept connections When it accepts a connection it creates a child task to manage the connection it relinguishes control of the socket by calling RTCS_detachsock and then creates the child with the accepted socket handle as the initial parameter while TRUE Issue ACCEPT TELNET accept skt accept TELNET listen skt amp peer addr amp addr len if TELNET accept skt RTCS SOCKET ERROR Transfer the socket and create the child task to look after the socket if RTCS detachsock TELNET accept skt RTCS OK child task task create LOCAL ID CHILD TELNET accept skt else printf Anaccept failed error Ox lx RTCS geterror TELNET accept skt The child attaches itself to the socket for which the main task transferred ownership void TELNET Child task uint 32 socket handle
24. 316 Freescale Semiconductor Function Reference 7 1 166 socket Creates the socket Synopsis uint 32 socket uint 16 protocol family uint 16 type uint 16 protocol Parameters protocol family in Protocol family must be PF INET protocol family IP addressing type in Type of socket one of the following SOCK STREAM SOCK DGRAM protocol in Unused Description The application uses the socket handle to subsequently use the socket This function blocks although the command is serviced and responded to immediately Return Value Socket handle success e RTCS SOCKET ERROR failure See Also e bind Example See bind Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 317 Function Reference 7 1 167 TCP_stats Gets a pointer to TCP statistics Synopsis TCP STATS PTR TCP stats void Description Function TCP_stats takes no parameters It returns the TCP statistics that RTCS collects Return Value Pointer to the TCP_STATS structure See Also ARP stats ENET get stats ICMP stats IGMP stats inet pton IPIF stats UDP stats TCP STATS Example See ARP stats Freescale MQX RTCS User s Guide Rev 10 318 Freescale Semiconductor Function Reference 7 1 168 TELNET_connect Starts Telnet Client which starts the shell that accepts a command to start a Telnet session with a Telnet server Synopsis
25. Biti d it i dea e ata 298 A ere seceta aos dn Iat ti Ein aa Tc ani da ot el d d ip e A d UR ad 300 151SNMP_trap_warmStart i es acea arat da aaa ad ae ema ete e d dna a ai d 301 sa oNMP irap COSI aia ra arta 302 158SNMP trap authenticationFailure 4AA 303 539 gui INKDOWN cecs aceea eee e aia ale dna e a a icu 304 Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 9 7 1 1558NMP_trap_myLinkDown o e e aa amalia ata sa a Rs Ronde eviews ae 305 7A ISOSNMP trap INKUDO na cear di eae inna Re Be RE EA dr da EE A a Mn e Ra 306 11 187 5INMP Wap userSpeb ER RAO UR ER a 307 Fr tap WAT u a sax OR RECORDER oda a E ORCI OR REF a 308 7 1 159S8NMPv2 trap coldStart GA FF aa 309 J 1 1609NMPv2 trap authenticatiariFallute 4524053837353 mew GR Sn Go RW 310 1 1SN AP y rap Tin DEWR ons reece DR GC DWG Un UR vas 311 7 1 1025NMPV2_ tap linKUDO io GU rd ee eee ee AYN 312 7 1 168SNMPV2 trap userSpec ai i tea pas beta adi eat ad ba b i 313 FASSI AINI as pi CER RA O apes eae eRe mes 314 7 1 165S5NTPONESRO osos se serrian aoe na dae 316 ls nar saiia me O REEE E eed ae E Ea Y ew dod 317 UN AA AA REALE PARERE seed ii mm NT AT EF 318 T I lG TELNE F CONMECI adesse Casi ERu dare rre 319 AAA TELE TS AV MU wie aa b ase ce hte AA AA 320 tAATOVETPSAV ACCESS cateii GR ES AA AREREAERAddEPqxu PER RE RP 322 AACE Pon DD ueque REF n e e ea aaa d ie ae Gan Gb Lo DG Cd 323 aras e A dcus
26. For PPPOE Driver pio ppp handle phandle IPCP DATA STRUCT ipcp data LWSEM STRUCT ppp sem PPPOE CLIENT INIT DATA STRUCT PTR init ptr static char MySecretName 64 static char MySecretPassword 64 static PPP SECRET MySecrets 2 char ptr login string char ptr password static void PPP linkup pointer lwsem lwsem post lwsem error RTCS create if error printf AnFailed to create RTCS error SX error return Freescale MQX RTCS User s Guide Rev 10 100 Freescale Semiconductor Function Reference Enable 1P forwarding IP forward TRUE Set up the Ethernet driver error ENET initialize ENET DEVICE enet local 0 amp ehandle if error printf AnFailed to initializ ENET strerror error thernet driver Ss ti return Set up PPPOE Driver init ptr mem alloc zero sizeof PPPOE CLIENT INIT DATA STRUCT init ptr gt EHANDLE ehandle use the default values for rest of the variables pio iopcb pppoe client init init ptr error PPP initialize pio amp phandle if error printf nFailed to initialize PPP Driver x error return iopcb open pio PPP lowerup PPP lowerdown phandle error RTCS if add phandle RTCS IF PPP amp ihandle if error printf AinFailed to add interface for PPP error x error return _lwsem create amp p
27. Nagle algorithm RTCS uses the Nagle algorithm defined in RFC 896 to coalesce short segments for stream sockets name See host name name server A server that maps host names to their associated attributes NAT Network Address Translation The traditional or outbound method of routing IPv4 datagrams transparently in which public IP addresses are mapped to unregistered private addresses and the other way around The router between the public and private networks performs session based translation See also application level gateway and session NCP Network Control Protocol Network control protocols negotiate a PPP link for use by a network layer protocol See also PCP negotiate See configure a link net See network network A physically connected set of hosts network address See address Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 419 network byte order Big endian format So that computers with different endian formats can communicate the Internet protocols specify this canonical byte order convention for data transmitted over the network See also host byte order Network Control Protocol See NCP network identifier That portion of an IP address that corresponds to a network or the internet network layer That portion of the OSI model that is responsible for data transfer across the network independent of both the media that make up the underlying subnetworks and
28. Return Value none See Also e httpd init e httpd server init Example HTTPD ROOT DIR STRUCT root dir uU Ihe Lg 0 0 table termination record H HTTPD STRUCT server server httpd server init root dir AMlindex html while 1 httpd_server poll server 1 user stuff come here only non blocking calls Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 161 Function Reference 7 1 53 HTTPD SET PARAM ROOT DIR Macro setting the HTTP server root directory mapping Synopsis HTTPD SET PARAM ROOT DIR server val Parameters server in pointer to server structure returned by httpd init or httpd server init val in pointer to root directories table array of HTTPD_ROOT_DIR_STRUCT Description This macro sets the root directory mapping array pointer in the HTTP server structure Example HTTPD ROOT DIR STRUCT root dir mM tfs usb Maan e 0 O table termination record allocate default values params httpd default params NULL if params 1 server httpd init params HTTPD SET PARAM ROOT DIR server root dir Freescale MQX RTCS User s Guide Rev 10 162 Freescale Semiconductor Function Reference 7 1 54 HTTPD SET PARAM INDEX PAGE Macro setting the HTTP server default page name Synopsis HTTPD SET PARAM INDEX PAGE server val Parameters server in pointer to server
29. error RTCS if bind IPCP ihandle amp ipcp data if error return error lwsem wait amp boot sem printf IPCP is up in return 0 Freescale MQX RTCS User s Guide Rev 10 260 Freescale Semiconductor Function Reference 7 1 134 RTCS_if_rebind_DHCP Binds a previously used IP address to the device interface Synopsis uint 32 RTCS if rebind DHCP _rtcs if handle rtcs if handle ip address address ip address netmask uint 32 lease ip address Server DHCP DATA STRUCT PTR params uchar ptr optptr uint 32 optlen Parameters handle in RTCS interface handle address in IP address for the interface netmask in IP address of the network or subnet mask for the interface lease in Duration in seconds of the lease server in IP address of the DHCP Server params Optional parameters params gt CHOICE_ FUNC params gt BIND_FUNC params gt REBIND_FUNC params gt UNBIND_FUNC params gt FAILURE_FUNC params gt FLAGS optptr in One of the following Pointer to the buffer of DHCP options see RFC 2132 NULL optlen in Number of bytes in the buffer pointed to by optptr Description Function RTCS if rebind DHCPY uses DHCP to get an IP address and bind it to the device interface Parameter rtcs if handle is returned by RTCS if add This function blocks until DHCP completes initialization but not until it binds the interface Return Value e RTCS O
30. n s failed to initialize error SX taskname error _task block Endif Enable IP forwarding IP forward TRUE Initialize the Ethernet device error ENET initialize ENET DEVICE enet local 0 amp ehandle if error printf AnENET initialize s ENET strerror error task block address REMOTE ADDRESS BASE for i 0 i lt MAX CONNECTION i GLOBAL APP CFG i PPP HANDLE NULL GLOBAL APP CFG i GLOBAL APP CFG i G G IO PCB HANDLE NULL LOCAL ADDRESS SERVER ADDRESS D OBAL APP CFG i OBAL APP CFG i Endfor REMOTE A SS address i IF HANDLE NULL U W initialize the init structure init ptr mem alloc zero sizeof PPPOE SERVER INIT DATA STRUCT init ptr gt SESSION UP init ppp session init ptr gt SESSION DOWN remove ppp session init ptr AC NAME AC NAME STRING init ptr PARAM NULL use default values for other values RTCS msgqueue create amp APP MSGO pppoe server init amp srv handle init ptr pppoe server if add srv handle ehandle PPP ACCM 0 printf AnPPPoE server ready n while TRUE app info RTCS msgqueue receive amp APP MSGQ 0 if app info gt PPP HANDLE printf AnConnection establishe
31. uint 32 RTX MIN TIMEOUT uint 32 RTX MAX TIMEOUT uint 32 RTX MAX RETRY boolean SEND PADI FOR EVER void CODE PTR CONNECTION TIME OUT pointer uint 32 CODE PTR SEND PADI TAGS EXTRA uchar ptr uint 32 CODE PTR SEND PADR TAGS EXTRA uchar ptr boolean CODE PTR PARSE PADO TAGS EXTRA pointer boolean CODE PTR_ PARSE PADS TAGS EXTRA pointer PPPOE CLIENT INIT DATA STRUCT _PTR_ PPPOE CLIENT INIT DATA STRUCT PTR EHANDLE Pointer to the initialized Ethernet handle from ENET initialize The application must initialize the field SERVICE NAME Pointer to the service name to open for the session If you set the field to NULL it is ignored AC NAME Pointer to the name of the access concentrator to negotiate a session with If you set the field to NULL any access concentrator is used and the first access concentrator that responds with a PADO packet is accepted HOST UNIQUE If you set the field to TRUE the host unique ID is used for the client session If you set the field to FALSE the host unique ID is not used RTX TASK PRIORITY Task priority for PPPOE rtx task If you set the field to zero iopcb pppoe client init sets it to the default value six RTX TASK STACK Extra stack space needed for PPPOE rtx task Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 369 Data Types RTX_MIN_TIMEOUT Minimum time to wait before retransmitting a disco
32. value len Length of the value in bytes In case the objectname is an INTEGER ASN 1 encoded you can simplify the parsing by using the built in function RTCSMIB int read value ptr value len The MIB set objectname function should return one of the following codes e SNMP ERROR noError The operation is successful e SNMP ERROR wrongValue Value cannot be assigned because it is illegal SNMP ERROR inconsistentValue Value is legal but it cannot be assigned other reason SNMP ERROR wrongLengtn value len is incorrect for this object type SNMP ERROR resourceUnavailable There are not enough resources SNMP ERROR genErr Any other reason Freescale MQX RTCS User s Guide Rev 10 86 Freescale Semiconductor RTCS Applications 5 125 Processing the MIB File There are several helper AWK scripts accompanying the RTCS installation e def2c awk should be used to generate the output C file This file should be added to project and compiled by standard C compiler together with RTCS library or end the application Use this script as gawk f def2c awk mymib def gt mymib c def2mib awk may be used to compile the definition file to a standard MIB syntax acceptable by majority of SNMP browsers Use this script as gawk f def2mib awk mymib def gt mymib mib mib2def awk may be used in early development stages when a standard MIB description file is av
33. 10 114 Freescale Semiconductor Function Reference Return Value e RTCS OK success Specific error code failure See Also e RTCS if bind family of functions e socket e sockaddr in e sockaddr Examples a Binds a socket to port number 2010 uint 32 sock sockaddr_in local_sin uint_32 result sock socket AF INET SOCK DGRAM 0 if sock RTCS_SOCKET ERROR printf nError socket create failed return memset char amp local sin 0 sizeof local sin local sin sin family AF INET local sin sin port 2010 local sin sin addr s addr INADDR ANY result bind sock struct sockaddr amp local sin sizeof sockaddr in if status RTCS OK printf MnError bind failed with error code 1x result b Binds a socket to port number 7007 using IPv6 protocol uint 32 socket udp struct addrinfo local addrv6 res pointer to Board IPv6 address struct addrinfo hints hints used for getaddrinfo hints ai family AF UNSPEC hints ai socktype SOCK DGRAM hints ai flags AI PASSIVE getaddrinfo NULL 7007 amp hints amp local addrv6 res Socket udp socket AF INET6 SOCK DGRAM 0 error bind socket udp sockaddr local addrv6 res ai addr sizeof struct sockaddr in6 Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 115 Function Reference 7 1 16 connect Connects the stream socket to the remote
34. A value of one indicates a single transmission with no follow up retransmissions A value of zero indicates that Duplicate Address Detection is not performed on tentative addresses 2 16 3 Application specific default settings 2 16 3 1 FTP Client 2 16 3 1 1 FTPCCFG SMALL FILE PERFORMANCE ENANCEMENT Set to 1 better performance for small files less than 4MB 2 16 3 1 2 FTPCCFG BUFFER SIZE FTP Client buffer size 2 16 3 1 3 FTPCCFG WINDOW SIZE FTP Client maximum TCP packet size 2 16 3 2 FTP Server 2 16 3 2 1 FTPDCFG_SHUTDOWN_OPTION Flags used in shutdown for close connection Default value FLAG ABORT CONNECTION 2 16 3 2 2 FTPDCFG DATA SHUTDOWN OPTION Flags used in shutdown for data termination Default value FLAG CLOSE TX Freescale MQX RTCS User s Guide Rev 10 38 Freescale Semiconductor Setting Up the RTCS 2 16 3 2 3 FTPDCFG_USES_MFS Enable MFS support 2 16 3 2 4 FTPDCFG ENABLE MULTIPLE CLIENTS Enable simultaneous client connections 2 16 3 2 5 FTPDCFG ENABLE USERNAME AND PASSWORD Set to 1 for request user name and password for connect to server 2 16 3 2 6 FTPDCFG ENABLE RENAME Default value 1 2 16 3 2 7 FTPDCFG WINDOW SIZE Maximum TCP packet size Override in application by setting FTPd window size 2 16 3 2 8 FTPDCFG BUFFER SIZE FTP Server buffer size Override in application by setting FTPd buffer size 2 16 3 2 9 FTPDCFG CONNECT TIMEOUT Connection timeout 2 16 3
35. Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 125 Function Reference 7 1 25 DHCPCLNT_find_option Searches a DHCP message for a specific option type Synopsis uchar ptr DHCPCLNT find option uchar ptr msgptr uint 32 msglen uchar option Parameters msgptr in out Pointer to the DHCP message msglen in out Pointer to the number of bytes in the message option in out Option type to search for see RFC 2131 Description The msgptr pointer points to an option in the DHCP message which is formatted according to RFCs 2131 and 2132 The application is responsible for parsing options and reading the values The returned pointer must be passed to one of the ntohl or ntohs macros to extract the value of the option The macros can be used to convert the value into host byte order Return Value Pointer to the specified option in the DHCP message in network byte order success e NULL no option of the specified type exists See Also e DHCP find option Freescale MQX RTCS User s Guide Rev 10 126 Freescale Semiconductor 7 1 26 DHCPCLNT_release Releases a DHCP Client no longer needed Synopsis uchar ptr DHCPCLNT release _rtcs if handle handle Parameters handle in Pointer to the interface no longer needed Description Function Reference Use function DHCPCLNT release to release a DHCP client when your application no longer needs it Functi
36. Number of received PADO packets ST RX PADTRECEIVED Number of received PADT packets ST RX GENERICE ERRORS RECEIVED Number of generic error packets received ST RX MALFORMED PACKETS Number of received malformed packets ST RX MULTIPLE PADO RECEIVED Number of multiple PADO packets received ST RX SERVICENAMEERRORS Number of service name error packets received ST RX ACSYSTEMERRORS Number of AC system errors received ST RX PADI Number of PADI packets received SERVICE NAME ERROR TAG LENGTH Freescale MQX RTCS User s Guide Rev 10 376 Freescale Semiconductor Length of the service name error data string SERVICE_NAME_ERROR_DATA Data pointer to the most recent error string received AC_SYSTEM_ERROR_TAG_LENGTH Length of the AC system error data string AC_SYSTEM_ERROR_DATA Data pointer to the most recent error string GENERIC_ERROR_TAG_LENGTH Length of the generic error data string GENERIC_ERROR_DATA Data pointer to the length of the AC system error data string Freescale MQX RTCS User s Guide Rev 10 Data Types Freescale Semiconductor 377 Data Types 8 8 28 PPP SECRET Used by PPP Driver for PAP and CHAP authentication of peers typedef struct uint 16 PPP ID LENGTH uint 16 PPP PW LENGTH char ptr PPP ID PTR char ptr PPP PW PTR PPP SECRET PTR PPP SECRET PTR PPP ID LENGTH Number of bytes in the array at PPP ID PTR PPP PW LENGTH Number of bytes in the array at PPP PW PTR
37. Put each interface in a state such that the interface can send and receive network traffic Dynamically add to RTCS each interface per supported device When the application initializes an interface to a device the initialization function returns a handle to the interface The application subseguently references this device handle to add the interface to RTCS and bind IP addresses to it 2 9 1 Initializing Interfaces to Ethernet Devices Before an application can use an interface to the ethernet device it must initialize the device driver interface by calling ENET initialize The function does the following It initializes the ethernet hardware and makes it ready to send and receive ethernet packets It installs the ethernet driver s interrupt service routine ISR e It sets up the send and receive buffers which are usually representations of the ethernet device s own buffers Itallocates and initializes the ethernet device handle which the application subsequently uses with other functions from the ethernet driver API ENET get stats and from the RTCS API 2 9 1 1 Getting Ethernet Statistics To get statistics about ethernet interfaces call ENET_get_stats passing to it the device handle to the interface 2 9 2 Initializing Interfaces to Point to Point Devices Point to point devices include devices that use PPP and PPP over Ethernet For information about initializing interfaces to point to point devices see Chap
38. RTCS User s Guide Rev 10 Freescale Semiconductor Using Sockets IP address A socket might have a remote endpoint 3 4 Socket Options Each socket has socket options which define characteristics of the socket such as e checksum calculations e ethernet frame characteristics e IGMP membership non blocking nowait options push operations Sizes of send and receive buffers e timeouts 3 5 Comparison of Datagram and Stream Sockets Table 3 1 gives an overview of the differences between datagram and stream sockets Table 3 1 Datagram and Stream Sockets Datagram socket Stream socket Protocol UDP TCP Connection based No Yes Reliable transfer No Yes Transfer mode Block Character 3 6 Datagram Sockets 3 6 1 Connectionless A datagram socket is connectionless in that an application uses a socket without first establishing a connection Therefore an application specifies the destination address and destination port number for each data transfer An application can pre specify a remote endpoint for a datagram socket if desired 3 7 Unreliable Transfer A datagram socket is used for datagram based data transfer which does not acknowledge the transfer Because delivery is not guaranteed the application is responsible for ensuring that the data is acknowledged when necessary Freescale MQX RTCS User s Guide Rev 10 44 Freescale Semiconductor Using Sockets 3 8 Bl
39. The process of splitting an IP datagram into fragments frame The unit of transmission at the data link layer usually an ethernet frame A frame includes a header a trailer or both and some payload A frame usually encapsulates one packet the unit of transmission at the network layer the exception occurs when an IP datagram is fragmented into multiple smaller datagrams Frame Check Sequence See FCS FTP File Transfer Protocol Freescale MQX RTCS User s Guide Rev 10 414 Freescale Semiconductor G gateway A layer three network layer relay Sometimes called a router H hardware address See address hardware interface Demarcation between hardware and software HDLC High Level Data Link Control A link layer protocol proposed by ISO High Level Data Link Control See HDLC host An entity with an IP address host byte order The endian format of the host computer one of big endian or little endian See also byte swap and network byte order host identifier That portion of an IP address that identifies a host on the IP network For example for 192 168 0 1 and 192 168 0 2 one and two are the host identifiers Sometimes called host number host name An identity usually a textual identifier that is associated with a host host number See host identifier HTTP Hypertext Transfer Protocol hub The ethernet term for a layer one physical layer relay The general term is switch Hyper
40. Total number of transmitted packets ST TX MISSED Packets to be sent that were discarded due to lack of resources ST TX DISCARDED Packets to be sent that were discarded for all other reasons ST TX ERRORS Internal errors detected while trying to send a packet ERR RX Freescale MQX RTCS User s Guide Rev 10 392 Freescale Semiconductor RX error information ERR_TX TX error information The following stats are included in ST RX DISCARDED ST_RX_BAD_PORT Datagrams with the destination port zero ST_RX_BAD_CHECKSUM Datagrams with an invalid checksum ST_RX_SMALL_DGRAM Datagrams smaller than the header ST RX SMALL PKT Datagrams larger than the frame ST RX NO PORT Datagrams for a closed port Freescale MQX RTCS User s Guide Rev 10 Data Types Freescale Semiconductor 393 Data Types Freescale MQX RTCS User s Guide Rev 10 394 Freescale Semiconductor Appendix A Protocols and Policies A 1 Ethernet Ethernet IEEE 802 3 is the physical layer that RTCS supports RFC 894 a standard for the transmission of IP datagrams over ethernet networks defines how IP datagrams are sent in ethernet frames Properties of ethernet include e tis not deterministic Delivery is unreliable not guaranteed All hosts on an ethernet network can receive all packets Minimum frame length is 64 bytes Maximum frame length is 1518 bytes B bytes B bytes 2 bytes 46 1500 byt
41. User s Guide Rev 10 380 Freescale Semiconductor Data Types For PPP Next hop destination address Returns a status code JOIN Called by RTCS to join a multicast group not used for PPP interfaces First parameter pointer to the IP interface structure Second parameter IP address of the multicast group Returns a status code LEAVE Called by RTCS to leave a multicast group not used for PPP interfaces First parameter Pointer to the IP interface structure Second parameter IP address of the multicast group Returns a status code Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 381 Data Types 8 3 32 RTCS protocol table A NULL terminated table that defines the protocols that RTCS initializes and starts when RTCS is created RTCS initializes the protocols in the order that they appear in the table An application can use only the protocols that are in the table If you remove a protocol from the table RTCS does not link the associated code with your application an action that reduces the code size extern uint 32 CODE PTR RTCS protocol table void Protocols Supported RTCSPROT IGMP Internet Group Management Protocol used for multicasting RTCSPROT UDP User Datagram Protocol connectionless datagram service RTCSPROT TCP Transmission Control Protocol reliable connection oriented stream service RTCSPROT RIP Routing Information
42. Values See comments Default value See comments Change After the socket is created Socket type Datagram or stream Comments An application supplied nat timeouts structure defines inactivity timeout values NAT Port Numbers Option name RTCS_SO_NAT_PORTS Protocol level SOL_NAT Values See comments Default value See comments Change After the socket is created Socket type Datagram or stream Comments An application supplied nat_ports structure defines port numbers No Nagle Algorithm Option name OPT_NO_NAGLE_ALGORITHM Protocol level SOL_TCP Values TRUE RTCS does not use the Nagle algorithm to coalesce short segments FALSE to reduce network congestion RTCS uses the Nagle algorithm defined in RFC 896 to coalesce short segments Default value FALSE Change Before bound Socket type Stream Comments If an application intentionally sends short segments it can improve efficiency by setting the option to TRUE Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor Receive Ethernet 802 10 Priority Tags Function Reference Option name RTCS_SO_LINK_RX_8021Q_PRIO Protocol level SOL_LINK Values e 1 last received frame did not have an Ethernet 802 10 priority tag e 0 7 last received frame had an Ethernet 802 10 priority tag with the specif
43. You can change its behavior to suit your needs Freescale MQX RTCS User s Guide Rev 10 88 Freescale Semiconductor RTCS Applications 5 17 2 Starting TFTP Server To start TFTP Server an application calls TFTPSRV init with the name of the task that implements TFTP the task s priority and its stack size We recommend a stack size of at least 1000 bytes Increase it only if you increase the value of TFTPSRV MAX TRANSACTIONS When the server is started the application should make the priority of the task lower than the TCP IP task that is make the task s priority 7 8 9 or greater See information on the HTCSTASK priority variable in Section 2 6 Changing RTCS Creation Parameters Note 5 18 Quote of the Day Service Note Quote of the Day client and server examples are not part of this MOX release RTCS provides example code that implements a Quote of the Day client and server This service is not part of the RTCS library but you might find it useful as a template to write your own service The examples can be found in the following subdirectories of the lexamples folder client example gotdclnt gotdclnt c e server example gotdsrv gotdsrvr c The Quote of the Day server example implements a server that complies with the Quote of the Day protocol RFC 865 The server task QUOTE server listens to TCP connections or UDP datagrams on port 17 When a client request is
44. acknowledgment time expected on the socket the connect timeout will expire prematurely Keep Alive Timeout Option name OPT KEEPALIVE Protocol level SOL TCP Values Zero RTCS does not probe the remote endpoint Non zero if the connection is idle RTCS periodically probes the remote endpoint an action that detects whether the remote endpoint is still present Default value Zero minutes Change Before bound Socket type Stream Comments The option is not a standard feature of the TCP IP specification and generates unnecessary periodic network traffic Freescale MQX RTCS User s Guide Rev 10 286 Freescale Semiconductor Maximum Retransmission Timeout Function Reference Option name OPT MAXRTO Protocol level SOL TCP Values Non zero maximum value for the retransmission timer s exponential backoff Zero RTCS uses the default value which is 2 times the maximum segment lifetime MSL Since the MSL is 2 minutes the MTO is 4 minutes Default value Zero milliseconds Change Before bound Socket type Stream Comments The retransmission timer is used for multiple retransmissions of a segment Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 287 Function Reference NAT Inactivity Timeout Option name RTCS_SO_NAT_TIMEOUTS Protocol level SOL_NAT
45. host gethostbyname string if host NULL name host gt h_name aliasl host h aliases 0 alias2 host gt h_aliases 1 type host gt h_addrtype length host gt h_length ip uint 32 ptr host h addr list 0 Freescale MQX RTCS User s Guide Rev 10 host string 30 name aliasl alias2 type length ip 150 Freescale Semiconductor Function Reference 7 1 44 getpeername Gets the remote endpoint identifier of a socket Synopsis uint 32 getpeername uint 32 socket sockaddr _PTR_ name uint_16 _PTR_ namelen Parameters socket in Handle for the stream socket name out Pointer to a placeholder for the remote endpoint identifier of the socket namelen in out When passed in Pointer to the length in bytes of what name points to When passed out Full size in bytes of the remote endpoint identifier Description Function getpeername finds the remote endpoint identifier of socket socket as was determined by connect or accept This function blocks but the command is immediately serviced and replied to Return Value e RTCS OK success Specific error code failure See Also accept e connect e getsockname e socket Example uint 32 handle sockaddr in remote sin uint 32 status uint 16 namelen namelen sizeof sockaddr in status getpeername handle struct sockaddr amp remote sin amp namelen if statu
46. iwcfg get mode iwcfg set wep key iwcfg get wep key iwcfg set passphrase iwcfg get passphrase iwcfg set sec type iwcfg get sectype iwcfg set power iwcfg set scan MIB MIB1213 init NAT NAT init NAT close NAT stats PPP Driver PPP initialize IPIF_stats Freescale MQX RTCS User s Guide Rev 10 326 Freescale Semiconductor Table 7 2 continued Function Reference PPP over Ethernet iopcb pppoe client destroy iopcb pppoe client init pppoe client stats pppoe server destroy pppoe server if add pppoe server if remove pppoe server if stats pppoe server init pppoe server session stats RTCS RTCS create RTCS exec TFTP BIN RTCS exec TFTP COFF RTCS exec TFTP SREC RTCS gate add RTCS gate remover RTCS if add RTCS if bind RTCS if bind BOOTP RTCS if bind DHCP RTCS if bind IPCP RTCS if remove RTCS if unbind RTCS load TFTP BIN RTCS load TFTP COFF RTCS load TFTP SREC RTCS ping RTCSLOG disable RTCSLOG enable SNMP Agent SNMP init SNMP trap warmStart SNMP trap coldStart SNMP trap authenticationFailure SNMP trap linkDown SNMP trap myLinkDown SNMP trap linkUp SNMP trap userSpec SNMPv2 trap warmsStart SNMPv2 trap coldStart SNMPv2 trap authenticationFailure SNMPv2 trap linkDown SNMPv2 trap linkUp SNMPv2 trap userSpec MIB1213 init
47. sends data on a stream socket or on a datagram socket for which a remote endpoint has been specified Stream Socket RTCS packetizes the data at buffer into TCP packets and delivers the packets reliably and sequentially to the connected remote endpoint Ifthe send nowait socket option is TRUE RTCS immediately copies the data into the internal send buffer for the socket to a maximum of buflen The function then returns If the send push socket option is TRUE RTCS appends a push flag to the last packet that it uses to send the buffer all data is sent immediately taking into account the capabilities of the remote endpoint buffer Datagram Socket If a remote endpoint is specified using connect send is identical to sendto using the specified remote endpoint If a remote endpoint is not specified send returns RTCS ERROR The flags parameter is for datagram sockets only The override is temporary and lasts for the current call to send only Setting flags to RTCS MSG NOLOOP is useful when broadcasting or multicasting a datagram to several destinations When flags is set to RTCS MSG NOLOOP the datagram is not duplicated for the local host interface Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 277 Function Reference Flags Group 1 RTCS MSG BLOCK overrides the OPT SEND NOWAIT datagram socket option makes it behave as if it was FALSE RTCS MSG NONBLOCK overrides the OPT SEND N
48. sent over a TCP or UDP connection EDS Server listens and responds to commands without the need for a debugger This lets you debug an embedded application from a host computer that is running a performance analysis tool When an application starts the EDS Server task through EDS init you can establish a connection using the performance analysis tool Set the configuration settings in the performance analysis tool to match the characteristics of the link EDS Server assumes a default port number of 5002 You can change this value by changing the following line in source apps eds c define EDS PORT 5002 5 7 FTP Client To initiate an FTP session the application calls FTPd init Once the FTP session has started the client issues commands to the FTP server using functions FTP_command and FTP command data The client calls FTP close to close the FTP session 5 8 FTP Server The File Transfer Protocol FTP is used to transfer files from a remote computer according to RFC 959 The server consists of a protocol interpreter and a data transfer process To start FTP Server an application calls FTPSRV init with the name of the task that implements FTP the task s priority and its stack size When the server is started the application should make the priority of the task lower than the TCP IP task that is make the task s priority 7 8 9 or greater See information on the HTCSTASK priority variable in Section 2 6 Changi
49. statistics getting 206 TCP reset 31 Telnet Client 57 starting 207 protocol 8 Server 57 starting 111 208 task structure RTCS_TASK 256 TFTP 8 Client 57 Server 58 access to a TFTP client allowing 210 starting 211 tftp h 58 211 TFTPOP RRQ 210 TFTPOP WRQ 210 TFTPSRV MAX TRANSACTIONS 58 211 Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 433 timeout socket send 195 Ul command 270 timewait timeout socket option 197 unbinding IP addresses from device interfaces 13 170 transmit buffer size socket option 196 UNIX BSD 4 4 23 transmit Ethernet 802 10 priority tags socket option 194 unnumbered information command 270 transmit Ethernet 802 3 frames socket option 194 W U Winsock connection for embedded debugging 55 UDP 8 267 in RTCS protocol table 255 X statistics getting 212 XDR 8 Freescale MQX RTCS User s Guide Rev 10 434 Freescale Semiconductor
50. uin IGMP STATS PTR IGMP STATS PTR ST_RX BAD TYPE Datagrams with unrecognized code ST RX BAD CHECKSUM Datagrams with invalid checksum ST RX SMALL DGRAM Datagrams smaller than header ST RX QUERY Received queries ST RX REPORT Received reports ST TX QUERY Transmitted queries ST TX REPORT Transmitted reports Freescale MQX RTCS User s Guide Rev 10 354 Freescale Semiconductor Data Types 8 3 16 in_addr Structure of address fields in the following structures ip mreq e sockaddr in typedef struct in addr ip address s addr in addr s addr IP address Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 355 Data Types 8 3 17 ip mreq IP multicast group typedef struct ip mreq in addr imr multiaddr in_addr imr interface ip mreg imr_multiaddr Multicast IP address imr_interface Local IP address Freescale MQX RTCS User s Guide Rev 10 356 Freescale Semiconductor Data Types A pointer to this structure is returned by inet_pton typedef struct uint 32 ST RX TOTAL uint 32 ST RX MISSED uint 32 ST RX DISCARDED uint 32 ST RX ERRORS uint 32 ST TX TOTAL uint 32 ST TX MISSED uint 32 ST TX DISCARDED uint 32 ST TX ERRORS RTCS ERROR STRUCT ERR RX RTCS ERROR STRUCT ERR TX uint 32 ST RX HDR ERRORS uint 32 ST RX ADDR ERRORS uint 32 ST RX NO PROTO
51. uint 32 TELNET connect ip address ipaddress Parameters ipaddress in IP address to connect to Description If a user enters telnet at the shell prompt the shell prompts for the IP address of a Telnet server The Telnet client creates a stream socket binds it and connects it to Telnet server When the socket is connected the client sends to the server any characters that the user types and displays on the console any characters that it receives from the server Return Value e RTCS OK success Error code failure Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 319 Function Reference 7 1 169 TELNETSRV_init Starts the Telnet Server Synopsis uint 32 TELNETSRV init char ptr name uint 32 priority uint 32 stacksize RTCS TASK PTR shell Parameters name in Name of Telnet Server task priority in Priority of Telnet Server task we recommend that you make the priority lower than the priority of the RTCS task that is make it a higher number stacksize in Stack size for Telnet Server task shell in Shell task that Telnet Server starts when a client initiates a connection see description Description Function TELNETSRV init starts Telnet Server and creates TELNETSRV task Telnet Server listens on a stream socket Every time a client initiates a connection the server creates a new shell task and redirects the new task s
52. 3309 1991 HDLC frame structure ISO IEC 4335 1991 HDLC elements of procedures 8 hits 8 hits 8 hits 16 hits 0 1500 bytes 16 bits 8 bits Flag Address Control Protocol Data FCS Flag Ox7E OxFF 0x03 Ox7E Figure A 13 PPP Frame A 8 1 Flag Each frame begins and ends with a Flag field 0x7E which PPP uses to synchronize frames Only one flag is required between two frames Two consecutive Flag fields constitute an empty frame which PPP silently discards and does not count as an FCS error A 8 2 Address Always contains OxFF which is the HDLC all stations that is broadcast address Individual station addresses are not assigned A 8 3 Control Always contains 0x03 the HDLC unnumbered information UI command A 8 4 Protocol Identifies the datagram that is encapsulated in the Data field Values are listed in RFC 1700 Assigned Numbers Freescale MQX RTCS User s Guide Rev 10 400 Freescale Semiconductor Protocols and Policies A 8 5 Data Contains the encapsulated packet A 8 6 FCS The frame check sequence by default uses CCITT 16 and is calculated over all bits of the Address Control Protocol and Data fields 8 4 LCP PPP uses Link Control Protocol RFC 1661 PPP and RFC 1570 LCP Extensions to negotiate options for a link In the process of maintaining the link the PPP link goes through states as shown in Figure A 14 Negotiating Open Succeeded Failed Open restart
53. 55 starting 105 embedded debugging 55 enet h 216 ENET STATS structure 224 Ethernet callback functions 154 253 Ethernet 802 1Q priority tags 191 194 Ethernet 802 3 frames 192 194 Ethernet connection for embedded debugging 55 Ethernet drivers initializing 12 107 statistics getting 12 106 structure 224 Ethernet II frames 21 Ethernet protocol 7 265 Ethernet802 1Q priority tags 21 Freescale MQX RTCS User s Guide Rev 10 428 Freescale Semiconductor Ethernet802 3 frames 21 examples binary boot file downloading and running 144 DHCP Client 98 158 160 162 167 echoing data TCP 176 UDP 178 FTP server starting 116 session starting 114 gateways adding default 149 removing default 151 host HOSTENT_STRUCT getting by name 119 host name getting by address 117 IP addresses assigning with BootP 156 NAT max port number 198 PAP and CHAP authentication setting up 39 PPP binding to interface 164 PPP Driver 17 PPP over Ethernet 70 RTCS creating and setting up 17 logging 181 received packets statistics displaying 82 SNMP Agent 201 SNTP Client 202 sockets accepting incoming connections 80 binding to port number 84 checksum bypass option 198 local endpoint getting 122 max NAT port number option 198 receive nowait option 197 receiving data datagram 139 stream 137 remote endpoint getting 120 sending data datagram 185 stream 183 send push option 197 shutti
54. 7 1 86 ipcfg_task_destroy Signals the exit request to the IPCFG task Synopsis void ipcfg task destroy boolean wait task finish Parameters wait task finish in wait for task exit if TRUE Description This functions sets an internal flag which is checked during each pass of Ethernet link status monitoring task The task exits as soon as it completes the immediate operation According to parameter this function may wait for task destruction Return Value none See Also e ipcfg task create e ipcfg task status ipcfg task poll Example See ipcfe task create Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 201 Function Reference 7 1 87 ipcfg task status Checks whether the IPCFG Ethernet link status monitorin task is running Synopsis boolean ipcfg task status void Description This function returns TRUE if link status monitoring task is currently running returns FALSE otherwise Return Value TRUE if task is running FALSE if task is not running See Also e ipcfg task create e ipcfg task destroy e ipcfg task poll Example See ipcfg task create Freescale MQX RTCS User s Guide Rev 10 202 Freescale Semiconductor Function Reference 7 1 88 ipcfg_task_poll One step of the IPCFG Ethernet link status monitoring task Synopsis boolean ipcfg_task_poll void Description This function executes one step of the link status monitoring task
55. 70 ipcfg add interface Add new interface and returns corresponding device number Synopsis uint 32 ipcfg add interface uint 32 device number rtcs if handle ihandle Parameters device number in device number ihandle in interface handle Description Internally this function makes the association between ihandle and the device number Return Value Device number if successful otherwise 1 See Also ipcfg get ihandle e ipcfg get device number Freescale MQX RTCS User s Guide Rev 10 Function Reference Freescale Semiconductor 185 Function Reference 7 1 71 ipcfg get ihandle Returns the RTCS interface handle for given Ethernet device number Synopsis rtcs if handle ipcfg get ihandle uint 32 device Parameters device in device identification Description Simple function returning the RTCS interface handle by giving an Ethernet device number Return Value Interface handle if successful NULL otherwise See Also e ipcfg get device number Freescale MQX RTCS User s Guide Rev 10 186 Freescale Semiconductor AE Function Reference 7 1 72 ipcfg get mac Returns the Ethernet MAC address Synopsis boolean ipcfg get mac uint 32 device _enet address mac Parameters device in device identification mac in pointer to mac address structure Description Simple function returning the Ethernet MAC address by giving Ethernet device nu
56. DHCP option variable amp optptr amp optlen DHCPOPT PARAMLIST parm options 3 error RTCS if bind DHCP ihandle amp params option array optptr option array Freescale MQX RTCS User s Guide Rev 10 Function Reference Freescale Semiconductor 255 Function Reference if error printf nDHCP boot failed error x error return Use the network interface when it is bound Freescale MQX RTCS User s Guide Rev 10 256 Freescale Semiconductor Function Reference 7 1 132 RTCS_if_bind_DHCP_timed Gets an IP address using DHCP and binds it to the device interface within a timeout Synopsis uint 32 RTCS if bind DHCP timed _rtcs if handle rtcs if handle DHCP DATA STRUCT PTR params char ptr opiptr uint_32 optlen Parameters rtcs if handle in RTCS interface handle params in Optional parameters params CHOICE FUNC params gt BIND_FUNC params gt REBIND_FUNC params gt UNBIND_FUNC params gt FAILURE_ FUNC params gt FLAGS optptr in One of the following Pointer to the buffer of DHCP params see RFC 2132 NULL optlen in Number of bytes in the buffer pointed to by optptr Description Function RTCS if bind DHCP timed uses DHCP to get an IP address and bind it to the device interface If the interface does not bind via DHCP within the timeout limit the client stops trying to bind and exits Parameter rtcs if handle is return
57. I O to the connected socket Command processing is done by the specified shell which may be the Shell function provided When using the Shell function an alternate command list may be specified in order to restrict the commands available remotely The Telnet server may be started or stopped from the shell by including the Shell _Telnetd function in the shell command list include lt rtcs h gt s s include include hell h rtcs h define SHELL ELNE define SHELL ELNE A restricted SHELL COMMA ted dir exit ui ftp n gethbn help netstat ping pwd read telnet Seip D STRUCT nett Nett nero nell Nett Nett Net J Nett Nett Net J hell T ANNNANNHNNNNWN h TD PRIO TD STACK 7 1000 list of shell commands Telnetd shell commands Let _cd _dir exit FTP client Fy get host by name help netstat ping _pwd read hy Inet client hell TFTP client Freescale MQX RTCS User s Guide Rev 10 320 Freescale Semiconductor Function Reference type Shell type pow Shell command list NULL NULL y RTCS TASK Telnetd shell template Telnet shell 8 2000 Telnetd shell fn NULL void Telnetd shell fn pointer dummy Shell Telnetd shell commands NULL void main_task uint_32 temp
58. NAT ST PACKETS BYPASS Number of unmodified packets ST PACKETS PUB PRV Number of packets from public to private realm ST PACKETS PUB PRV ERR Number of packets from public to private realm with errors packets that have errors are discarded ST PACKETS PRV PUB Number of packets from private to public realm ST PACKETS PRV PUB ERR Number of packets from private to public realm with errors packets that have errors are discarded Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 367 A Data Types 8 3 24 nat timeouts Used by Freescale MQX NAT to determine inactivity timeout settings typedef struct uint 32 timeout tcp uint 32 timeout fin uint 32 timeout udp nat timeouts TIMEOUT TCP Inactivity timeout setting for a TCP session TIMEOUT FIN Inactivity timeout setting for a TCP session in which a FIN or RST bit has been set TIMEOUT UDP Inactivity timeout setting for a UDP or ICMP session Freescale MQX RTCS User s Guide Rev 10 368 Freescale Semiconductor Data Types 8 3 25 PPPOE_CLIENT_INIT_DATA_STRUCT A pointer to this structure is the parameter to iopcb pppoe client init typedef struct pppoe client init data struct pointer EHANDLE char ptr SERVICE NAME char ptr AC NAME boolean HOST UNIQUE uint 32 RTX TASK PRIORITY uint 32 RTX TASK STACK
59. PERS e seas 51 3 29 1 Shutting Down Gracefully csi aacra doter cte n E ndm dd 51 3 29 2 Shutting Down with an Abort Operation c YY 51 Sl Exam 5 ge ao eed oa da a E oye A 8 ate 0 pied bd ru Rd cia a ee ear 52 Freescale MQX RTCS User s Guide Rev 10 4 Freescale Semiconductor Chapter 4 Point to Point Drivers dl Bele YOU BEGIN cris er ls Pd as 55 Z2 PPP and PPP IUBE 22225252 392253 dod Gw daret ace n a det had uet i i 8 55 421 UCP Configuration ODIOfIS zd ra pieds ERE ba a b dee REI eee d ba EE dd 55 4 2 2 Configuring PPP INVEE uu eciam hes ame a Botta D ua Y O ei e id 57 423 Changing AMONIO e se ai ae a ERE a a aerea 59 424 Initializing PPP LINKS seta rra a damda ii A 62 425 Goma PPP Slalsll B liszizhexeciemeeraness adim LG sw RR AUR 62 120 Example Using PPP DINEF cris demens Qr IR rs als 62 48 PPP over Ethemet DIET o donde n olm CR REOR EHE o A Gi m RR RE a 62 4 3 1 Setting Up PPP over Ethernet Driver ug 63 4 3 2 Examples Using PPP over Ethernet Driver 64 Chapter 5 RTCS Applications 5 1 Before DUB sa doc OR Sores oc RR o X CORRER RR ASA 71 OD AM elec MT rm 71 5 2 1 Example Setting Up and Using DHCP Client 72 22 HOP A esq ads 72 5 3 1 Example Setting Up and Modifying DHCP Server 73 54 DNS oiu cssonERRERERSAZQEARREE E ddr eu be Gb d RR EE dd n n Esi d 78 541 Setting U
60. SADDR char ptr boot data BOOTFILE return error Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 251 Function Reference 7 1 130 RTCS if bind DHCP Gets an IP address using DHCP and binds it to the device interface Synopsis uint 32 RTCS if bind DHCP _rtcs if handle rtcs if handle DHCP DATA STRUCT PTR callback ptr char ptr optptr uint_32 optlen Parameters rtcs if handle in RTCS interface handle callback ptr in Pointer to the callback functions for DHCP optptr in One of the following pointer to the buffer of DHCP params see RFC 2132 NULL optlen in Number of bytes in the buffer pointed to by optptr Description Function RTCS if bind DHCP uses DHCP to get an IP address and bind it to the device interface Parameter rrtcs if handle is returned by RTCS if add This function blocks until DHCP completes initialization but not until it binds the interface Return Value e RTCS OK success Error code failure See Also e RTCS if add e RTCS if bind e RTGS if bind BOOTP e RTCS if bind DHCP flagged e RTCS if bind DHCP timed e RICS if bind IPCP DHCP DATA STRUCT Example enet handl handle rtcs if handle ihandle uint 32 error uint 32 optlen 100 Use the size that you need for the number of params that you are using with DHCP uchar option array 100 uchar _PTR_ optptr Freescale MQX RTCS User s Guide Rev
61. T dis drei aeu Ia TT d waa dod 324 7 2 Functions Listed by Service llle eere 325 Chapter 8 Data Types 8 1 Data Types for Compiler Portability 23252 eur ae ca pasi dene sa ae aa ca Etot aa a 329 Br Oher Dita VPE AA Y EE REUS Dxa dua uuu rad d RE PA 330 8 3 Alphabetical List of RTCS Data Structures oooooooooooorroonnonmo 330 8 3 1 Jopob handle _iopcb_table i RR RR RR FFROG GR ie ma dr ba EA 331 6 92 A GIADS rra b dt A ia 333 Bas BOOTP DATA STRUCT 1 2 drip Raus db gu dae 335 8 3 4 DHOP DATA STHUGT i2uciesedeamnn mh deeem UM ek enn 336 8 3 5 DHGPSRV DATA STRUGT nn in ate RR errada aa 337 8 360 A 338 8 93 7 HOSTENT STHUET 52x moara ia a ue se te te da e aa 341 8 8 Mitr COGI UNK STHUCT uu ica der GR RA DEU UG awodd 342 8 3 9 ATTPD PN LIS SS THU aen YG GROW ES bec ER E REC S 343 8 3 10 HTTPD PARAMS STRUCOT sic xz eum dos Re pal iaa 344 8 39 11 ATIPO ROOT DIR STHUDT siiri rriti Redon bid ce ER Rr in 346 Bale HTIPD SESSION SIRUGT 5RR eG eet dda bs bee seaweed 347 Boe Ul isa qutd naut a eae O OY rw AAA 349 8 3 14 OS ae a e es de dy a ge 350 8 93 15 IGMP STATS aea GYR na is ER ER GAS GDG DDE Oa Ue O Uh 354 E SUG 34 6 4 NT pp Rd ad aie Eb TO edd ede x e HYN 355 CRM cmo MMC mm 356 B3 18 A 357 8 3 19IPCFGIP ADDRESS DATA v ecc ete oi aia n di a 360 8 3 20 IPCP_DATA_STRUCT sias DRDD Edd na cad da a s 361 Freescale MQX RTCS User s Guide Rev 10 10 Freescale Semiconductor SOCIE STATS carnada H
62. This function may be called periodically in any user s task to emulate the task operation The task itself doesn t need to be created in this case Return Value TRUE if the immediate bind process finished stable state FALSE if task is in the middle of bind operation function should be called again See Also e ipcfg task create e ipcfg task destroy e ipcfg task status Example See ipcfe task create Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 203 Function Reference 7 1 89 ipcfg unbind Unbinds the Ethernet device from network Synopsis uint 32 ipcfg unbind uint 32 device Parameters device in device identification Description This function releases the IP address information bound to a given device It is blocking function i e doesn t return until the process is finished or error occurs Return Value IPCFG OK success e RTCSERR IPCFG BUSY RTCSERR IPCFG DEVICE NUMBER RTCSERR IPCFG INIT See Also ipcfg bind staticip ipcfg bind_dhcp Example void main uint 32 param setup network ipcfg unbind while 1 Freescale MQX RTCS User s Guide Rev 10 204 Freescale Semiconductor Function Reference 7 1 90 ipcfg6 bind addr Binds IPv6 address information to the Ethernet device Synopsis uint 32 ipcfg6 bind addr uint 32 device IPCFG6 BIND ADDR DATA PTR ip data Parameters device in device i
63. aa 130 7 1 29 DHGPSBV set contin Mag OM i e ceea ae eee oti ud aaa a aie ERES 131 7 1 30 DHCPSRV set contig flag oh ne ee ee aaa m ea a a aa aa 132 Ag i JL VM i PAM EN IA 133 7 132 BODDI mill aie gaa sean iata ocre rta pa tens arre 134 A E AAA ee i Bi a 6 eee ae eee d 135 08 ENEA Get SIS tj ie tt A obere GO de 136 7 1539 ENE T WAC sspe RR RR bod 44 ERU AC REC E ARA 197 CAUSE IINE arar a ibi ST 138 Za FIF command O di AS O as 139 7 1 38 FTP command data aai GR ara e re m rhe eee ERE ER SERRE 140 NCC DEIN serie ros tt OIRWR de til Ar ae dept Ne ee ead 141 Cola DISSE A ai i ied i a O OA WW HY AW EEn 145 TAI FITPSRV IBI a a AA 147 7 142 JS MOSIIVAUON ia ceata aie aaa obese dadea piae 2 gus a dia ded baz 148 TL ASO MOS Mame RC PP EMT 149 7 1 44 getpeername in ca aa x secun pERERA se e nm e a e i eta d a sa aa 151 7 14503590 an NE OO Y nme e de oa an fc a dn debera 153 FANE We reis oi A P CEP 154 7 1494 Tic defaut paraMS exei ase Rd d d RR YEPUCAIAG id a e dd ate ar 155 FEES iso i rr nara n ay ral parerea ada 156 71 49 DADO server WW raceala mas mia da zeta dea asa FFOI NW dd a 157 71 20 MDG Server MICA ma erei ate ara deg AERA AR CEPEP RIS EG Re d d dac enews 158 7 1 51 httpd server TUM uuo dos ie EE aA E AR aa i dd 160 7 1 52 TPO Server DON coa bk ERGSELI RS intr ae e br i 161 7159 HTTPD SET PAHAM RODT DIP i RR RD UD ama ae a EW RR CR d 162 7 1 54 HTTPD SET PARAM
64. active MQX makes active the highest priority task that has been the longest in the ready queue See also block verb and schedule verb DNS Domain Name System The system and the protocol that are defined in RFC 1035 Domain Names Implementation and Specification Freescale MQX RTCS User s Guide Rev 10 412 Freescale Semiconductor domain name server A server that implements the DNS protocol which is defined in RFC 1035 Sometimes called a DNS server Domain Name System See DNS DoS A denial of service attack is characterized by an explicit attempt by attackers to prevent legitimate users of a service from using the service Examples include attempts to flood a network thereby preventing legitimate network traffic attempts to disrupt connections between two machines thereby preventing access to a service attempts to prevent a particular individual from accessing a service and attempts to disrupt service to a specific system or person dotted decimal notation A convention for writing IP addresses in textual format for example 192 100 140 2 download Get a file from a server driver See device driver Dynamic Host Configuration Protocol See DHCP E encapsulate Add a header and perhaps a trailer to a layer s unit of transmission to create the unit of transmission for the next lower layer IP encapsulates an ICMP message to create an IP datagram by prepending the IP header Ethernet encapsulates
65. buffer length 0 struct sockaddr amp raddr rlen Freescale MQX RTCS User s Guide Rev 10 274 Freescale Semiconductor E i Function Reference 7 1 144 RTCSLOG_disable Disables RTCS logging Synopsis void RTCSLOG disable uint 32 logtype Parameters logtype in Class or classes of entries to stop logging Description The function disables RTCS event logging in the MQX kernel log ogtype is a bitwise OR of either of the following RTCS LOGCTRL FUNCTION Logs all socket API calls RTCS LOGCTRL PCB Logs packet generation and parsing Alternatively ogtype can be RTCS LOGCTRL ALL to disable all classes of log entries See Also RTCSLOG enable Example See RTCSLOG enable Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 275 Function Reference 7 1 145 RTCSLOG_enable Enables RTCS logging Synopsis void RTCSLOG enable uint 32 logtype Parameters logtype in Class or classes of entries to start logging Description The function enables RTCS event logging in the MQX kernel log ogtype is a bitwise OR of any of the following RTCS LOGCTRL FUNCTION Logs all socket API calls RTCS LOGCTRL PCB Logs packet generation and parsing Alternatively ogtype can be RTCS LOGCTRL ALL to enable all classes of log entries RTCS log entries are written into the kernel log Therefore the kernel log must have been created prior to enabli
66. character int 8 ptr 4 0 OxFFFFFFFF Pointer to int 8 uint 8 1 0 255 Unsigned character uint 8 ptr 4 0 OxFFFFFFFF Pointer to uint 8 int 16 2 2 15 2 15 1 Signed 16 bit integer int 16 ptr 4 0 OxFFFFFFFF Pointer to int 16 uint 16 2 0 2 16 1 Unsigned 16 bit integer uint 16 ptr 4 0 OxFFFFFFFF Pointer to uint 16 int 32 4 2 81 2 31 1 Signed 32 bit integer int 32 ptr 4 0 OxFFFFFFFF Pointer to int 32 uint 32 4 0 2 32 1 Unsigned 32 bit integer uint 32 ptr 4 0 OxFFFFFFFF Pointer to uint 32 int 64 8 2 63 2 63 1 Signed 64 bit integer int 64 ptr 4 0 OxFFFFFFFF Pointer to int 64 uint 64 8 0 2 64 1 Unsigned 64 bit integer uint 64 ptr 4 0 OxFFFFFFFF Pointer to uint 64 Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 329 Data Types 8 2 8 3 Other Data Types Alphabetical List of RTCS Data Structures This section provides an alphabetical list of RTCS data structures with the following information RTCS data type MQX data type Defined in Notes _PTR_ psptypes h as In MOX source for a particular processor type _enet address uchar 6 enet h In MOX source _enet_handle pointer enet h In MOX source ip address uint 32 rtcs h _ppp_handle pointer ppp h _pppoe_srv_handle pointer pppoe h _rtes_if_handle pointer rtcs h task id uint 32 mqx h In MQX source bool t boolean rpctypes h caddr t char ptr rpctypes h enum t uint 16 or rpctypes h u
67. create a socket an application calls socket and specifies whether the socket is a datagram socket or a stream socket The function returns a socket handle which the application subsequently uses to access the socket 3 15 Changing Socket Options When RTCS creates a socket 1t sets all the socket options to default values To change the value of certain options an application must do so before it binds the socket An application can change other options anytime All socket options and their default values are described in the listing for setsockopt in Chapter 7 Function Reference 3 16 Binding Sockets After an application creates a socket and optionally changes or sets socket options it must bind the socket to a local port number by calling bind The function defines the endpoint of the local socket by the local IP address and port number where the application defined the local IP address by calling RTCS if bind while it was setting up RTCS You can specify the local port number as any number but if you specify zero RTCS chooses an unused port number To determine the port number that RTCS chose call getsockopt After the application binds the socket how it uses the socket depends on whether the socket is a datagram socket or a stream socket The description of using datagram sockets follows 3 17 Using Datagram Sockets 3 18 Setting Datagram Socket Options By default RTCS uses IGMP and by default a socket
68. e Error failure See Also e jiopcb open Example See Section 2 15 6 Example Setting Up RTCS Freescale MQX RTCS User s Guide Rev 10 98 Freescale Semiconductor Function Reference 7 1 4 lopcb pppoe client destroy Destroys the PPPoE Client task Synopsis void iopcb pppoe client destroy pointer ppp handle iopcb handle iopcb Parameters ppp handle in PPP handle iopcb in VO PCB handle for the session Description Function iopcb pppoe client destroy destroys the PPPoE Client task and frees the resources that are allocated to the PPPoE Client task Return Value None See Also e jiopcb pppoe client init Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 99 Function Reference 7 1 5 lopcb pppoe client init Initializes PPPoE Client Synopsis _iopcb handle iopcb pppoe client init PPPOE CLIENT INIT DATA STRUCT PTR init Parameters init in pointer to PPPOE CLIENT INIT DATA STRUCT Description Function iopcb pppoe client init initializes the driver for the PPP over Ethernet framing device and returns a handle to the device Return Value I O PCB handle success NULL failure See Also e jiopcb open e PPPOE CLIENT INIT DATA STRUCT Example The following example sets up RTCS with a PPP over Ethernet device rtcs if handle ihandle uint 32 error For Ethernet driver enet handle ehandle
69. e RTCS if add Example Fdefine ENET IPADDR IPADDR 192 168 1 4 define ENET IPMASK IPADDR 255 255 255 0 define ENET IPGATEWAY IPADDR 192 168 1 1 uint 32 setup network void uint_32 error IPCFG IP ADDRESS DATA ip data enet address enet address ip data ip ENET IPADDR ip data mask ENET IPMASK ip data gateway ENET IPGATEWAY Create TCP IP task error RTCS create if error return error Get the Ethernet address of the device ENET get mac address BSP DEFAULT ENET DEVICE ENET IPADDR enet address Initialize the Ehternet device error ipcfg init device BSP DEFAULT ENET DEVICE enet address Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 173 Function Reference if error return error Bind Ethernet device to network using constant static IP address information error ipcfg bind staticip BSP DEFAULT ENET DEVICE amp ip data if error return error return 0 Freescale MQX RTCS User s Guide Rev 10 174 Freescale Semiconductor Function Reference 7 1 64 ipcfg init interface Setups IPCFG context for already initialized device and its interface Synopsis uint 32 ipcfg init interface uint 32 device number rtcs if handle ihandle Parameters device number in device number ihandle in interface handle Description This function sets up the IPCFG context for network inte
70. e RTCSCFG ENABLE GATEWAYS must be set non zero to enable reaching devices behind gateways within the network Without this feature IPCFG ignores all gateway related data e RTCSCFG IPCFG ENABLE DNS must be set non zero to enable DNS name resolving in IPCFG Note that DNS functionality also depends on RTCSCFG ENABLE DNS RTCSCFG ENABLE UDP and RTCSCFG ENABLE LWDNS Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 79 RTCS Applications e RTCSCFG IPCFG ENABLE DHCP must be set non zero to enable DHCP binding in IPCFG Note that DHCP also depends on RTCSCFG ENABLE UDP e RTCSCFG IPCFG ENABLE BOOT must be set non zero to enable TFTP names processing and BOOT binding 5 11 IWCFG High Level Wireless Network Interface Management IWCFG is a set of high level functions wrapping some of wireless configuration management functions It is used to set the parameters of the network interface which are specific to the wireless operation for example ESSID Iwconfig may also be used to display those parameters All these parameters are device dependent Each driver will provide only some of them depending on hardware support and the range of values may change Please refer to the documentation main page of each device for details The IWCFG API functions are all prefixed with iwefg prefix See the functions reference chapter for more details The usage procedure of IWCFG is as follows 1 Create RTCS as described i
71. endpoint can send more data 3 28 Improving the Throughput of Stream Data Include the push flag in sent data only where the flag is needed that is at the end of a stream of data Specify the largest possible send and receive buffers to reduce the amount of work that the application and RTCS do When you call recv call it again immediately to reduce the amount of data that RTCS must copy into its receive buffer e Specify the size of the send and receive buffers to be multiples of the maximum packet size e Call send with an amount of data that is a multiple of the maximum packet size Freescale MQX RTCS User s Guide Rev 10 50 Freescale Semiconductor Using Sockets 3 29 Shutting Down Stream Sockets An application can shut down a stream socket by calling shutdown with a parameter that indicates how the socket is to be shut down either gracefully or with an abort operation TCP reset The function always returns immediately Before shutdown returns outstanding calls to send and recv return immediately and RTCS discards any data that is in its receive buffer for the socket 3 29 1 Shutting Down Gracefully If the socket is to be shut down gracefully RTCS tries to deliver all the data that is in its send buffer for the socket As specified by the TCP specification RTCS maintains the socket connection for four minutes after the remote endpoint disconnects 3 29 2 Shutting Down with an Abort Opera
72. expires Default value TRUE Change Anytime Socket type Stream Comments Receive Timeout Option name OPT RECEIVE TIMEOUT Protocol level SOL TCP Values Zero RTCS waits indefinitely for incoming data during a call to recv Non zero RTCS waits for this number of milliseconds for incoming data during a call to recv Default value Zero milliseconds Change Anytime Socket type Stream Comments When the timeout expires recv returns with whatever data that has been received Receive Buffer Size Option name OPT_RBSIZE Protocol level SOL_TCP Values Recommended to be a multiple of the maximum segment size where the multiple is at least three Default value 4380 bytes Change Before bound Socket type Stream Comments When the socket is bound RTCS allocates a receive buffer of the specified number of bytes which controls how much received data RTCS can buffer for the socket Freescale MQX RTCS User s Guide Rev 10 290 Freescale Semiconductor Send Ethernet 802 10 Priority Tags Function Reference Option name RTCS SO LINK TX 8021Q PRIO Protocol level SOL LINK Values e 1 RTCS does not include Ethernet 802 10 priority tags e 0 7 RTCS includes Ethernet 802 1Q priority tags with the specified priority Default value 1 Cha
73. function i e doesn t return until the process is finished or error occurs According to second parameter an additional auto IP binding can take place if DHCP fails When the third parameter is NULL the last successful bind information is used as an input to auto IP binding Any failure during bind leaves the network interface in unbound state Return Value e IPCFG OK success RTCSERR IPCFG BUSY RTCSERR IPCFG DEVICE NUMBER RTCSERR IPCFG INIT RTCSERR IPCFG BIND See Also e ipcfg bind dhep e ipcfg poll dhcp Example define ENET IPADDR IPADDR 192 168 1 4 define ENET IPMASK IPADDR 255 255 255 0 define ENET IPGATEWAY IPADDR 192 168 1 1 uint 32 setup network void uint 32 error IPCFG IP ADDRESS DATA auto ip data enet address enet address auto ip data ip ENET IPADDR auto ip data mask ENET IPMASK auto ip data gateway ENET IPGATEWAY Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 181 Function Reference error RTCS create if error return error ENET get mac address BSP DEFAULT ENET DEVICE ENET IPADDR enet address error ipcfg init device BSP DEFAULT ENET DEVICE enet address if error return error return ipcfg bind dhcp wait BSP DEFAULT ENET DEVICE TRUE amp auto ip data Freescale MQX RTCS User s Guide Rev 10 182 Freescale Semiconductor Functio
74. interface index Description This function sends a link up trap type 3 0 SNMP trap version 1 Return Value See Also SNMPv2 trap linkUp Freescale MQX RTCS User s Guide Rev 10 306 Freescale Semiconductor Function Reference 7 1 157 SNMP_trap_userSpec Synopsis void SNMP trap userSpec TCSMIB NODE PTR trap node uint 32 spec trap RTCSMIB NODE PTR enterprises po Parameters trap_node in user specific trap node spec_trap in user specific trap type enterprises in enterprises node Description This function sends user specified trap 6 spec trap type 1 message Return Value See Also SNMP trap userSpec Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 307 Function Reference 7 1 158 SNMPv2 trap warmStart Synopsis void SNMPv2 trap warmStart void Description This function sends warm start trap type 2 message Return Value See Also e SNMP trap warmsStart Freescale MQX RTCS User s Guide Rev 10 308 Freescale Semiconductor Function Reference 7 1 159 SNMPv2_trap_coldStart Synopsis void SNMPv2 trap coldStart void Description This function sends cold start trap type 2 message Return Value See Also SNMP trap coldStart Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 309 Function Reference 7 1 160 SNMPv2_trap_authenticationFailure Synopsis void SNMPv2 trap authenticationFailu
75. memory Each node structure also points to a value structure RTCSMIB VALUE which contains the actual MIB node data or function pointer in case of run time generated values As the MIB tree typically does not need to be changed in run time the node structures may be declared const and put into read only memory this is how the script actually generates them The definition file is split into two sections separated by a 33 separator placed on a single line e Object definition section contains defintion of the MIB objects one object per line Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 81 RTCS Applications Verbatim C code section the second part of the file is copied verbatim to the output file 5 12 4 1 MIB Definition File Object Definition Each MIB object is defined on a single line of this format objectname parent number type access status index index index Only the first two parameters objectname and parent number are required Other parameters are optional depending on kind of the MIB object being defined All parameters can be described as follows objectname required the object name It should be a valid C identifier as this name appears in structure and function names in the generated code parent required the name of the parent object number required child index within the parent object e type required for leaf nodes the
76. option variable Example See DHCPSRV init Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 119 Function Reference 7 1 19 DHCP_option_addrlist Adds the list of IP addresses to the list of DHCP options for DHCP Server Synopsis boolean DHCP option addrlist uchar ptr PTR Oplptr uint 32 PTR optlen uchar opttype ip address PTR optval uint 32 listlen Parameters optptr in out Pointer to the option list optlen in out Pointer to the number of bytes remaining in the option list Passed in before optval is added Passed out after optval is added opttype in Option type to add to the list see RFC 2132 optval in Pointer to list of IP addresses listlen in Number of IP addresses in the list Description Function DHCP option addrlist adds the list of IP addresses referenced by optval to the list of DHCP options for the DHCP Server The application subsequently passes parameter optptr pointer to the option list to DHCPSRV ippool add Return Value e TRUE success FALSE failure not enough room in the option list See Also DHCPCLNT find option e DHCPSRV ippool add e DHCP option addr e DHCP option int8 e DHCP option int16 e DHCP option int32 e DHCP option string e DHCP option variable Example See DHCPSRV init Freescale MQX RTCS User s Guide Rev 10 120 Freescale Semiconductor Function Refe
77. pairs PPP SECRET to use when we authenticate ourselves to the peer e _PPP CHAP RSECRETS One of NULL LCP does not require that the peer authenticates itself Pointer to a NULL terminated array of all the ID password pairs PPP SECRET to use when authenticating the peer LCP requires that the peer authenticates itself If the peer rejects Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 59 Point to Point Drivers negotiation of the CHAP authentication protocol LCP terminates the link immediately when the link reaches the opened state 4 2 3 3 Example Setting Up PAP and CHAP Authentication 4 2 3 4 PAP Client Side The user arc has the password password On the client side for PAP authentication initialize the global variables as follows char myname arc char mysecret passwordl PPP SECRET PAP secret sizeof myname 1 sizeof mysecret 1 myname mysecret _PPP PAP LSECRET amp PAP secret 4 2 3 5 CHAP Client Side CHAP is more flexible in that it lets you have a different password on each host that you might want to connect to User arc has two accounts using e Password password on host server e Password password on host server2 On the client side initialize the global variables as follows char myname arc char serverl serverl char mysecretl passwordl char server2 server2 c
78. params UNBIND FUNC DHCPCLNT test unbind func optptr option array Fill in the requested params Request a three minute lease DHCP option int32 amp optptr amp optlen DHCPOPT LEASE 180 Request a TFTP Server FILENAME and Finger Server DHCP option variable amp optptr amp optlen DHCPOPT PARAMLIST parm options 3 error RTCS if bind DHCP timed ihandle amp params option array optptr option array timeout if error printf nDHCP boot failed error x error return Use the network interface if it successfully binds Check after the timeout value to see if it did bind Freescale MQX RTCS User s Guide Rev 10 258 Freescale Semiconductor Function Reference 7 1 133 RTCS_if_bind_IPCP Binds an IP address to the PPP device interface Synopsis uint 32 RTCS if bind IPCP _rtcs if handle rtcs if handle IPCP DATA STRUCT PTR data ptr Parameters rtcs if handle in RTCS interface handle for PPP device data ptr in Pointer to the IPCP data Description Function RTCS if bind IPCP is the only way to bind an IP address to a PPP device interface The function starts to negotiate IPCP over the PPP interface that is specified by rtcs_if handle returned by RTCS if add The function returns immediately it does not wait until IPCP has completed negotiation The PCP DATA STRUCT contains configuration parameters and a s
79. portion of the OSI model that is responsible for transmission framing and error control over a single communications link data link layer protocol A protocol that controls data transmission and error detection over a physical medium delivery service See transport protocol device An object hardware at the physical layer In RTCS there are two types of devices Ethernet devices use IP E e Serial devices use PPP and IPCP device driver Software that communicates with and manages a device In RTCS there are two types of device drivers ethernet drivers and PPP Driver device interface A number that identifies an interface for a device A device can have multiple interfaces device number A 32 bit number that identifies the interface on a device DHCP Dynamic Host Configuration Protocol direct routing The process of sending an IP datagram when the sender and destination are on the same IP network See also indirect routing discard silently Discard the packet and do not process it in a way that creates network traffic Examples of processing that can occur include logging the error and recording the event in a statistics counter discovery packet Packets during the Discovery stage of PPP over Ethernet any one of PADI packet PADO packet PADR packet PADS packet or PADT packet dispatch verb When MQX dispatches a task it is in the process of examining the ready queues to determine which task it will make
80. printf AnError shutdown failed with error code 1x status Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 299 Function Reference 7 1 150 SNMP_init Starts SNMP Agent Synopsis uint 32 SNMP init char ptr name uint 32 priority uint 32 stacksize Parameters name in Name of the SNMP Agent task priority in Priority of the SNMP Agent task we recommend that you make the priority lower than the priority of the RTCS task that is make it a higher number stacksize in Stack size for the SNMP Agent task Description This function starts the SNMP Agent and creates the SNMP task Return Value RTCS OK success Error code failure See Also e MIB1213 init Example uint 32 error register the RFC1213 MIB MIB1213 init Start SNMP Agent error SNMP init SNMP agent 7 1000 if error return error printf NnSNMP Agent is running Freescale MQX RTCS User s Guide Rev 10 300 Freescale Semiconductor Function Reference 7 1 151 SNMP trap warmStart Synopsis void SNMP trap warmStart void Description This function sends a warm start trap type 1 0 SNMP trap version 1 Return Value See Also e SNMPv2 trap warmStart Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 301 Function Reference 7 1 152 SNMP_trap_coldStart Synopsis void SNMP trap coldStart void Description This fun
81. processed The function is then able to generate customized content back to the client The following example shows a function which generates a visibility value based on the USB stick status static void usb status fn HTTPD SESSION STRUCT session if USB Stick VALUE httpd sendstr session gt sock visible else httpd sendstr session gt sock hidden const HTTPD FN LINK STRUCT fn Ink tbl usb status fn usb status fn O 0 n The callback array is registered in a similar way the CGI pages are registered by calling HTTPD SET PARAM FN TBL server HTTPD FN LINK STRUCT fn Ink tbl anytime after the HTTP server is initialized and before it is run Freescale MQX RTCS User s Guide Rev 10 78 Freescale Semiconductor RTCS Applications The HTML page may contain a special tag in the style string li style visibility lt usb status fn gt gt lt a href usb index htm gt Browse USB Mass Storage Device lt a gt lt li gt 5 10 IPCFG High Level Network Interface Management IPCFG is a set of high level functions wrapping some of the RTCS network interface management functions described in Section 2 11 Binding IP Addresses to Device Interfaces The IPCFG system may be used to monitor the Ethernet link status and call the appropriate bind functions automatically In the current version the IPCFG supports automatic binding of static IP address or automated
82. received the server sends a quote back Sample quotations are provided in gotdsrv quotes c The client task QUOTE client connects to the server gets the quote displays it and then closes the connection 5 19 Typical RTCS IP Packet Paths Figure 5 1 is a diagram of typical code paths for IP packet handling in RTCS applications This is a generic illustration only for general purposes such as finding good locations for setting a breakpoint The functions listed are internal to RTCS The driver s input and output interfaces are specific to the media interface driver software such as an ethernet driver Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 89 RTCS Applications IP send Y ICMP IGMP TCP UDP IP_complete_recv Y IP route IP send dgram IP service Y A IP complete send nat exec message ARP service N IPLOCAL_service IP_reasm Call send function for device Driver s output function Driver s input function ARP resolve Ethernet only Figure 5 1 Typical RTCS Packet Processing Paths Freescale MQX RTCS User s Guide Rev 10 90 Freescale Semiconductor Chapter 6 Rebuilding 6 1 Why to Rebuild RTCS You need to rebuild RTCS if you do any of the following Change c
83. renewal of DHCP assigned addresses It may operate in its own independently runnig task or in a polling mode The IPCFG API functions are all prefixed with ipefg_ prefix See the functions reference chapter for more details The usage procedure of IPCFG is as follows 1 Create RTCS as described in previous sections RTCS_create 2 Initialize network device using ipcfg init device 3 Use one of the ipcfg bind xxx functions to bind the interface to an IP address mask and gateway IPv6 address will be assigned automatically using the IPv6 stateless auto configuration To add IPv6 address manually use ipcfg6 bind addr see example in shell source rtcs sh_ipconfig c Shell ipconfig staticip 4 You can start the link status monitoring task ipcfg task create to automatically rebind in case of Ethernet cable is re attached Another method to handle this monitoring is to call ipcfg task poll periodically in an existing task 5 You can acquire bind information using various iocfg get xxx functions The whole IPCFG functionality is demonstrated in the ipconfig command in shell See its implementation in the shell source rtcs sh ipconfig c source code file Part of IPCFG functionality depends on what RTCS features are enabled or disabled in the user config h configuration file Any time this configuration is changed the RTCS library and all applications must be rebuilt IPCFG functionality is affected by following defines
84. s Guide Rev 10 142 Freescale Semiconductor Function Reference FTPd init initializes a new FTP Server found in the examples directory which has the following enhancements It uses revised file system abstraction allowing better support for MFS and TargetFFS It supports multiple simultaneous FTP sessions e It uses a command table so the user can configure the supported commands We recommend the use of FTPd init in place of FTPSRV init Return Value e RTCS_OK success Error code failure Example finclude lt mgx h gt finclude lt rtcs h gt finclude ftpd h ftp root dir const char FTPd rootdir ftp commands const FTPd COMMAND STRUCT FTPd commands abor acctt cdup cwd feat help dele LIST mkd noop nist opts pass pasv port pwd guit unire rnto retr stor rmd site size syst type user xcwd xmkd xpwd xrmd NULL FT n oe a Men n Ice Hg a Aaa ga ug FT rd TPd cdup TPd cd TPd feat TPd help TPd dele TPd list TPd mkdir TPd noop Pd nlst TPd opts Pd pass TPd pasv Pd port TPd pwd TPd quit TPd rnfr TPd rnto TPd retr TPd stor Pd rmdir TPd site Pd size TPd syst Pd type TPd user Pd cd N di Ys Fa E E TPd mkdir TPd p
85. s Guide Rev 10 Freescale Semiconductor 15 AE IA Before You Begin 1 3 4 Cautions Cautions tell you about commands or procedures that could have unexpected or undesirable side effects or could be dangerous to your files or your hardware CAUTION If you modify MQX data types some tools might not operate properly Freescale MQX RTCS User s Guide Rev 10 16 Freescale Semiconductor Chapter 2 Setting Up the RTCS 2 1 Introduction This chapter describes how to configure create and set up the RTCS so that it is ready to use with sockets For information about See Data types mentioned in this chapter Chapter 8 Data Types PPP Driver and PPP over Ethernet Driver Chapter 4 Point to Point Drivers Protocols Section Appendix A Protocols and Policies Prototypes for functions mentioned in this Chapter 7 Function Reference chapter Sockets Chapter 3 Using Sockets 2 2 Supported Protocols and Policies Figure 2 1 shows the protocols and policies that are discussed in this manual For more information about protocols see the table below and Section Appendix A Protocols and Policies 2 3 RTCS Included with Freescale MQX RTOS The RTCS stack included in Freescale MQX RTOS distribution is based on the ARC RTCS version 2 97 Parts of this document may refer to features not available in the Freescale MQX RTCS Please read the Release Notes documen
86. secrets sizeof userl 1 sizeof secret1 1 userl secretl sizeof user2 1 sizeof secret2 1 user2 secret2 sizeof user3 1 sizeof secret3 1 Freescale MQX RTCS User s Guide Rev 10 Point to Point Drivers Freescale Semiconductor 61 Point to Point Drivers user3 secret3 0 0 NULL NULL _PPP CHAP LNAME myname _PPP_CHAP_RSECRETS secrets 4 2 4 Initializing PPP Links Before an application can use a PPP link it must initialize the link by calling PPP_initialize The function does the following for the link e It allocates and initializes internal data structures and a PPP handle which it returns It installs PPP callback functions that service the link It initializes LCP and CCP e It creates send and receive tasks to service the link e It puts the link into the Initial state 4 2 4 1 Using Multiple PPP Links An application can use multiple PPP links by calling PPP_initialize for each link 4 2 5 Getting PPP Statistics To get statistics about PPP links call IPIF stats Table 4 1 Summary Using PPP Driver PPP_initialize Initializes PPP Driver LCP or CCP for a PPP link PPP_SECRET Authentication passwords IPIF stats Gets statistics about PPP links 4 2 6 Example Using PPP Driver See Section 2 15 6 Example Setting Up RTCS PPP server and PPP client functionality is demonstrated in the RTCS shell example app
87. sineta abat statea m 99 7 1 5 _iopcb_ pppoe COM WW usu dia ase shee E nl ERES ERREUR AA 100 7 145 DEDE COM SIMS 222a a xoa PIRE HT ta n aa 103 7 1 7 _pppoe server destroy GG GG ua 104 7 168 pppoe Server i BU Las Dw CW YRS DD DDU DAD c dada aia d d 105 7 49 _ pppoe Server I TOmoVel aes REX RARA GAF EU 106 7 1 10 DppDOS server il SIalSl cios ara DYW YSW AED AD DYD AU 107 1 pppoe server RM Gi acea inta aa derrita 108 7 1 12 pppoe server session stats eee Fu 109 A 5 UT e aaa O a Oh fe n bed Ln a a did Ge pora d 110 PARLE i ET RR a 112 Pl VMN EF iA ST RR RH oor need 114 Aia A rcp ewes ee ees 116 7 1 17 DHGP mu OpUOF a area ave RA e ad 118 2 1218 DACP OOUON SOON aia scana asia EDUD UR Od sa aa YEDEDURF ati a d 119 Z1 ae o Lola Sad ll EA barda 120 Freescale MQX RTCS User s Guide Rev 10 6 Freescale Semiconductor 2120 DACP SHION WO uas essa d qose ula Pd e wales 121 7 121 DACP COUCH an D s xd Rid ded eden b ERU A GRECE AA 122 7 122 DHCP CODIO lb ss incas e Y see eee a 129 Fe DACP COUN Sl rescato ee PS En aet ai AUR ERO CER RN 123 7 1 24 DHCP option variable GG eee eee eee 125 2 1 29 DACPCENT And SPON sms ca ai mate ladies ro Errar 126 LO DEI POLII TRIBAN chance REXERRI ra 127 7 1 27 DHCPSRV ND coros a ai al e n ae da ced 128 Z L29DHOPSHV ippool BOG sai caci ine beba dit RE atat bat
88. socket option expires Return Value e RTCS OK success e Specific error code failure See Also e accept bind getsockopt Freescale MQX RTCS User s Guide Rev 10 116 Freescale Semiconductor e listen setsockopt e socket Examples Stream Socket a The connection use IPv4 protocol uint 32 sock uint 32 child handle sockaddr in remote sin uint 16 uint 32 result Connect to 192 203 0 83 port 2011 Function Reference remote addrlen sizeof sockaddr in memset char amp remote sin 0 sizeof sockaddr in remote sin sin family AF INET remote sin sin port 2011 remote sin sin addr s addr 0xC0A80001 192 168 0 1 result connect sock struct sockaddr amp remote sin remote addrlen if result RTCS OK printf AnError connect failed with error code 1x result else printf inConnected to lx port d remote sin sin addr s addr remote sin sin port a The connection use IPv6 protocol uint 32 socket tcp struct addrinfo struct addrinfo struct addrinfo foreign addrv6 res local addrv6 res hints hints ai family AF UNSPEC hints ai socktype SOCK DGRAM hints ai flags AI PASSIVE pointer to PC IPv6 address pointer to Board IPv6 address hints used for getaddrinfo getaddrinfo NULL 7007 amp hints amp local addrv6 res hints ai family AF UNSPEC hin
89. src in Pointer to an address in network format dst out Pointer to address in presentation format sizeof dst in Size of dst buffer Description Converts an address src from network format usually a struct either in_addr or in6addr in network byte order to presentation format suitable for external display purposes This function is presently valid for AF INET and AF INET6 Return Value This function returns NULL if a system error occurs or it returns a pointer to the destination string Example a IPv4 protocol in addr addr char prn addr sizeof 255 255 255 255 inet ntop AF INET amp addr prn addr sizeof prn addr printf IP addr s n prn addr b IPv6 protocol in6 addr addr6 char prn addr6 sizeof ffff ffff ffff ffff ffff ffff 255 255 255 255 inet ntop AF INET6 amp addr6 prn addr6 sizeof prn addr6 printf IP addr sAn prn addr6 Freescale MQX RTCS User s Guide Rev 10 170 Freescale Semiconductor Function Reference 7 1 61 IP stats Gets a pointer to the IP statistics Synopsis IP STATS PTR IP stats void Description Function IP stats takes no parameters and returns a pointer to the IP statistics that RTCS collects Return Value Pointer to the P STATS structure See Also ARP stats e ENET get stats CMP stats e IGMP stats e IPIF_stats e TCP stats e UDP stats IP STATS Example See ARP stats Fre
90. task we recommend that you make the priority lower than the priority of the RTCS task that is make it a higher number stacksize in Number of bytes to allocate for the TFTP Server task stack see description Description This function creates TFTP Server task and blocks until TFTP Server task has completed its initialization We recommend a stack size of at least 1000 bytes Increase it only if you increase the value of TFTPSRV MAX TRANSACTIONS whose default value 20 is defined in ffip h Return Value e RTCS OK success e RTCS error code failure See Also e TFTPSRV access Example uint 32 error Start TFTP Server error TFTPSRV init TFTP server 7 1000 if error return error printf NnTFTP Server is running return 0 Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 323 Function Reference 7 1 172 UDP_stats Gets a pointer to UDP statistics Synopsis UDP STATS PTR UDP stats void Description Function UDP stats gets a pointer to the UDP statistics that RTCS collects Return Value Pointer to the UDP STATS structure See Also ARP stats e ENET get stats CMP stats e GMP stats jnet pton e IPIF_stats e TCP stats e ARP STATS Example See ARP stats Freescale MQX RTCS User s Guide Rev 10 324 Freescale Semiconductor 7 2 Functions Listed by Service Function Reference Table
91. the option list Passed in before optval is added Passed out after optval is added opttype in Option type to add to the list see RFC 2132 optval in Value to add Return Value TRUE success FALSE failure not enough room in the option list See Also DHCPCLNT find option e DHCPSRV ippool add e DHCP option addr e DHCP option addrlist e DHCP option int16 e DHCP option int32 e DHCP option string e DHCP option variable Example See DHCPSRV init 7 1 23 DHCP option string Adds a string to the list of DHCP options for DHCP Server Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 123 Function Reference Synopsis uint 32 DHCP option string uchar ptr PTR op p r uint 32 PTR optlen uchar opttype char ptr optval Description Function DHCP option string adds a string to the list of DHCP options for the DHCP Server The application subsequently passes parameter optptr pointer to the option list to DHCPSRV ippool add Parameters optptr in out Pointer to the option list optlen in out Pointer to the number of bytes remaining in the option list Passed in before optval is added Passed out after optval is added opttype in Option type to add to the list see RFC 2132 optval in String to add Return Value TRUE success FALSE failure not enough room in the option list See Also DHCPCLNT fi
92. the topology of the subnetworks network layer protocol A protocol that routes datagrams from the original source to the final destination over physical networks Because network layer protocols are independent of the medium they use link layer protocols to send packets over individual physical networks network mask A 32 bit quantity that indicates which bits in an IP address refer to the network portion Sometimes called net mask or address mask node See host NULL FCS No Frame Check Sequence for PPP frames See also CCITT 16 and CCITT 32 O opaque data Data whose interpretation is unknown by a layer because the layer does not have the XDR translation function Open Systems Interconnection See OSI option In RTCS the following have options associated with them DHCP IGMP e IPCP e PPP links e sockets OSI Open Systems Interconnection An international body to facilitate communication among computers of different manufacturers and technologies Freescale MQX RTCS User s Guide Rev 10 420 Freescale Semiconductor P packet The unit of transmission at the network layer and passed between the network layer and the data link layer A packet is usually mapped to one frame the unit of transmission at the data link layer the exception occurs when an IP datagram is fragmented into multiple smaller datagrams See also segment Packet Control Block See PCB PADI packet Active Discovery In
93. uint 32 dev num uint 32 pow val uint 32 flags Parameters dev num in Device identification index pow val in Power in dBm flags in Device specific options Description For cards supporting multiple transmit powers sets the transmit power in dBm If W is the power in Watt the power in dBm is P 30 10 log W In addition on and off enable and disable the radio and auto and fixed enable and disable power control if those features are available Return Value e ENET OK success ENETERR INVALID DEVICE Freescale MQX RTCS User s Guide Rev 10 218 Freescale Semiconductor Function Reference 7 1 104 iwcfg set scan Synopsis uint 32 iwcfg set scan uint 32 dev num char ptr ssid Parameters dev num in Device identification index ssid in Not used yet Description This will find all avialable networks and print them in format The format is wifi vendor dependent ssid tplink SSID name bssid 94 c 6d a5 51 b SSID s MAC address channel 1 channel strength signal strength in graphics indicator 183 signal strength Return Value e ENET OK success ENETERR INVALID DEVICE Example define SSID NGZG Inv 32 error IP configuration error RTCS_create ENET get mac address DEFAULT DEVICE ENET IPADDR enet address error ipcfg init device DEFAULT DEVICE ENET IPADDR
94. 0 7 1 761pelg gel link acllVel asseu i ne he reae rum a aaa Rh so 191 7 af Pero get die JDU 2 oves azrx4 emi cete aa iei aa a bei ease eels 192 7 1478 iper 200 ONE IUD rear Do ROC Rn n eee ao ac dedo eee neat 193 as ipofg del dS ss cit mtr be oco on seein dod 194 A 1 80 WC OBL NOY ansa dn AERRARRCROCR EPERRAXERRERLIQAPRE C de At DRESS 195 7 1 811pefg get Mp serveraddress so GR cu o ora irr Oe RR RES 196 7 1 82 ipcfg get_tiip servername ooocccconin dsc ee unam non ram caw Res 197 7 1 83 ipcfg get boot filename GG GG ua 198 Fa IpERI DO OCDE cusacene su pid e a dt X RADA EROR 199 TOSCO TASK CFOSIOL a up iaces s aca de ARE NE ee a o ar RR E dea RS d 200 TOC TOS dO SNO SM ii dg e aree e dios 201 7 1987 NOC las SIS aia b para HE FC RT RF 202 PASSO task pol i cea ei ie al ale le a 203 7 Veter UNDOING 3a dn dna a e tv oi i ar od od odes 204 T 1201600 DING 19 o D na are e a d end o y decta Fg a dp ia d E ERR e d e ds 205 7 1 91 a A AA O A O OO E SERERE LED pduhE ded E Ves xed 206 7a 92 Cid eal BSSIUD aqua Cere Aa al e n Y doni eod 207 7 1 93 1wctfg get essid eer eser mme hem kx Ie ARR RE 208 2 198 CG COMMIN uus asuma aa sa az bio ata da a aaa a TN e EO EE S 209 414003 weld se MOdS sisi i nEn niopen e a a a e a ES 210 ME MA tl ol oe ee a baza hie led zac dai ed 211 7 1 97 WWolg sel Wen KEVIN scara a bai miei fobii re 212 7 1 98 iwcfg
95. 0 in addr structure 231 INADDR ANY 84 information on DHCP server 175 initial transmission timeout socket option 189 Internet Standard Subnetting Procedure 7 IP 7 266 ICMP and 267 statistics getting 127 IP addresses binding to device interfaces 13 155 using BootP 156 using DHCP 158 160 162 166 using IPCP 164 unbinding device interfaces 13 170 IP forwarding enabling 11 IP multicast group structure ip mreq 232 ip mreq structure 232 IPCP 7 35 callback functions 11 164 using to bind an IP address 13 164 IPCP DATA STRUCT 236 IP E 7 IPIF statistics getting 42 128 IPIP 7 IPsec 272 K keep alive timeout socket option 190 L LCP 7 35 41 135 271 configuration optionsspan lcp options 35 links PPP initializing 12 41 135 logging disabling 14 180 enabling 14 181 maximum retransmission timeout socket option 190 maximum segment lifetime 197 199 MDS 7 metric for gateway 150 152 MIB 7 MIB 1213 installing 57 130 MRU 36 37 N NAT 7 272 NAT alg table 16 nat ports structure 240 NAT STATS structure 241 nat timeouts structure 242 network address translation starting 132 statistics 133 stopping 131 no Nagle algorithm socket option 191 O OPT_CHECKSUM_BYPASS 187 OPT_CONNECT_TIMEOUT 187 OPT_KEEPALIVE 190 OPT_MAXRTO 190 OPT NO NAGLE ALGORITHM 191 OPT RBSIZE 193 OPT RECEIVE NOWAIT 188 192 OPT RECEIVE PUSH 193 OPT RECEIVE TIMEOUT
96. 10 252 Freescale Semiconductor DHCP_DATA STRUCT params uchar parm options 3 DHCPOPT SERVERNAME DHCPOPT FILENAME DHCPOPT FINGER SRV error ENET initialize 0 enet local 0 amp ehandle if error printf AinFailed to initialize Ethernet driver s ENET strerror error return error RTCS create if error RTCS OK printf AnFailed to create RTCS error x error return error RTCS if add ehandle RTCS IF ENET amp ihandle if error printf nFailed to add the interface rror x error return You supply the following functions if any is NULL DHCP Client follows its default behavior params CHOICE FUNC DHCPCLNT test choice func params BIND FUNC DHCPCLNT test bind func params UNBIND FUNC DHCPCLNT test unbind func optptr option array Fill in the requested params Request a three minute lease DHCP option int32 amp optptr amp optlen DHCPOPT LEASE 180 Request a TFTP Server FILENAME and Finger Server DHCP option variable amp optptr amp optlen DHCPOPT PARAMLIST parm options 3 error RTCS if bind DHCP ihandle amp params option array optptr option array if error printf nDHCP boot failed error x error return Use the network interface when it is bound Freescale MQX RTCS User s Guide Rev 10 Function Reference F
97. 1213 init e MIB find objectname Example Freescale MQX RTCS User s Guide Rev 10 224 Freescale Semiconductor Function Reference 7 1 109 NAT_close Stops Network Address Translation Synopsis uint 32 NAT close void Return Value RTCS OK success See Also NAT init Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 225 Function Reference 7 1 1310 NAT init Starts Network Address Translation Synopsis uint 32 NAT init ip address prv network ip address prv netmask Parameters prv network in Private network address prv_netmask in Private network subnet mask Description Freescale MQX NAT starts working only when network address translation has started by a call to NAT init and the P forward global running parameter is TRUE Function NAT init enables all the application level gateways that are defined in the NAT alg table For more information see Section 2 15 3 Disabling NAT Application Level Gateways You can use this function to restart Network Address Translation after you call NAT close Return Value e RTCS OK success e RTCSERR OUT OF MEMORY failure RTCSERR INVALID PARAMETER failure See Also NAT close e NAT stats e nat ports nat timeouts NAT STATS Freescale MQX RTCS User s Guide Rev 10 226 Freescale Semiconductor Function Reference 7 1 111 NAT_stats Gets Network Address Transl
98. 193 OPT RETRANSMISSION TIMEOUT 189 OPT SEND NOWAIT 194 195 OPT SEND PUSH 195 OPT SEND TIMEOUT 195 OPT SOCKET ERROR 196 OPT SOCKET TYPE 196 OPT TBSIZE 196 OPT TIMEWAIT TIMEOUT 197 P PAP 7 36 37 38 example 39 parameters RTCS creation 11 running 11 23 PCBs max RTCS 11 opening driver for PPP 67 PCB handle destroying for PPPoE Client 69 getting for HDLC 68 Freescale MQX RTCS User s Guide Rev 10 430 Freescale Semiconductor for PPPoE Client 70 structure 217 PCB table structure 217 peer name stream sockets getting 120 PF_INET 205 PFC 36 37 ping 7 174 PPP 7 35 callback functions 41 67 154 253 frame 270 PPP Driver 35 authentication protocols 37 changing 38 example 39 configuring 37 example 17 function summary 42 HDLC like framing device initializing 68 I O PCB driver opening 67 initializing 12 41 135 IP addresses binding to 164 LCP configuration optionsspan lcp_ options 35 PPP over Ethernet framing device destroying 69 PPP over Ethernet framing device initializing 70 stack size additional 37 statistics getting 42 128 task priority 38 PPP in HDLC like Framing 7 PPP LCP Extensions 7 PPP links initializing 41 135 PPP over Ethernet callback functions 244 245 246 destroying 69 example 70 function summary 43 initializing 12 70 setting up 42 statistics PPPOE SESSION STATS STRUCT 247 statistics PPPOEIF STATS 24
99. 2 1 LCP Configuration Options The following table lists the LCP configuration options that PPP Driver negotiates It lists the default values that RFC 1661 specifies and PPP Driver uses The table also indicates for which option an application can change the default value A description of each option follows the table Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 55 Point to Point Drivers Configuration option Default See also ACCM Asynchronous Control OxFFFFFFFF Section 4 2 2 Character Map Configuring PPP Driver ACFC Address and Control Field FALSE Compression AP Authentication Protocol none Section 4 2 2 You cannot change the default Configuring PPP value of the AP option itself but Driver you can change the default values of global variables that define the authentication protocol MRU Maximum Receive Unit 1500 PFC Protocol Field Compression FALSE 4 2 1 1 ACCM ACCM is a 32 bit mask where each bit corresponds to a character from 0x00 to 0x1F The least significant bit corresponds to 0x00 the most significant to 0x1F For each bit that is set to one PPP Driver escapes the corresponding character every time it sends the character over the link Because not all processors number bits in the same way we define bit zero to be the least significant bit The driver sends escaped characters as two bytes in the following order HDLC esca
100. 2 10 FTPDCFG SEND TIMEOUT Sending timeout 2 16 3 2 11 FTPDCFG TIMEWAIT TIMEOUT The timeout 2 16 3 3 Telnet 2 16 3 3 1 TELNETDCFG_BUFFER_SIZE Telnet Server buffer size 2 16 3 3 2 TELNETDCFG_NOWAIT Enable nonblocking functionality Default value FALSE 2 16 3 3 3 TELNETDCFG ENABLE MULTIPLE CLIENTS Enable simultaneous client connections Default value RTCSCFG FEATURE DEFAULT Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 39 Setting Up the RTCS 2 16 3 3 4 TELENETDCFG_CONNECT_TIMEOUT Connection timeout 2 16 3 3 5 TELENETDCFG SEND TIMEOUT Sending timeout 2 16 3 3 6 TELENETDCFG TIMEWAIT TIMEOUT The timeout 2 16 3 4 SNMP 2 16 3 4 1 RTCSCFG ENABLE SNMP STATS Enable SNMP statistics Default value RTCSCFG ENABLE STATS 2 16 3 5 IPCFG 2 16 3 5 1 RTCSCFG IPCFG ENABLE DNS Enable DNS name resolving depends on RTCSCFG ENABLE DNS RTCSCFG ENABLE UDP and RTCSCFG ENABLE LWDNS 2 16 3 5 2 RTCSCFG IPCFG ENABLE DHCP Enable DHCP binding depends on RTCSCFG ENABLE UDP 2 16 3 5 3 RTCSCFG IPCFG ENABLE BOOT Enable TFTP names processing and BOOT binding 2 16 4 HTTP Server default configuration 2 16 4 1 HTTPDCFG POLL MODE Default 1 Set to 1 to run HTTP Server in poll mode all sessions handled by a single task Set to 0 to handle each HTTP session in a different task 2 16 4 HTTPDCFG DEF PORT HTTP Server listen port Default value 80 Override in application w
101. 2 2 Adding Gateways to a Specific Route To add a gateway with address ip address to reach subnet 192 168 1 0 24 call RTCS gate add ip address 0xC0A80100 OXFFFFFFOO 2 12 3 Removing Gateways To remove a gateway call RTCS gate remove Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 25 Setting Up the RTCS 2 13 Downloading and Running a Boot File After an application has bound at least one IP address to each interface it can download and run a boot file The format of the boot file depends on the output of the compiler that you use To get a boot file of this format and Call download and run the boot file Binary code RTCS_exec_TFTP_BIN Common Object File Format RTCS_exec_TFTP_COFF Motorola S Records RTCS_exec_TFTP_SREC 2 14 Enabling RTCS Logging You can enable RTCS event logging in the MQX kernel log Performance analysis tools can use kernel log data to analyze how an application operates and how it uses resources Before you enable RTCS logging you must have MQX RTCS library compiled with RTCSCFG LOGGING defined to 1 for kernel log compilation parameters read MQX User s Guide In application user must create the kernel log and enable RTCS logging KLOG RTCS FUNCTIONS better description for kernel log can be found in MOX User s Guide Final step to enable RTCS event logging is calling RTCSLOG enable with required event mask To disable RTCS event lo
102. 3 13 Creating and Using Sockets sc kcu Rr UU la aa aa pe e m aa acea durs 45 3 14 Creating Sockets eo parea e avec Re de a RU RA e e ae e pe e re 47 3 15 Changing Sockel ODIOIIS a coama asa nas uz aaa dia aa azeua Le SANDEE DER 47 So BINE SOCKS i EC E Tm 47 3 17 Using Datagram Sockets u s as au eres den led dd 47 3 18 Selling Datagram Sockel Options aai cane arta e rate de e dei lt ace fi de o d dee e nl 47 2 19 Tasten Datagram Dala ia mai Haee ot od dd n e ei balet id 48 319 1 BUS cte ped dara Ge iris qe ad ada ue 48 3 19 2 Pre Specifying a Peer nene mazare mea eee xx UD 48 3 20 Shutting Down Datagram Sockets ne i ia ad ia oe coat d Dra e 48 mel USING Stream SOCKS FR dee Y ranki krediten e A dl A e 08 A 8 a e ie de r 48 3 22 Changing Stream Socket Options 2 0c20cccesedean cerrara 48 3 23 Establishing Stream Socket Connections 00 ccc eee eee ee eee aaa 49 3 23 1 Establishing Stream Socket Connections Passively 49 3 23 2 Establishing Stream Socket Connections Actively 49 3 24 Getting Stream Socket Names e pia aa sat sata aaa ema taca m meet E a 49 3 25 Sending Stream Dale 026 cae ceeean dud soseass errada 49 e ai Dala aug dod scire a eO Y O wa o dace Ed ed E ERRARE ET Rd 50 3 27 Buffering Data sai cra NN NF FD FFYN 50 3 28 Improving the Throughput or Stream Data 2 cscccocsdectareuecuns cad ER ns 50 229 Shutting Down Stream SOCKS oc acnee aaa ae cet la
103. 5 Data Types 8 3 36 sockaddr Structure for a socket endpoint identifier supported by IPv4 and IPv6 if RTCSCFG ENABLE IP6 typedef struct sockaddr uint 16 sa family char sa data 22 sockaddr felse if RTCSCFG ENABLE IP4 define sockaddr sockaddr_in define sa family sin family tendi f tendi f sa_family The code for the address format It identifies the format of the data that follows sa_data The actual socket address data which is format dependent The length also depends on the format Each address format has a symbolic name which starts with AF_ AF_INET This determines the address format that goes with the Internet namespace AF_INET6 This is similar to AF_INET but refers to the IPv6 protocol AF_UNSPEC This determines no particular address format Freescale MQX RTCS User s Guide Rev 10 386 Freescale Semiconductor Data Types 8 3 37 TCP STATS A pointer to this structure is returned by TCP_stats typedef struct uint 32 ST RX TOTAL uint 32 ST RX MISSED uint 32 ST RX DISCARDED uint 32 ST RX ERRORS uint 32 ST TX TOTAL uint 32 ST TX MISSED uint 32 ST TX DISCARDED uint 32 ST TX ERRORS RTCS ERROR STRUCT ERR RX RTCS ERROR STRUCT ERR TX uint 32 ST RX BAD PORT uint 32 ST RX BAD CHECKSUM uint 32 ST RX BAD OPTION uint 32 ST RX BAD SOURCE uint 32 ST RX SMALL HDR uint 32 ST RX SMALL D
104. 5 15 Telnet Server Telnet Server implements a server that complies with the Telnet protocol specification RFC 854 To start Telnet Server an application calls TELNETSRV _init with the name of the task that implements the server the task s priority its stack size and a pointer to the task that the server starts when a client initiates a connection When the server is started the application should make the priority of the task lower than the TCP IP task that is make the task s priority 7 8 9 or greater See information on the HTCSTASK priority variable in Section 2 6 Changing RTCS Creation Parameters Note Telnet Server listens on a stream socket When the Telnet Client initiates a connection the server creates a new task and redirects the new task s I O to the socket 5 16 TFTP Client TFTP Client implements a client that complies with the TFTP see RFC 1350 TFTP Client sends a request message to port 69 5 17 TFTP Server TFTP Server implements a server that complies with the Trivial File Transfer Protocol TFTP see RFC 1350 TFTP enables files to be moved between computers on different UDP networks 5 17 1 Configuring TFTP Server By default the maximum number of TFTP transactions TFTPSRV MAX TRANSACTIONS is 20 defined in ftp h If you change the default value you must recompile TFTP Server RTCS provides TFTPSRV access which allows all read accesses and denies all write accesses
105. 6 RTCSCFG BOOTP RETURN YIADDR When RTCSCFG BOOTP RETURN YIADDR is 1 the BOOTP DATA STRUCT has an additional field which will be filled in with the YIADDR field of the BOOTREPLY 2 16 2 7 RTCSCFG UDP ENABLE LBOUND MULTICAST When RTCSCFG UDP ENABLE LBOUND MULTICAST is 1 locally bound sockets that are members of multicast groups will be able to receive messages sent to both their unicast and multicast addresses 2 16 2 8 RTCSCFG LINKOPT 8021Q PRIO By default RTCS does not send and receive Ethernet 802 10 priority tags Set this value to 1 one to have RTCS send and receive Ethernet 802 1Q priority tags 2 16 2 9 RTCSCFG LINKOPT 8023 By default RTCS sends and receives Ethernet II frames Set this value to 1 one to have RTCS send and receive both Ethernet 802 3 and Ethernet II frames 2 16 2 10 RTCSCFG DISCARD SELF BCASTS By default controls whether or not to discard all broadcast packets that we sent as they are likely echoes from older hubs 2 16 2 11 RTCS MINIMUM FOOTPRINT Default 0 Set to 1 to enable RTCS optimizations for small RAM devices Setting this parameter 1 causes the RTCSCFG FEATURE DEFAULT setting to 0 automatically Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 33 Setting Up the RTCS 2 16 2 12 RTCSCFG FEATURE DEFAULT This parameter is used to determine the default enable disable state of RTCS features 2 16 2 13 RTCSCFG ENABLE ICMP Default value RTCSCFG FEATURE DEFAULT
106. 7 2 Service Functions DHCP Client RTCS_if_bind_DHCP DHCPCLNT find option DHCP Server DHCP DHCPSRV DNS Resolver DNS init gethostbyaddr gethostbyname Echo Server ECHOSRV_init EDS Server Winsock DNS init Ethernet Driver ENET get stats part of MQX ENET initialize part of MQX FTP Client FTP close FTP command FTP command data FTPd init FTP Server FTPSRV init HDLC iopcb ppphdlc init HTTP Server httpd default params httpd server init httpd server run httpd server poll I O PCB driver iopcb open iopcb ppphdlc init iopcb pppoe client init Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 325 Function Reference Table 7 2 continued IPCFG ipcfg init device ipcfg init interface ipcfg bind boot ipcfg bind dhcp ipcfg bind dhcp weait ipcfg bind staticip ipcfg get device number ipcfg add interface ipcfg get ihandle ipcfg get mac ipcfg get state ipcfg get state string ipcfg get desired state ipcfg get link active ipcfg get dns ip ipcfg add dns ip ipcfg del dns ip ipcfg get ip ipcfg get tftp serveraddress ipcfg get tftp servernamer ipcfg get boot filename ipcfg poll dhcp ipcfg task create ipcfg task destroy ipcfg task status ipcfg task poll ipcfg unbind IWCFG iwcfg set essid iwcfg get essid iwcfg commit iwcfg set mode
107. 8 statistics getting 73 77 79 ppp h 216 PPP SECRET structure 251 PPPoE 7 PPPoE Server adding an Ethernet interface 75 destroying task 74 initializing 78 removing an Ethernet interface 76 statistics getting Ethernet 77 getting PPP session 79 pppoe h 216 PPPOE CLIENT INIT DATA STRUCT structure 243 PPPOE SERVER INIT DATA STRUCT structure 245 PPPOE SESSION STATS STRUCT structure 247 PPPOEIF STATS structure 248 priority of tasks PPP Driver 38 RTCS 11 protocol family internet 205 protocol stack RTCS 9 protocols RTCS defining 10 Q Quote of the Day protocol 7 58 Quote of the day service 58 R R2 timeout socket option 188 receive buffer size socket option 193 receive Ethernet 802 1Q priority tags socket option 191 receive Ethernet 802 3 frames socket option 192 receive nowait socket option 30 192 receive push socket option 30 193 receive timeout socket option 193 reducing code size 255 references documentation 3 release DHCP client 97 Requirements for Internet Hosts 7 Requirements for IP Version 4 Routers 7 retransmission timeout socket option 189 RFCs supported 6 RIP 7 in RTCS protocol table 255 round trip time stream sockets 190 RPC 7 rpctypes h 216 RTCS checksums bypassing 11 compile time options 19 recommended settings 19 creating 11 142 directory structure 61 example creating and setting up 17 function summary 17 gateways adding 13 149 m
108. AA mete desde Ge bs SERERE ledosdietoeeesued neve 23 2 8 Changing RIGS Running Parameters mi e saaa aana dia de 23 25 1 Enabling IP Forwarding i exeo teda hd e dee a a deb ORE RARE Reda 23 282 Bypassing TCP Checksum iso REG eu din ww aaa y 24 2 9 Initializing Device Interfaces Y eee 24 2 9 1 Initializing Interfaces to Ethernet Devices 24 2 9 2 Initializing Interfaces to Point to Point Devices 24 2 10 Adding Device Interfaces to TOS L G 2RN e recrear 25 2 10 1 Removing Device Interfaces from RTCS VVY Y YY 25 2 11 Binding IP Addresses to Device Interfaces YY ud 25 2 11 1 Unbinding IP Addresses from Device Interfaces 25 2 12 Addam ASICWAS _ II e EIN cede pe 25 2 12 1 Adding Default Gateways VYL FF ele 25 2 12 2 Adding Gateways to a Specific ROUt6 VV YY 25 2 12 Hemeovilig GaleWalis HO I O Orosa nee Ka OO II yN 25 2 13 Downloading and Running Boot File kamera hn RR dn 26 2 14 Enabling RTOS LOGGING uuadosaberkezkscbredseish amp schicreER ZOLbU si9i4 592x4 26 2 15 Starting Network Address Translation sesicochascchbes reste ere ERE DE ES 26 2 15 1 Changing Inactivity Timeouts L FFI GY ee 27 2 15 2 Specifying Port Ranges sau iat ae i dardo be ba a drag dae Red RE REEESAS 27 2 15 3 Disabling NAT Application Level Gateways esser
109. AF INET HTTPD SET PARAM CGI TBL server cgi Ink tbl H h TTPD SET PARAM FN TBL server fn Ink tbl ttpd server run server b IPv6 protocol HTTPD ROOT DIR STRUCT root dir Freescale MQX RTCS User s Guide Rev 10 158 Freescale Semiconductor Function Reference m eqs by 0 0 table termination record HTTPD STRUCT server server httpd server init root dir NWngx html AF INET6 HTTPD SET PARAM CGI TBL server cgi Ink tbl HTTPD SET PARAM FN TBL server fn Ink tbl httpd server run server Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 159 Function Reference 7 1 51 httpd server run This function starts the HTTP server task or tasks Synopsis int httpd server run HTTPD STRUCT server Parameters server in pointer to main server structure HTTPD STRUCT returned by httpd init or httpd server init Description Depending on HTTPDCFG POLL MODE compilation parameter from user config h this function starts the HTTP server tasks or tasks With HTTPDCFG POLL MODE set non zero single HTTP server task is started In this mode all sessions are handled polled from a single task Alternatively the HTTP server may be polled from the caller s task by calling httpd server poll periodically e With HTTPDCFG_ POLL MODE set zero mutiple tasks are started one for each HTTP session Return Value Re
110. ATA STRUCT boot data enet handle ehandle rtcs if handle ihandle uint 32 error error ENET initialize 0 enet local if error return error error RTCS create if error return error error RTCS if add ehandle RTCS IF ENET if error return error 0 memset amp boot_data erro if 0 sizeof boot data RTCS if bind BOOTP ihandle error return error printf MnDownloading the boot file n rror RTCS exec TFTP BIN return error amp ehandle amp ihandle amp boot data boot data SADDR char ptr boot data BOOTFILE uchar ptr DOWNLOAD ADDR uchar ptr RUN ADDR Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 239 Function Reference 7 1 120 RTCS_exec_TFTP_COFF Downloads and runs the COFF boot file Synopsis uint 32 RTCS exec TFTP COFF ip address Server char ptr filename Description The function downloads the COFF file from the TFTP Server decodes the file and runs it For information on the values of server and filename see Table 7 1 Parameters server in IP address of the TFTP Server from which to get the file filename in Name of the file to download Return Value Nothing RTCS OK on success Error code on failure See Also e RTCS create e RTCS exec TFTP BIN RTCS exec TFTP SREC BOOTP DATA STRUCT Freescale MQX RTCS User s Guide Rev 10 240 Freescale Semiconductor Functi
111. CS SOCKET ERROR error See Also e RTCS attachsock e RTCS detachsock e RTCS selectset Example Echo data on TCP port number seven int 32 servsock int 32 connsock int 32 status SOCKET ADDRESS STRUCT addrpeer uint 16 addrlen char buf 500 int_32 count uint_32 error Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 271 Function Reference create a stream socket and bind it to port 7 rror listen servsock 0 if error RTCS OK printf inlisten failed status d error return for connsock RTCS selectall 0 if connsock RTCS SOCKET ERROR printf AnRTCS selectall failed else if connsock servsock status accept servsock amp addrpeer amp addrlen if status RTCS SOCKET ERROR printf Anaccept failed else count recv connsock buf 500 0 if count lt 0 shutdown connsock FLAG CLOSE TX else send connsock buf count 0 Freescale MQX RTCS User s Guide Rev 10 272 Freescale Semiconductor Function Reference 7 1 143 RTCS_selectset Waits for activity on any socket in the set of sockets Synopsis uint 32 RTCS selectset pointer sockset uint 32 count uint 32 timeout Parameters sockset in Pointer to an array of sockets count in Number of sockets in the array timeout in One of the following Maximum number of mill
112. CS if bind family of functions Example RTCS gate add metric GATE ADDR INADDR ANY INADDR ANY 42 Freescale MQX RTCS User s Guide Rev 10 244 Freescale Semiconductor Function Reference 7 1 124 RTCS_gate_remove Removes a gateway from the routing table Synopsis uint 32 RTCS gate remove ip address gateway _ip address network ip address netmask Parameters gateway in IP address of the gateway network in IP network in which the gateway is located netmask in Network mask for network Description Function RTCS gate remove removes gateway gateway from the routing table Return Value e RTCS OK success Error code failure See Also e RTCS gate add Example Remove the default gateway error RTCS gate remove GATE ADDR INADDR ANY INADDR ANY Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 245 Function Reference 7 1 125 RTCS_gate_remove_metric Removes a specific gateway from the routing table Synopsis uint 32 RTCS gate remove metric ip address gateway ip address network ip address netmask uint 16 metric Parameters gateway in IP address of the gateway network in IP network in which the gateway is located netmask in Network mask for network metric in Gateway metric on a scale of 0 to 65535 Description Function RTCS gate remove metric removes a specific gateway from the routing table if it matc
113. CS_SO_IGMP_DROP_MEMBERSHIP Protocol level SOL_IGMP Values Default value Not in a group Change After the socket is created Socket type Datagram Comments IGMP must be in the RTCS protocol table To leave a multicast group uint 32 sock struct ip mreg group group imr multiaddr multicast ip address group imr interface local ip address error setsockopt sock SOL IGMP RTCS SO IGMP DROP MEMBERSHIP group sizeof group IGMP Get Membership Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 285 Function Reference Option name RTCS_SO_IGMP_GET_MEMBERSHIP Protocol level SOL_IGMP Values Default value Not in a group Change use with getsockopt only returns value in optval Socket type Datagram Comments Initial Retransmission Timeout Option name OPT RETRANSMISSION TIMEOUT Protocol level SOL TCP Values gt 15 ms see comments Default value 3000 three seconds Change Before bound Socket type Stream Comments Value is a first best guess of the round trip time for a stream socket packet RTCS attempts to resend the packet if it does not receive an acknowledgment in this time After a connection is established RTCS determines the retransmission timeout starting from this initial value If the initial retransmission timeout is not longer than the end to end
114. DCFG DYNAMIC TASKS configures the HTTP server for dynamic tasks mode The server creates new task for each new session and terminates the task when session is closed This method does dynamic memory allocation in runtime 5 9 2 Basic Usage An easy way to start the HTTP Server with default parameters is to call httpd server init for server initialization followed by httpd server run to create HTTP server task one or more tasks depending on settings server httpd server init HTTPD ROOT DIR STRUCT root dir Mlindex html httpd server run server There is also an option to run the server in poll mode HTTPDCFG POLL MODE 1 without creating a dedicated task After the server is initialized with httpd server init an application should call httpd server poll periodically in the background server httpd server init HTTPD ROOT DIR STRUCT root dir Mlindex html while 1 httpd_server poll server 1 5 9 3 Providing Static Content One of the key parameters to the HTTP server initialization is an array describing HTTP root directories Each directory in this array is a mapping between virtual web directory root directory and path to physical filesystem directory The following example shows mapping of two web root directories e The web root directory for example your server com to the root of the tfs filesystem e The usb subdirectory for example your server com usb to the root of c filesys
115. FG BUSY RTCSERR IPCFG DEVICE NUMBER RTCSERR IPCFG INIT RTCSERR IPCFG BIND See Also e ipcfg poll dhcp ipcfg unbind e ipcfg bind dhep wait Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 179 Function Reference Example uint 32 ipcfg bind dhcp wait uint_32 device boolean try auto ip IPCFG IP ADDRESS DATA PTR auto ip data 1 uint_32 result IPCFG OK do if result RTCSERR IPCFG BUSY time delay 200 result ipcfg bind dhcp device try auto ip while result RTCSERR IPCFG BUSY if result IPCFG OK return result do time delay 200 result ipcfg poll dhcp device try auto ip auto ip data while result RTCSERR IPCFG BUSY return result Freescale MQX RTCS User s Guide Rev 10 180 Freescale Semiconductor Function Reference 7 1 67 ipcfg bind dhcp wait Binds Ethernet device to network using DHCP protocol blocking mode Synopsis uint 32 ipcfg bind dhcp wait uint 32 device boolean try auto ip IPCFG IP ADDRESS DATA PTR auto ip data Parameters device in device identification try auto ip in try the auto ip automatic assign address 1f DHCP binding fails auto ip data in ip mask and gateway information used by auto IP binding may be NULL Description This function tries to bind the device to network using the DHCP protocol optionally followed by auto IP bind if DHCP fails It is blocking
116. Freescale MQX RTCS User s Guide Document Number MOXRTCSUG Rev 10 11 2012 YI Z freescale How to Reach Us Home Page www freescale com E mail support freescale com USA Europe or Locations Not Listed Freescale Semiconductor Technical Information Center CH370 1300 N Alma School Road Chandler Arizona 85224 1 800 521 6274 or 1 480 768 2130 support freescale com Europe Middle East and Africa Freescale Halbleiter Deutschland GmbH Technical Information Center Schatzbogen 7 81829 Muenchen Germany 44 1296 380 456 English 46 8 52200080 English 49 89 92103 559 German 33 1 69 35 48 48 French support freescale com Japan Freescale Semiconductor Japan Ltd Headquarters ARCO Tower 15F 1 8 1 Shimo Meguro Meguro ku Tokyo 153 0064 Japan 0120 191014 or 81 3 5437 9125 support japan Ofreescale com Asia Pacific Freescale Semiconductor China Ltd Exchange Building 23F No 118 Jianguo Road Chaoyang District Beijing 100022 China 86 10 5879 8000 support asia O freescale com Information in this document is provided solely to enable system and software implementers to use Freescale Semiconductor products There are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document Freescale Semiconductor reserves the right to make changes without further notice t
117. Freescale MQX RTOS the RTCS build projects takes its compile time configuration options from the central user configuration file user config h This file is located in board specific subdirectory in top level config folder The list of all configuration macros and their default values is defined in the source include rtcscfg h file This file is not intended to be modified by user Thanks to proper include search paths set in the RTCS build project the rtcscfg h file includes the user config h file from the board specific configuration directory and uses the configuration options suitable for the given board To do this Set the option value to Include the option 1 Exclude the option 0 Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 31 Setting Up the RTCS 2 16 1 Recommended Settings The settings that you choose for compile time configuration options depend on the requirements of your application Table 2 3 illustrates some common settings that you might want to use as you develop your application Table 2 3 Recommended Compile Time Settings Option Default Debug Speed Size RTCSCFG_CHECK_ADDRSIZE 1 1 0 0 RTCSCFG_CHECK_ERRORS 1 1 0 0 RTCSCFG_CHECK_MEMORY_ 1 1 1 1 ALLOCATION_ERRORS RTCSCFG_CHECK_VALIDITY 1 1 0 0 RTCSCFG IP DISABLE _ 0 0 0 0 DIRECTED BROADCAST RTCSCFG LINKOPT 8021Q PRIO 0 0 1 O 1 O 1 RTCSCFG LINKOPT 8023 0 O 1 O 1 O 1 RTCSCF
118. Freescale Semiconductor 141 Function Reference The FTP Server may be started or stopped from the shell by including the She _F TPd function in the shell command list Function FTP Command Description String FTPd_cd cwd xcwd Changes directory FTPd_cdup cdup Change to parent directory FTPd dele dele Deletes file FTPd help help Help returns list of supported commands FTPd list list Lists files FTPd mkdir mkd xmkd Makes directory FTPd nlst nlst Lists files FTPd noop noop No operation FTPd opts opts Sets options always returns bad option FTPd pass pass Specifies password FTPd pasv pasv Enters passive mode FTPd port port Specifies port FTPd pwd pwd xpwd Prints working directory FTPd quit quit Quits FTPd retr retr Retrieves file FTPd rmdir rmd xrmd Removes directory FTPd site site Gets site information FTPd size size Gets file size FTPd stor stor Stores file FTPd syst Syst System FTPd type type Sets type ascii or binary FTPd unimp abor acct Returns unimplemented command lemented FTPd user user Specifies user name FTPd feat feat request a descriptive list of server supported features FTPd rmd rmd remove a remote directory FTPd rnfr rnfr rename from FTPd rnto rnto rename to FTPd site site site specific commands FTPd size size return the size of a file Freescale MQX RTCS User
119. G LOG PCB 1 1 0 0 RTCSCFG LOG SOCKET API 1 1 0 0 2 16 2 Configuration Options and Default Settings The default values are defined in rtcs include rtcscfg h You may override the settings from the user config h user configuration file 2 16 2 1 RTCSCFG CHECK ADDRSIZE By default for functions that take a parameter that is a pointer to sockaddr RTCS determines whether the addrlen field is at least sizeof sockaddr bytes If addrlen is not at least this size RTCS does either of the following It returns an error when these functions are called bind connect sendto e It performs a partial copy operation when these functions are called accept getsockname getpeername recvfrom Freescale MQX RTCS User s Guide Rev 10 32 Freescale Semiconductor Setting Up the RTCS 2 16 2 2 RTCSCFG_CHECK_ERRORS By default RTCS API functions perform error checking on their parameters 2 16 2 3 RTCSCFG_CHECK MEMORY_ALLOCATION_ERROR By default RTCS API functions perform error checking when they allocate memory 2 16 2 4 RTCSCFG CHECK VALIDITY By default RTCS accesses its internal data structures it determines whether the VALID field in the structures is valid 2 16 2 5 RTCSCFG IP DISABLE DIRECTED BROADCAST By default RTCS receives and forwards directed broadcast datagrams Set this value to 1 one to reduce the risk of Smurf ICMP echo request DoS attacks 2 16 2
120. GRAM uint 32 ST RX SMALL PKT uint 32 ST RX BAD ACK uint 32 ST RX BAD DATA uint 32 ST RX LATE DATA uint 32 ST RX OPT MSS uint 32 ST RX OPT OTHER uint 32 ST RX DATA uint 32 ST RX DATA DUP uint 32 ST RX ACK uint 32 ST RX ACK DUP uint 32 ST RX RESET uint 32 ST RX PROBE uint 32 ST RX WINDOW uint 32 ST RX SYN EXPECTED uint 32 ST RX ACK EXPECTED uint 32 ST RX SYN NOT EXPECTED uint 32 ST RX MULTICASTS uint 32 ST TX DATA uint 32 ST TX DATA DUP uint 32 ST TX ACK uint 32 ST TX ACK DELAYED uint 32 ST TX RESET uint 32 ST TX PROBE uint 32 ST TX WINDOW uint 32 ST CONN ACTIVE uint 32 ST CONN PASSIVE uint 32 ST CONN OPEN uint 32 ST CONN CLOSED uint 32 ST CONN RESET uint 32 ST CONN FAILED Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 387 Data Types uint_32 ST CONN ABORTS TCP STATS _PTR TCP STATS PTR ST RX TOTAL Total number of received packets ST RX MISSED Incoming packets discarded due to lack of resources ST RX DISCARDED Incoming packets discarded for all other reasons ST RX ERRORS Internal errors detected while processing an incoming packet ST TX TOTAL Total number of transmitted packets ST TX MISSED Packets to be sent that were discarded due to lack of resources ST TX DISCARDED Packets to be sent that were discarded for all other reasons ST TX ERRORS Internal errors detected while trying to send a packet ERR RX RX error information ERR TX TX
121. Guide Rev 10 206 Freescale Semiconductor Function Reference 7 1 92 iwcfg set essid Synopsis uint 32 iwcfg set essid uint 32 dev num char ptr essid Parameters dev num in Device identification index essid in Pointer to ESSID Extended Service Set Identifier string Description This function sets to device identificated IP interface structure ESSID Device must be initialized before ESSID comes into effect only when user commits his changes The ESSID is used to identify cells which are part of the same virtual network Return Value e ENET OK success ENET ERROR ENETERR INVALID DEVICE Example fdefine SSID NGZG define DEFAULT DEVICE 1 int_32 error IP configuration error RTCS create ENET get mac address DEFAULT DEVICE ENET IPADDR enet address error ipcfg init device DEFAULT DEVICE enet address Set SSID iwcfg set essid DEFAULT DEVICE SSID iwcfg commit DEFAULT DEVICE end of IP configuration error ipcfg bind staticip DEFAULT DEVICE amp ip data Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 207 Function Reference 7 1 93 iwcfg get essid Synopsis uint 32 iwcfg get essid uint 32 dev num char ptr essid Parameters dev num in Device identification index essid out Extend
122. HCP Server See DHCPSRV init in Chapter 7 Function Reference 5 4 DNS Resolver DNS Resolver is an agent that retrieves information such as a host address or mail information based on a domain name by querying a DNS server DNS Resolver implements a client based on the DNS protocol see RFC 1035 5 4 1 Setting Up DNS Resolver To setup DNS resolver modify the following lines in source if dnshosts c char DNS Local network name char DNS Local server name ns arc com DNS SLIST STRUCT DNS First Local server uchar PTR DNS Local server name 0 INADDR LOOPBACK 0 0 0 0 DNS A DNS IN Note DNS SLIST STRUCT is defined in source include dns h For example for a local server with the name DnsServer on local network arc com with IP address 10 10 0 120 char DNS Local network name char DNS Local server name DnsServer arc com DNS SLIST STRUCT DNS First Local server uchar PTR DNS Local server name 0 0x0A0A0078 0 0 0 0 DNS A DNS IN on The following is also valid char DNS Local network name arc com char DNS Local server name DnsServer DNS SLIST STRUCT DNS First Local server uchar PTR DNS Local server name 0 0x0A0A0078 0 0 O O DNS A DNS IN Calling DNS init starts DNS services Table 5 3 Summary Setting Up DNS Resolver DNS SLIST STRUCT DNS server list struct
123. HDLC Freescale MQX RTCS User s Guide Rev 10 416 Freescale Semiconductor K KB Kilobyte L LAN Local Area Network Any technology that provides high speed transfer over a geographically limited area LANCE Local Area Network Controller for Ethernet An ethernet device from AMD Inc LCP Link Control Protocol The protocol that PPP uses to negotiate options over a link lease See finite lease library See API link noun A network of two hosts that use PPP to communicate See also configure a link Link Control Protocol See LCP link layer See data link layer little endian The endian format in which the most significant byte is the last byte in the word See also big endian byte swap host byte order network byte order local For a datagram or stream socket the endpoint or part of the endpoint such as the IP address or port number that is here It is the endpoint that is associated with the function that called socket See also remote For a PPP link it refers to the end of the link that is here It is the endpoint that is associated with the function that called PPP initialize See also peer Local Area Network See LAN logical address See address loopback address See address Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 417 MAC Medium Access Control The MAC mechanism is based on CSMA CD Media Access Controller See Ethernet
124. INDEX PAGE s 4ss nur Rr yr ems 163 7 1 55 HTTPD SET PAHAM FN TBlL 2 ERR m bee aa aa aa ae aa 164 LL998HTIPD SET PAHAM COL TEL 2c iz zara b RE anri roa ERRARE 165 Ar A ae te eee ee doll taia ener eee 166 AE AA A UE Y YR 2 167 71 59 inel BIO i irrita dee de a n d de fear at ic ut de a A RO A Ree eod 168 CAR A ie a at d O O RH etd pi d li d a d FN 170 AI arrene aeea Gs igi aoe hd eed ow ge win oie Bee eee de A k ud a 171 7 1 92 PP SIS se nec deraiat e Bla RR REOR ER Redi ied far Re Edid icd inito Ao 172 7 1 63 ipcfg NN device S od oed uei bes de A bit aede Ed 173 7 14 64 ipcfg_ init WEN ACC as dexesRbrehieotesaderkeeeitieeni AEREA 175 Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 7 7 14991DOIO DING DOG cc ca e cae asa as na e ae d dur Rud dr ones e la a es 177 Z 166 ipio bind ONCE ni emiri ia c YO biata a bi aa teii er 179 7 107 ipcfg bind dhcp Wait seen aceea mata aere ae rat e aie ae a ad 181 Arcs Bd Se IONUL sos setenari Re dee OR Oe dia LR dl Rr eee 183 7 1 69 ipcfg get device number GG GG GG ua 184 1370 Weld add MHONKJdOB 2c ci aia e e cndevededceseducev de drid de 185 Zip E OSU AAA oben n ide ae OU ES 186 lA Oet IMC MPs 187 7 17510030 get Sale sn a ni ar ick be o d i rii nd RC d n b rbie at babe ee i 188 7 1 74 ipcfg_get_state_string Y e rr eed xdi Sr 189 7 1 75 Cig get desired stalel a ei O RG RED GU tt ea ate a n ala aia a 19
125. K success Error code failure See Also Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 261 Function Reference RTCS if add RTCS if bind RTCS if bind BOOTP RTCS if bind DHCP flagged RTCS if bind DHCP timed RTCS if bind IPCP DHCP DATA STRUCT Example enet handl handle rtcs if handle ihandle uint 32 error uint 32 optlen 100 Make large enough for the number of your DHCP options uchar option array 100 uchar _PTR_ optptr DHCP DATA STRUCT params uchar parm options 3 DHCPOPT SERVERNAME DHCPOPT FILENAME DHCPOPT FINGER SRV in_addr rebind address rebind mask rebind server uint_32 lease 28800 8 Hours in seconds error ENET initialize 0 enet local 0 amp ehandle if error printf AnFailed to initialize Ethernet driver s ENET strerror error return error RTCS create if error RTCS OK printf nFailed to create RTCS error x error return error RTCS if add ehandle RTCS IF ENET amp ihandle if error printf AnFailed to add the interface error x error return You supply the following functions if any is NULL DHCP Client follows its default behavior params CHOICE FUNC DHCPCLNT test choice func params BIND FUNC DHCPCLNT test bind func params UNBIND FUNC DHCPCLNT test unbind func optptr option array Fill in the requested op
126. K DELAYED Delayed ACKs sent ST TX RESET RST segments sent ST TX PROBE Window probes sent ST TX WINDOW Window updates sent ST CONN ACTIVE Active open operations ST CONN PASSIVE Passive open operations ST CONN OPEN Established connections ST CONN CLOSED Graceful shutdown operations Freescale MQX RTCS User s Guide Rev 10 390 Freescale Semiconductor A Data Types ST_CONN_RESET Ungraceful shutdown operations ST CONN FAILED Failed open operations ST CONN ABORTS Abort operations Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 391 Data Types 8 3 38 UDP_STATS A pointer to this structure is returned by UDP_stats typedef struct uint 32 ST RX TOTAL uint 32 ST RX MISSED uint 32 ST RX DISCARDED uint 32 ST RX ERRORS uint 32 ST Te TOTAL uint 32 ST TX MISSED uint 32 ST TX DISCARDED uint 32 ST TX ERRORS RTCS ERROR STRUCT ERR RX RTCS ERROR STRUCT ERR TX uint 32 ST RX BAD PORT uint 32 ST RX BAD CHECKSUM uint 32 ST RX SMALL DGRAM uint 32 ST RX SMALL PKT uint 32 ST RX NO PORT UDP STATS PTR UDP STATS PTR ST RX TOTAL Total number of received packets ST RX MISSED Incoming packets discarded due to lack of resources ST RX DISCARDED Incoming packets discarded for all other reasons ST RX ERRORS Internal errors detected while processing an incoming packet ST TX TOTAL
127. MP stats takes no parameters and returns a pointer to the IGMP statistics that RTCS collects Return Value Pointer to the GMP STATS structure See Also ARP stats e ENET get stats CMP stats e jnet pton e IPIF_stats e TCP stats e UDP stats e IGMP STATS Example See ARP stats Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 167 Function Reference 7 1 59 inet pton This function converts the character string src into a network address structure Synopsis uint 32 inet pton int 32 af const char SrC void dst unsigned int sizeof dst Parameters af in Family name src in Pointer to prn form of address dst out Pointer to bin form of address sizeof dst in Size of dst buffer Description This function converts the character string src into a network address structure in the af address family then copies the network address structure to dst The af argument must be either AF INET or AF INET6 The following address families are currently supported AF INET src points to a character string containing an IPv4 network address in dotted decimal format ddd ddd ddd ddd where ddd is a decimal number of up to three digits in the range 0 to 255 The address is converted to a struct in addr and copied to dst which must be sizeof struct in addr 4 bytes 32 bits long AF INET6 src points to a character string containing an IPv6 ne
128. N I 364 9022 nal POMS 2 01 cd cede eee Seda dt Led Sd ERARRRER REALE RARA 366 DINA SUR sacarina Soc SG a ad 367 EOS Oat eae rr Y Y 0O O hh LYW ee ae hee bese eens 368 8 3 25 PPPOE CLIENT INIT DATA STRUCT eee 369 5 5 co PPPOE SERVER INIT DATA STRUCT 4 5a ua aa sua cate GOR da ad 371 8 3 27 PPPOE SESSION STAIS STRUGT laa ua acea vg a RET awd 373 8 9 28 PPPOEIF STATS STRUGT iia daga e taie da rd Ron mna AUD 374 9 929 PPP SECRET mmm tarie bas dd doti Ecke d nai dora a ae dri di Ei ul d nd dece d daa 378 So ATO ERROR STRUCT e ipac see e bee XR at at a a 379 8 391 a Le STRUCT siii rado 380 8 3 22 PIUS protocol 16016 2s ara atare ae ese mme e nt r ra 382 8 339 RICS TASK aceia oala ae ER 383 8 3 34 RTCOSMIB VALUE i GR RA RR tite WR DWR Ak in A WA Rd 384 8 3 95 S0CKaddr A A ARN Y YR se a doped 385 6 39 30 SUD oos O n Ie Gnd ten AU A 386 A ie aia Y ul 6c 8 n d ot d cee ee ut Pd RR PAD SEE dard 387 OOO UDP STATS ue ae mada iu ree iila d Rd Ede Sr doa dos 2 aida 392 fe AAA AA 401 A m 402 T R ee oia aterra 402 A O a la dt ati HN a E 402 Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 11 Freescale MQX RTCS User s Guide Rev 10 12 Freescale Semiconductor Revision History To provide the most up to date information the revision of our documents on the World Wide Web will be the most current Your printed copy may be an earlier revision To ver
129. OWAIT datagram socket option makes it behave as if it was TRUE Group 2 RTCS MSG CHKSUM overrides the OPT CHECKSUM BYPASS checksum bypass option makes it behave as if it was FALSE RTCS MSG NOCHKSUM overrides the OPT CHECKSUM BYPASS checksum bypass option makes it behave as though it is TRUE Group 3 RTCS MSG NOLOOP does not send the datagram to the loopback interface Zero ignore Return Value Number of bytes sent success RTCS ERROR failure Ifthe function retums RTCS ERROR the application can call RTCS geterror to determine the cause of the error See Also accept bind getsockopt listen recv RTCS_geterror setsockopt shutdown socket Example Stream Socket uint 32 handle char buffer 20000 uint 32 count count send handle buffer 20000 0 if count RTCS ERROR printf AnError send failed with error code 1x Freescale MQX RTCS User s Guide Rev 10 278 Freescale Semiconductor Function Reference RTCS geterror handle Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 279 Function Reference 7 1 147 sendto Sends data on the datagram socket Synopsis int 32 sendto uint 32 socket char _PTR_ buffer uint 32 buflen uint 16 flags sockaddr _PTR_ destaddr uint 16 addrlen Parameters socket in Handle for the socket on which to send data buffer in Pointer to th
130. Open passive Stopped Figure A 14 PPP State Diagram In the Closed state PPP does not accept requests from the peer to open the link nor does it allow the host to send packets to the peer In the Stopped state PPP accepts requests from the peer to open the link but still does not allow the host to send packets to the peer For the link to be opened the link configuration must be negotiated first If the negotiation is successful the link is in the Open state and available for an application to use If the negotiation is not successful the link is in the Stopped state Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 401 Protocols and Policies 8 5 SNTP Simple Network Time Protocol RFC 2030 operates over UDP at the IP layer for IPv4 to synchronize computer clocks on the Internet RTCS clients can operate in unicast point to point or anycast multi point to point mode A 8 7 Unicast Mode The client sends a request to a time server at its unicast address then waits for a reply The reply must contain the time round trip delay and local clock offset relative to the server A 8 8 Anycast Mode The client sends a request to a local broadcast or multicast group address One or more servers might reply with a unicast address The client binds to the first received reply 8 6 IPsec IPsec IP security defines a set of protocols and cryptographic algorithms for creating secure IP traffic ses
131. P agent same definition file No leaf object node No user code required The generated RTCSMIB_NODE structure only contains pointers to other node structures Leaf object node variable object The instance of RTCSMIB_VALUE structure named as MIBVALUE objectname Table object A function to map table indices to instances The function name should be MIB find objectnamey Writable variable object A function to perform a set operation The function name should be MIB set objectnamey Variable Objects In the verbatim code section the user should provide implementation of RTCSMIB VALUE structures for all readable variable leaf objects The structure is defined as typedef struct rtcsmib value uint_32 TYPE pointer PARAM RTCSMIB VALUE PTR RTCSMIB VALUE PTR In this structure the user specifies the type and method used to retrieve the object value in the application There are actually two types of information attached to each MIB object Oneis based directly on the MIB standard type and is attached to the RTCSMIB NODE structure The TYPE information attached to RTCSMIB_VALUE structure This type value is used in conjuction with PARAM member See the table below for more details Freescale MQX RTCS User s Guide Rev 10 84 Freescale Semiconductor RTCS Applications MIB Object type INTEGER whose value SNMP agent computes when SNMP manager perfor
132. PPP ID PTR Pointer to an array that represents a remote entity s ID such as a host name or user ID PPP PW PTR Pointer to an array that represents the password that is associated with the remote entity s ID Freescale MQX RTCS User s Guide Rev 10 378 Freescale Semiconductor Data Types 8 3 30 RTCS ERROR_STRUCT Statistics for protocol errors the structure that is included as fields ERR_TX and ERR_RX in the following statistics structures ARP STATS ICMP STATS IGMP STATS IP STATS IPIF STATS TCP STATS UDP STATS typedef En uint 32 ERROR uint_32 PARM task id TASK ID uint 32 TASKCODE pointer EMPTR boolean STACK RTCS ERROR STRUCT PTR RTCS ERROR STRUCT PTR ERROR Code that describes the protocol error PARM Parameters that are associated with the protocol error TASK ID Task ID of the task that set the code TASKCODE Task error code of the task that set the code MEMPTR Highest core memory address that MQX has allocated STACK Whether the stack for the task that set the code is past its limit Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 379 Data Types 8 8 31 RTCS IF STRUCT Callback functions for a device interface A pointer to this structure is a parameter to RTCS if add To use the default table for an interface use the constant that is defined in the following tabl
133. PSRV DATA STRUCT Example See DHCPSRV init Freescale MQX RTCS User s Guide Rev 10 130 Freescale Semiconductor Function Reference 7 1 29 DHCPSRV_set_config_flag_off Disables address probing Synopsis uint 32 DHCPSRV set config flag off uint 32 flag Parameters flag in DHCP server address probing flag Description By default the RTCS DHCP server probes the network for a requested IP address before issuing the address to a client If the server receives a response it sends a NAK reply and waits for the client to request a new address You can disable probing to reduce overhead in time and traffic To do so pass the DHCPSVR FLAG DO PROBE flag to DHCPSRV set config flag off This function may be called any time after DHCPSRV init Return Value e RTCS OK success Error code failure See Also DHCPSRV set config flag on e DHCPSRV minit Example define DHCP DO PROBING 1 int dhcp do probing DHCP DO PROBING init setup if dhcp do probing DHCPSRV set config flag on DHCPSVR FLAG DO PROBE else DHCPSRV set config flag off DHCPSVR FLAG DO PROBE Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 131 Function Reference 7 1 30 DHCPSRV_set_config_flag_on Re enables address probing Synopsis uint 32 DHCPSRV set config flag on uint 32 flag Parameters flag in DHCP server address p
134. Protocol requires UDP Default RTCS Protocol Table You can either define your own protocol table or use the following default table which RTCS provides in if rtcsinit c uint 32 CODE PTR_ RTCS protocol table void RTCSPROT IGMP RTCSPROT UDP RTCSPROT TCP RTCSPROT IPIP NULL Freescale MQX RTCS User s Guide Rev 10 382 Freescale Semiconductor Data Types 8 3 33 RTCS TASK Definition for Telnet Server shell task typedef struct char ptr NAME uint 32 PRIORITY uint 32 STACKSIZE void CODE PTR START pointer pointer ARG RTCS TASK PTR RTCS TASK PTR NAME Name of the task PRIORITY Task priority STACKSIZE Stack size for the task START Task entry point ARG Parameter for the task Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 383 Data Types 8 3 34 RTCSMIB VALUE typedef struct rtcsmib value uint_32 TYPE pointer PARAM RTCSMIB VALUE _PTR_ RTCSMIB VALUE PTR TYPE Value type PARAM Freescale MQX RTCS User s Guide Rev 10 384 Freescale Semiconductor Data Types 8 3 35 sockaddr_in Structure for a socket endpoint identifier typedef struct sockaddr in uint_16 sin family uint_16 sin port in_addr sin addr sockaddr in sin family Address family type sin port Port number sin addr IP address Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 38
135. QX RTCS User s Guide Rev 10 374 Freescale Semiconductor Incoming packets discarded due to lack of resources ST RX DISCARDED Incoming packets discarded for all other reasons ST RX ERRORS Internal errors detected while processing an incoming packet ST TX TOTAL Total number of transmitted packets ST TX MISSED Packets to be sent that were discarded due to lack of resources ST TX DISCARDED Packets to be sent that were discarded for all other reasons ST TX ERRORS Internal errors detected while trying to send a packet ST RX OCTETS Total bytes received ST RX UNICAST Unicast packets received ST RX BROADCAST Broadcast packets received ST RX MULTICAST Multicast packets received ST TX UNICAST Unicast packets sent ST TX BROADCAST Broadcast packets sent ST TX PADITRANSMITTED Number of transmitted PADI packets ST TX PADOTRANSMITTED Number of transmitted PADO packets ST TX PADRTRANSMITTED Freescale MQX RTCS User s Guide Rev 10 Data Types Freescale Semiconductor 375 Data Types Number of transmitted PADR packets ST_TX_PADSTRANSMITTED Number of transmitted PADS packets ST_TX_PADTTRANSMITTED Number of transmitted PADT packets ST TX GENERIC ERRORS TRANSMITTED Number of generic error packets transmitted ST RX PADIREJECTED Number of PADI packets rejected ST RX PADRREJECTED Number of PADR rejected ST RX PADSRECEIVED Number of received PADS packets ST RX PADORECEIVED
136. QX RTCS User s Guide Rev 10 Function Reference Freescale Semiconductor 237 Function Reference 7 1 119 RTCS_exec_TFTP_BIN Download and run the binary boot file Synopsis uint 32 RTCS exec TFTP BIN ip address Server char ptr uchar ptr uchar ptr Parameters server in IP address of the TFTP Server from which to get the file filename in Name of the file to download download address in Address to which to download the file run address in Address at which to start to run the file Description filename download address run address This function downloads the binary file from the TFTP Server and runs the file This function does not return if it succeeds You can usually find the server and filename in the structure fields shown in Table 7 1 Table 7 1 Boot File Server and File Names Operation Function Fields Structure BootP RTCS if bind e SADDR BOOTP DATA STRUCT BOOTP BOOTFILE DHCP RTCS_if_bind_ e SADDR DHCPSRV_DATA_STRUCT DHCP FILE Return Value RTCS_OK success Error code failure See Also RTCS create RTCS exec TFTP COFF RTCS exec TFTP SREC RTCS load TFTP BIN BOOTP DATA STRUCT Freescale MQX RTCS User s Guide Rev 10 238 Freescale Semiconductor Example Function Reference Initialize RTCS using BootP download the binary boot file and run it uint 32 boot function void BOOTP D
137. RORS ST RX BAD VERSION Datagrams with the version not equal to four ST RX BAD CHECKSUM Datagrams with an invalid checksum ST RX BAD SOURCE Datagrams with an invalid source address ST RX SMALL HDR Datagrams with a header too small ST RX SMALL DGRAM Freescale MQX RTCS User s Guide Rev 10 358 Freescale Semiconductor Datagrams smaller than the header ST RX SMALL PKT Datagrams larger than the frame ST RX TTL EXCEEDED Datagrams to route with TTL 0 ST RX FRAG RECVD Received IP fragments ST RX FRAG REASMD Reassembled datagrams ST RX FRAG DISCARDED Discarded fragments ST TX FRAG SENT Sent fragments ST TX FRAG FRAGD Fragmented datagrams ST TX FRAG DISCARDED Fragmentation failures Freescale MQX RTCS User s Guide Rev 10 Data Types Freescale Semiconductor 359 Pi Data Types 8 3 19 IPCFG IP ADDRESS DATA Interface address structure typedef uint 32 ip address typedef struct ipcfg ip address data 1 ip addressip ip address mask ip address router IPCFG IP ADDRESS DATA PTR IPCFG IP ADDRESS DATA PTR ip ip address mask mask route gateway Freescale MQX RTCS User s Guide Rev 10 360 Freescale Semiconductor 8 8 20 IPCP DATA STRUCT A pointer to this structure is a parameter of RTCS if bind IPCP typedef
138. RSECRETS Initial timeout in milliseconds for PPP Drivers restart timer when the timer becomes active The driver doubles the timeout every time the timer expires until the timeout reaches PPP MAX XMIT TIMEOUT Maximum timeout in milliseconds for PPP Driver s restart timer 3000 10000 PPP MIN XMIT TIMEOUT PPP MAX XMIT TIMEOUT Minimal ACCM that LCP accepts for both link directions when PPP Driver configures a link for information about ACCM see Section 4 2 1 1 ACCM OxFFFF FFFF PPP ACCM Number of times while it negotiates link configuration that LCP sends configure request packets before abandoning 10 PPP MAX CONF RETRIES Number of times while PPP Driver is closing a link and before it enters the Closed or Stopped state that it sends terminate request packets without receiving a corresponding terminate ACK packet PPP MAX TERM RETRIES Number of times while PPP Driver is negotiating link configuration that itsends consecutive configure NAK packets before it assumes that the negotiation is not converging at which time it starts to send configure reject packets instead PPP MAX CONF NAKS Priority of PPP Driver tasks Since you must assign priorities to all the tasks that you write RTCS lets you change the priority of PPP Driver tasks so that it fits with your design PPPTASK priority Freescale MQX RTCS Us
139. RTCS if bind DHCPY Gets an IP address using DHCP and binds it to the device interface DHCPCLNT find option Searches a DHCP message for a specific option type 5 2 1 Example Setting Up and Using DHCP Client See RTCS if bind DHCP in Chapter 7 Function Reference 5 3 DHCP Server DHCP server allocates network addresses and delivers initialization parameters to client hosts that request them For more information see RFC 2131 Freescale MQX DHCP Server is based on RFC 2131 By default the RTCS DHCP server probes the network for a requested IP address before issuing the address to a client If the server receives a response it sends a NAK reply and waits for the client to request a new address To disable probing pass the DHCPSVR FLAG DO PROBE flag to DHCPSRV set config flag off Table 5 2 Summary Using DHCP Server Add the following to the option list that DHCPSRV_ippool_add uses DHCP option addr IP address DHCP option addrlist List of IP addresses DHCP option int8 8 bit value DHCP option int16 16 bit value DHCP option int32 32 bit value DHCP option string String DHCP option variable Variable length option DHCPSRV init Creates DHCP server DHCPSRV ippool add Assigns a block of IP addresses to DHCP server Freescale MQX RTCS User s Guide Rev 10 72 Freescale Semiconductor RTCS Applications 5 3 1 Example Setting Up and Modifying D
140. RTCSCFG ENABLE GATEWAYS Default value RTCSCFG FEATURE DEFAULT Set to 1 to add support for gateways 2 16 2 27 RTCSCFG ENABLE VIRTUAL ROUTES Default value RTCSCFG FEATURE DEFAULT Must be 1 for PPP or tunneling 2 16 2 28 RTCSCFG USE KISS RNG Default 0 Must be 1 for PPP or tunneling 2 16 2 29 RTCSCFG ENABLE ARP STATS Default value RTCSCFG FEATURE DEFAULT Set to 1 to enable ARP packet statistics 2 16 2 30 RTCSCFG PCBS INIT PCB Packet Control Block initial allocated count Override in application by setting the RTCSPCB init global variable 2 16 2 31 RTCSCFG PCBS GROW PCB Packet Control Block allocation grow granularity Override in application by setting the RTCSPCB grow global variable 2 16 2 32 RTCSCFG PCBS MAX PCB Packet Control Block maximum allocated count Override in application by setting the _RTCSPCB_max global variable 2 16 2 33 RTCSCFG MSGPOOL INIT RTCS message pool initial size Override in application by setting the RTCS msgpool init variable 2 16 2 34 RTCSCFG MSGPOOL GROW RTCS message pool growing granularity Override in application by setting the RTCS msgpool grow variable Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 35 Setting Up the RTCS 2 16 2 35 RTCSCFG MSGPOOL MAX RTCS message pool maximal size Override in application by setting the RTCS msgpool max variable 2 16 2 36 RTCSCFG SOCKET PART INIT RTCS socket pre allocated count Override in application
141. RVER TASK STACK Extra stack space for the PPPoE Server task ECHO TIMEOUT Maximum time to wait before retransmitting an echo packet If you set the field to zero pppoe server init sets it to the default value 10 000 which is ten seconds ECHO MAX RETRY Number of echo requests to make before closing the client connection If you set the field to zero pppoe server init sets it to the default value six SESSION UP Callback function to call after a session is established with the client SESSION DOWN Callback function to call after a session is terminated PARAM Parameter to the SESSION UP or SESSION DOWN callback function Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 371 Data Types SEND PADO TAGS EXTRA Callback function that can parse extra tags such as vendor specific tags with PADO packets If you set the field to NULL it is ignored SEND_PADS_TAGS EXTRA Callback function that can parse extra tags with PADS packets If you set the field to NULL it is ignored SEND PADI TAGS EXTRA Callback function that can send extra tags for example vendor specific tags with PADI packets The parameter should be returned to the driver If you set the field to NULL it is ignored SEND PADR TAGS EXTRA Callback function that can send extra tags with PADR packets The parameter should be returned to the driver If you set the field to NULL it is ignored Freescale MQX RTCS User s Gu
142. S User s Guide Rev 10 194 Freescale Semiconductor at Function Reference 7 1 80 ipcfg get ip Returns an immediate IP address information bound to Ethernet device Synopsis boolean ipcfg get ip uint 32 device IPCFG IP ADDRESS DATA PTR data Parameters device in device identification data in pointer to IP address information IP address mask and gateway Description This function returns the immediate IP address information bound to given Ethernet device Return Value TRUE if successful and data structure filled FALSE in case of error See Also e ipcfg get dns ip Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 195 AN Function Reference 7 1 81 ipcfg get tftp serveraddress Returns TFTP server address if any Synopsis _ip address ipcfg get tftp serveraddress uint 32 device Parameters device in device identification Description This function returns the last TFTP server address 1f such was assigned by the last BOOTP bind process Return Value The TFTP server IP address See Also e ipcfg get tftp servername e ipcfg get boot filename Freescale MQX RTCS User s Guide Rev 10 196 Freescale Semiconductor Function Reference 7 1 82 ipcfg get tftp servername Returns TFTP servername if any Synopsis uchar ptr ipcfg get tftp serveraddress uint 32 device Parameters device in device identification Description This function
143. S 11 23 S secret structure PPP_SECRET 251 segment lifetime max 197 199 send buffer size socket option 196 send Ethernet 802 10 priority tags socket option 194 send Ethernet 802 3 frames socket option 194 send nowait socket option 29 182 194 195 send push socket option 182 195 send timeout socket option 195 server information DHCP 175 SML 7 Smurf DoS attacks reducing risk of 21 SNMP Agent 56 starting 201 snmpcfg h 56 NMPCFG_BUFFER_SIZE 56 NMPCFG_COMMUNITY 56 NMPCFG_SYSDESCR 56 MPCFG_SYSSERVICES 56 MPvI 8 community string 56 MPvl MIB 8 MPv2 8 MPv2 MIB 8 MPv2c 56 community string 56 SNMPv3 8 SNTP 272 SNTP Client services 57 starting 202 starting time 204 SOCK DGRAM 205 SOCK STREAM 205 sockaddr in structure 257 socket error socket option 196 socket name stream sockets getting 122 socket options getting 124 round trip time for stream sockets 190 setting 27 186 for datagram sockets 27 for stream sockets 28 socket type socket option 196 socket send timeout 195 sockets aborting stream sockets 31 activity waiting on any in a set 178 waiting on any owned by task 176 ANnRNNHNH ZZ 2222 Freescale MQX RTCS User s Guide Rev 10 432 Freescale Semiconductor binding 27 84 comparison of datagram and stream 24 connections establishing for stream sockets 29 accept 80 connect 86 listen 129 creating 27 205 definition 23 e
144. Set to 1 to add support for ICMP protocol 2 16 2 14 RTCSCFG ENABLE IGMP Default value RTCSCFG FEATURE DEFAULT Set to 1 to add support for IGMP protocol 2 16 2 15 RTCSCFG ENABLE NAT Default 0 Set to 1 for add support for NAT functionality 2 16 2 16 RTCSCFG ENABLE DNS Default value RTCSCFG FEATURE DEFAULT Set to 1 to add support for DNS 2 16 2 17 RTCSCFG ENABLE LWDNS Default 0 Set to 1 for add implement light weight DNS functionality only 2 16 2 18 RTCSCFG ENABLE IPIP Default value RTCSCFG FEATURE DEFAULT Set to 1 to to add support for IPIP 2 16 2 19 RTCSCFG ENABLE RIP Default value RTCSCFG FEATURE DEFAULT Set to 1 to add support for RIP 2 16 2 20 RTCSCFG ENABLE SNMP Default value RTCSCFG FEATURE DEFAULT Set to 1 to add support for SNMP 2 16 2 21 RTCSCFG ENABLE IP REASSEMBLY Default value RTCSCFG FEATURE DEFAULT add support for IP packet reassembling 2 16 2 22 RTCSCFG ENABLE LOOPBACK Default value RTCSCFG FEATURE DEFAULT Set to 1 to enable loopback interface 2 16 2 23 RTCSCFG ENABLE UDP Default value RTCSCFG FEATURE DEFAULT Set to 1 to add support for UDP protocol Freescale MQX RTCS User s Guide Rev 10 34 Freescale Semiconductor Setting Up the RTCS 2 16 2 24 RTCSCFG ENABLE TCP Default value RTCSCFG FEATURE DEFAULT Set to 1 to add support for TCP protocol 2 16 2 25 RTCSCFG ENABLE STATS Default value RTCSCFG FEATURE DEFAULT Set to 1 to add support for network trafic statistics 2 16 2 26
145. Setting up the RTCS Chapter 2 Setting Up the RTCS Using RTCS and sockets Chapter 3 Using Sockets 5 2 DHCP Client The Dynamic Host Configuration Protocol DHCP is a binding protocol as described in RFC 2131 Freescale MQX DHCP Client is based on RFC 2131 The protocol allows a DHPC client to acquire TCP IP configuration information from a DHCP server even before having an IP address and mask DHCP client must be used with RTCS it cannot be ported to a different internet stack By default the RTCS DHCP client probes the network with an ARP request for the offered IP address when it receives an offer from a server in response to its discoverer If a host on the network answers the ARP the client does not accept the server s offer instead it sends a decline to the server s offer and sends out a new discover You can disable probing by being sure not to set DHCP SEND PROBE among the flags defined in dhcp h when calling RTCS if bind DHCP flagged Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 71 RTCS Applications Table 5 1 Summary Setting Up DHCP Client Add the following to the option list that RTCS_if_bind_DHCP uses DHCP option addr IP address DHCP option addrlist List of IP addresses DHCP option int8 8 bit value DHCP option int16 16 bit value DHCP option int32 32 bit value DHCP option string String DHCP option variable Variable length option
146. TCS User s Guide Rev 10 426 Freescale Semiconductor Index Symbols _lopcb_handle 217 _lopcb table 217 _IP forward 11 PPP ACCM 38 _PPP CHAP LNAME 37 PPP CHAP LSECRETS 37 PPP CHAP RSECRETS 37 PPP MAX CONF NAKS 38 PPP MAX CONF RETRIES 38 PPP MAX TERM RETRIES 38 PPP MAX XMIT TIMEOUT 37 PPP MIN XMIT TIMEOUT 37 PPP PAP LSECRET 37 PPP PAP RSECRETS 37 _PPPTASK priority 38 _PPPTASK stacksize 37 RTCSPCB max 11 _RTCSTASK priority 11 RTCSTASK stacksize 11 _TCP bypass rx 11 _TCP bypass tx 11 A ACCM 35 36 minimal 37 ACFC 36 address family internet 84 117 118 226 address field structure in addr 231 address probing DHCP 52 101 102 AF INET 84 117 118 226 AP 36 ARC NAT ALGs disabling 15 enabling 11 132 enabling and starting 14 inactivity timeout socket option 190 inactivity timeout structure nat timeouts 242 inactivity timeouts changing 15 limitations 16 port numbers socket option 191 port ranges specifying 15 port numbers structure nat ports 240 protocols supported 16 starting 132 statistics 16 133 statistics NAT STATS 241 stopping 131 timeouts changing 15 ARP 6 265 statistics getting 82 structure 219 ARP STATS structure 219 Assigned Numbers protocol 6 270 authentication protocols 37 changing 38 B BIN boot files loading 171 loading and running 14 144 binding IP addresses to device inter
147. UND fe80 200 Seff fefe 303 state PREFERRED type AU TOCONFIGURABLE 0 0 0 0 DNS1 169 254 0 1 Link status task stopped shell ipconfig d Bind via dhcp SUC shell ipconfig Eth 0 Link on AC 00 00 50 f0 03 03 GATE DNS1 15 Link sta shell gt REFERRED type AUTOCONFIGURABLE e PREFERRED type AUTOCONFIGURABLE Freescale MQX RTCS User s Guide Rev 10 406 Freescale Semiconductor Glossary A AC Access concentrator in PPP over Ethernet In the Discovery stage a host the client discovers an access concentrator the server Based on the network topology there might be more than one access concentrator with which the host can communicate The Discovery stage allows the host to discover all access concentrators and then select one When Discovery completes successfully both the host and the selected access concentrator have the information they will use to build their point to point connection over ethernet ACCM Asynchronous control character map One of the LCP configuration options for PPP Driver that you can modify It is a set of control characters that have special meaning when they are sent over a PPP link and must therefore be escaped when they are sent in a frame active task The task that is currently running on the processor that is the highest priority ready task address When it is used alone address refers to an IP address or a hardware address All statio
148. User s Guide Rev 10 Freescale Semiconductor 335 Data Types 8 3 4 DHCP_DATA_STRUCT A pointer to this structure in a parameter to RTCS if bind DHCP typedef struct int 32 CODE PTR CHOICE FUNC uchar PTR_ uint 32 void CODE PTR BIND FUNC uchar PTR_ uint 32 rtcs if handle boolean CODE PTR UNBIND FUNC rtcs if handle DHCP DATA STRUCT PTR DHCP DATA STRUCT PTR CHOICE FUNC Called every time a server receives a DHCP OFFER If CHOICE FUNC is NULL RTCS attempts to bind with the first offer it receives First parameter pointer to the OFFER packet Second parameter length of the OFFER packet Returns 1 to reject the packet Returns zero to accept the packet BIND FUNC Called every time DHCP gets a lease If BIND FUNC is NULL RTCS does not modify the behavior of the DHCP Client the function is for notification purposes only First parameter pointer to the ACK packet Second parameter length of the packet e Third parameter handle passed to RTCS if bind DHCP UNBIND FUNC Called when a lease expires and was not renewed If UNBIND FUNC is NULL RTCS terminates DHCP e Parameter handle passed to RTCS if bind DHCP Returns TRUE to attempt to get a new lease Returns FALSE to leave the interface unbound Freescale MQX RTCS User s Guide Rev 10 336 Freescale Semiconductor Data Types 8 3 5 DHCPSRV_DATA_STRUCT A pointer
149. User s Guide Rev 10 Freescale Semiconductor 213 Function Reference 7 1 99 iwcfg set passphrase Synopsis uint 32 iwcfg set passphrase uint 32 dev num char ptr passphrase Parameters dev num in Device identification index passphrase in SSID passpharse Description Set wpa passphrase Return Value e ENET OK success ENETERR INVALID DEVICE Example define DEMOCFG SECURITY wpa define DEMOCFG SSID NGZG define DEMOCFG NW MODE managed define DEMOCFG PASSPHRASE abcdefgh define DEFAULT DEVICE 1 error RTCS create ip data ip ENET IPADDR ip data mask ENET IPMASK ip data gateway ENET IPGATEWAY ENET get mac address DEFAULT DEVICE ENET IPADDR enet address DEFAULT DEVICE enet address iwcfg set essid DEFAULT DEVICE DEMOCFG SSID iwcfg set passphrase DEFAULT DEVICE DEMOCFG PASSPHRASE iwcfg set sec type DEFAULT DEVICE DEMOCFG SECURITY iwcfg set mode DEFAULT DEVICE DEMOCFG NW MODE error ipcfg bind staticip DEFAULT DEVICE amp ip data Freescale MQX RTCS User s Guide Rev 10 rror ipcfg init device 214 Freescale Semiconductor 7 1 100 iwcfg get passphrase Synopsis uint 32 iwcfg get passphrase uint 32 dev num cha
150. Value e PPPOE OK success Error code failure See Also e pppoe server init Freescale MQX RTCS User s Guide Rev 10 104 Freescale Semiconductor A A Function Reference 7 1 8 pppoe server if add Adds an ethernet interface to the PPPoE Server Synopsis uint 32 pppoe server if add pppoe srv handle pppoe handle enet handle enet handle Parameters pppoe handle in PPPoE Server handle enet handle in Ethernet port handle Description Function pppoe server if add adds an ethernet interface to the PPPoE Server and opens discovery and session protocols for the Ethernet port Return Value PPPOE OK success Error code failure See Also pppoe server if remove Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 105 Function Reference 7 1 9 _pppoe_server_if_remove Removes the ethernet interface to the PPPoE Server Synopsis uint 32 pppoe server if remove _pppoe srv handle pppoe handle enet handle enet handle Parameters pppoe handle in PPPoE Server handle enet handle in Ethernet interface handle Description Function pppoe server if remove removes the ethernet interface to the PPPoE Server and closes discovery and session protocols for the ethernet port The ethernet interface must be previously registered by a call to pppoe server if add Return Value e PPPOE OK success Error code failure See Also e _p
151. Values TRUE if possible RTCS appends a send push flag to the last packet in the segment of the data that is associated with send and immediately sends the data A call to send might block until another task calls send for that socket FALSE before it sends a packet RTCS waits until it has received enough data from the host to completely fill the packet Default value TRUE Change Anytime Socket type Stream Comments Send Timeout Option name OPT SEND TIMEOUT Protocol level SOL TCP Values Zero RTCS waits indefinitely for outgoing data during a call to send Non zero RTCS waits for this number of milliseconds for incoming data during a call to send Default value Four minutes Change Anytime Socket type Stream Comments When the timeout expires send returns Freescale MQX RTCS User s Guide Rev 10 292 Freescale Semiconductor Send Buffer Size Socket Error Socket Type Function Reference Option name OPT TBSIZE Protocol level SOL TCP Values Recommended to be a multiple of the maximum segment size where the multiple is at least three Default value 4380 bytes Change Before bound Socket type Stream Comments When the socket is bound RTCS allocates a send buffer of the specified number of bytes which controls how much sent data RTCS can buffer for the s
152. _get_wep_key sas aere a amana hm Bea ce aie ie iR REESE SERE 213 7 1 99 iwcfg_set_passphrase kilo Gu Wa aar ia 214 7 1 100iwcfg get passphrase llle 215 7 1 1019610 set set WG asa issa zzzi cem UREUERUERYR RRE ERE ED PR x 216 ARI a A 217 Zu T108IWEIg Sal DOWN aorta dis o sed 218 aan PA 219 A rer 221 7121090051218 Mill aa aa de id ed oo e e as 222 7 1 OF MIB find ODISCINAMED sra aa 52 pede o eb Rara dra AR ea d i 223 7 1 108MIB Sel objectriamel eios duis ke Re is ou 224 Tel POONA COs i 2 speqchee ev Y seb d due En iq den CY d CREER 225 Freescale MQX RTCS User s Guide Rev 10 8 Freescale Semiconductor TORIA Moll rare ea 226 nihii co ei temea Ed gi ddd n ie di n ee Be fetite de dn are ilie a i ee de DEG 227 o qos o pese o n cance Reese a Am d e A ra 228 a IONS aperia it ptio sarat d di ER he won eee A See UR 229 EBD o a Le 230 21 IDIGEVNDIM au _ O O O O OO I dade SREREEXALERAZPZANLY 232 oh HORTUS ACME a aes eiit dde O OO mS SERE REP e PS ewe Ra ean MN 234 NEW co err 236 MIO LO detachsock lt 4206424200 0 2426050 RE Re bed ob 514 Rice RARE RE RS 237 I19RTCS exec TFTP BIND iussa same u RR REM REOR EROR dew RO Rm UL 238 A2URTGOS 6xec TFTP OFF iube ned ie e Rare Rene GG n a 240 121RTCS_exec_TFTP_SREC usos veria AD ene EU RE atr td e ane S en 241 pene galo 380 acasa aa O O I se aaa a dei ace iai adie Peu P RUE GU 243 JJ2SRTGS galo add PENIS 149a a
153. a stream socket Sock socket PF INET SOCK STREAM 0 if sock RTCS SOCKET ERROR printf AnFailed to create the stream socket task block Bind the stream socket to a TCP port error bind sock amp laddr sizeof laddr if error RTCS OK printf nFailed to bind the stream socket Ox lx error task block Set up the stream socket to listen on the TCP port error listen sock 0 if error RTCS OK printf Anlisten failed 0x 1x error task block listensock sock printf AninQuote Server is active on port 17 n index 0 for Sock RTCS selectall 0 if sock listensock Connection requested accept it rlen sizeof raddr Sock accept listensock amp raddr amp rlen if sock RTCS SOCKET ERROR printf Anaccept failed error 0x 1x RTCS geterror listensock continue Send back a quote send sock Quotes index strlen Quotes index 1 0 time delay 1000 shutdown sock FLAG CLOSE TX else Datagram socket received data memset amp raddr 0 sizeof raddr rlen sizeof raddr Freescale MQX RTCS User s Guide Rev 10 Using Sockets Freescale Semiconductor 53 Using Sockets length recvfrom sock NULL 0 0 amp raddr amp rlen if length RTCS ERROR printf AinError x receiving from d d d d d RTCS geterror sock raddr s
154. ag For incoming data RTCS matches the data packet by packet to recv or recvfrom calls that the application makes If a packet arrives and one of the recv and recvfrom calls is not waiting for data RTCS queues the packet 3 19 2 Pre Specifying a Peer An application can optionally pre specify a peer by calling connect Pre specification has the following effect e The send function can be used to send a datagram to the peer that is specified in the call to connect Calls to send fail if connect has not been called previously The behavior of sendto is unchanged It is not restricted to the specified peer The functions recv or recvfrom return datagrams that have been sent by the specified peer only 3 20 Shutting Down Datagram Sockets An application can shut down a datagram socket by calling shutdown Before the function returns the following actions occur Outstanding calls to recvfrom return immediately e RTCS discards received packets that are queued for the socket and frees their buffers When shutdown returns the socket handle is invalid and the application can no longer use the socket 3 21 Using Stream Sockets 3 22 Changing Stream Socket Options An application can change the value of certain stream socket options anytime For details see the listing for setsockopt in Chapter 7 Function Reference Freescale MQX RTCS User s Guide Rev 10 48 Freescale Semiconductor
155. ailable This script generates the first part of the definition file no user code is generated Use this script as gawk f mib2def awk test mib test def 5 12 6 Standard MIB Included In RTCS There are two MIBs included and compiled by default with RTCS library The standard MIB as defined by RFC1213 MIB providing MQX specific information Custom MIB database can be defined as a part of application see example application in rtcs examples snmp 5 13 SNTP Client RTCS provides an SNTP Client that is based on RFC 2030 Simple Network Time Protocol The SNTP Client offers two different interfaces One is used as a function call that sets the time to the current time and the other interface starts a SNTP Client task that updates the local time at regular intervals Table 5 5 Summary SNTP Client Services SNTP_init Starts the SNTP Client task SNTP_oneshot Sets the time using the SNTP protocol Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 87 RTCS Applications 5 14 Telnet Client Telnet Client implements a client that complies with the Telnet protocol specification RFC 854 A Telnet connection establishes a network virtual terminal configuration between two computers with dissimilar character sets The server host provides a service to the user host that initiated the communication To start a TCP IP based Telnet Client an application calls TELNET_connect
156. all Waits for activity on any socket that a caller owns RTCS_selectset Waits for activity on any socket in a set of sockets send Sends data on a stream socket or on a datagram socket for which a remote endpoint has been specified sendto Sends data on a datagram socket setsockopt Sets the value of a socket option shutdown Shuts down a connection and discards the socket socket Creates a socket 3 30 Example A Quote of the Day server sets up a datagram socket and a stream socket The server then loops forever If the stream socket receives a connection request the server accepts it and sends a quote If the datagram socket receives data the server sends a quote sockaddr in uint 32 int 32 uint 32 uint 32 uint 16 Set up the UDP port Quot laddr raddr SOCk listensock length index error rlen Server services port 17 Freescale MQX RTCS User s Guide Rev 10 52 Freescale Semiconductor laddr sin family AF_INET laddr sin port BOT laddr sin addr s addr INADDR ANY Create a datagram socket Sock socket PF INET SOCK DGRAM 0 if sock RTCS SOCKET ERROR printf AnFailed to create datagram socket task block Bind the datagram socket to the UDP port error bind sock amp laddr sizeof laddr if error RTCS OK printf inFailed to bind datagram 0x lx error task block Create
157. alues for the remaining variables pio iopcb pppoe client init init ptr if pio printf nPPPOE client Initialized Endif _PPP_ACCM 0 error PPP initialize pio amp phandle if error printf NnPPP initialize 1x error task block Endif _iopcb open pio PPP lowerup PPP lowerdown phandle error RTCS if add phandle RTCS IF PPP amp ihandle if error printf nIF add failed error lx error task block Endif mem zero amp ipcp data sizeof ipcp data ipcp data IP UP PPP linkup ipcp data IP DOWN NULL ipcp data IP PARAM pointer amp ppp sem ipcp data ACCEPT LOCAL ADDR TRUE ipcp data LOCAL ADDR INADDR ANY ipcp data ACCEPT REMOTE ADDR TRUE ipcp data REMOTE ADDR INADDR ANY ipcp data DEFAULT NETMASK TRUE ipcp data NETMASK 0 ipcp data DEFAULT ROUTE TRUE ipcp data NEG LOCAL DNS FALSE ipcp data ACCEPT LOCAL DNS 0 ipcp data LOCAL DNS 0 ipcp data NEG REMOTE DNS FALSE ipcp data ACCEPT REMOTE DNS 0 ipcp data REMOTE DNS 0 error RTCS if bind IPCP ihandle amp ipcp data Freescale MQX RTCS User s Guide Rev 10 68 Freescale Semiconductor Point to Point Drivers if error printf AnIF bind failed error 1x error task block Endif printf AnTry
158. an the priority of the RTCS task that is make it a higher number stacksize in Stack size for FTP Server task shell in Shell task that FTP Server starts when a client initiates a connection see description Description Function FTPd init starts Telnet Server and creates FTPSRV task A sample FTP Server is included in the examples shell directory The FTP Server allows any number of users to connect from a remote workstation using an FTP client The FTP Server optionally supports usernames and passwords To enable usernames and passwords the global FTPd userfile must be set to the name of the file containing the usernames and passwords The username and password file contains one line for each username password combination in one of the following formats username e username password e username password info If the username is specified without a password no password is required The info field is ignored This is a valid sample password file guest anonymous userl passl user2 pass2 user3 pass3 other stuff To disable usernames and passwords set FTPd_userfile to NULL The commands supported by the FTP Server are configurable The application must initialize a NULL terminated global variables FTPd_ COMMAND STRUCT FTPd commands with the supported commands and char FTPd rootdir with the default FTP root directory path Available commands are Freescale MQX RTCS User s Guide Rev 10
159. an IP datagram to create an ethernet frame by prepending the ethernet header and appending the FCS endian format Byte ordering for processor s words one of big endian the most significant byte is the first byte in the word or little endian the most significant byte is the last byte in the word endpoint The IP address transport protocol and port number that define one end of a socket ENET Refers to an ethernet driver ESP Encapsulating Security Payload security protocol Ethernet Can refer to IEEE 802 3 signaling protocol An ethernet controller hardware Sometimes called an ethernet device and a MAC media access controller An ethernet driver software Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 413 ethernet address See address executable image See boot file executable file See boot file External Data Representation See XDR F FALSE Not TRUE that is zero FCS Frame Check Sequence The result of an algorithm usually a CRC for determining whether an error occurred during transmission of a frame File Transfer Protocol See FTP finite lease DHCP defines mechanisms whereby it can assign an IP address to a client for a limited time which means it can reassign the IP address to another client later fragment One of An IP datagram that contains only a portion of the payload from a larger IP datagram e Part of an RTCS PCB fragmentation
160. ange the values the application must do so before it creates RTCS that is before it calls RTCS create To change From this Change this creation default value variable Priority of RTCS tasks 6 _RTCSTASK priority see because you must assign priorities to all the tasks that caution below you write RTCS lets you change the priority of RTCS tasks so that it fits with your design If the priority of RTCS tasks is too low RTCS might miss received packets or violate the timing specifications for a protocol Additional stack size that is needed for DHCP and 0 _RTCSTASK_stacksize IPCP callback functions for PPP Maximum number of packet control blocks PCBs that 32 _RTCSPCB_max RTCS uses Pool that RTCS should allocate memory from If O 0 _RTCS_mem_pool system pool will be used If a different pool needs to be used the memory pool id must be provided Example RTCS mem pool mem create pool ADR SIZE 2 7 Creating RTCS To create RTCS call RTCS create which allocates resources that RTCS needs and creates RTCS tasks 2 8 _ Changing RTCS Running Parameters RTCS uses some global variables after an application has created them All the variables have default values most of which you need never change If you want to change the values an application can do so anytime after it creates RTCS that is anytime after it calls RTCS create To do this Change this variable to TRUE
161. arameters handle in FTP session handle command in FTP command ctrl fd in Device to write control connection responses to data fd in Device for the data connection flags in Options for the data connection Description Function FTP command data sends a command to the FTP server opens a data connection and then performs a data transfer Parameter flags is a bitwise OR of the following the connection mode which must be one of the following FTPMODE DEFAULT the client will use the default port for the data connection FTPMODE PORT the client will choose an unused port and issue a PORT command FTPMODE PASV the client will issue a PASV command the data transfer direction which must be one of FTPDIR RECV the client will read data from the data connection and write it to data fd FTPDIR SEND the client will read data from data fd and send it to the data connection Return Value e The FTP response code success e failure See Also e FTP command Example See FTPd init Freescale MQX RTCS User s Guide Rev 10 140 Freescale Semiconductor Function Reference 7 1 39 FTPd init Starts the FTP Server Synopsis uint 32 FTPd init char ptr name uint 32 priority uint 32 stacksize Parameters name in Name of FTP Server task priority in Priority of FTP Server task we recommend that you make the priority lower th
162. ary socket Create DNS Resolver task See Also gethostbyaddr gethostbyname e RICS if bind e RTCS if bind BOOTP e RTCS_ if bind DHCP e RTCS if bind IPCP Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 133 Function Reference 7 1 32 ECHOSRV init Starts RFC 862 Echo Server Synopsis uint 32 ECHOSRV_init char ptr name uint 32 priority uint 32 stacksize Parameters name in Name of the server s task priority in Priority of the server s task stacksize in Stack size for the server s task Description Function ECHOSRV_init starts the RFC 862 Echo Server and creates ECHO task We recommend that you make priority lower than the priority of the RTCS task that is make it a higher number Return Value e RTCS OK success Error code failure Example error ECHOSRV init Echo server 7 1000 Freescale MQX RTCS User s Guide Rev 10 134 Freescale Semiconductor Function Reference 7 1 33 EDS init Starts Embedded Debug Server EDS server Synopsis uint 32 EDS init char ptr name uint 32 priority uint 32 stacksize Parameters name in Name of EDS Server Winsock task priority in Priority of EDS Server Winsock stacksize in Stack size for EDS Server Winsock task Description The function starts the EDS task which listens on UDP and TCP ports 5002 and Creates EDS task When the Inte
163. at is the official name of the host h aliases NULL terminated array of alternate names for the host h addrtype Type of address being returned always AF INET h length Length in bytes of the address h addr list Pointer to a list of pointers to the network addresses for the host each host address is represented as a series of bytes in network byte order they are not ASCII strings Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 341 Data Types 8 3 8 HTTPD CGI LINK STRUCT CGI callback structure See HTTPD PARAMS STRUCT typedef int CGI CALLBACK HTTPD SESSION STRUCT typedef struct httpd cgi link struct char cgi name HTTPDCFG MAX SCRIPT LN 1 CGI CALLBACK callback HTTPD CGI LINK STRUCT 8 3 8 1 Fields 8 3 8 1 1 cgi name callback function alias used as name for requested page 8 3 8 1 2 callback callback function Freescale MQX RTCS User s Guide Rev 10 342 Freescale Semiconductor Data Types 8 3 9 HTTPD_FN_LINK_STRUCT Function callback link structure one row in table functions callback table See HTTPD PARAMS STRUCT typedef void FN CALLBACK HTTPD SESSION STRUCT typedef struct httpd fn link struct char fn name HTTPDCFG MAX SCRIPT LN 1 FN CALLBACK callback HTTPD FN LINK STRUCT fn name callback function alias used as command in inlined script callback callback function Freescale MQX RTCS User s Guide Re
164. ation statistics Synopsis NAT STATS PTR NAT stats void Return Value e Pointer to the NAT STATS structure success NULL failure NAT init has not been called See Also NAT init e NAT STATS Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 227 AD Function Reference 7 1 112 ping See RTCS_ping Freescale MQX RTCS User s Guide Rev 10 228 Freescale Semiconductor Function Reference 7 1 113 PPP initialize Initializes PPP Driver for the PPP link Synopsis uint 32 PPP initialize _iopcb handle device ppp handle _PTR_ ppp handle Parameters device in VO stream to use ppp handle out Pointer to the PPP handle Description Function PPP initialize fails if RTCS cannot do any one of the following Allocate memory for the PPP state structure or initialize a lightweight semaphore to protect it Initialize LCP or CCP Allocate a pool of message buffers Create the PPP send and receive tasks Return Value e PPP OK success Error code failure See Also e iopcb handle iopcb table Example See Section 2 15 6 Example Setting Up RTCS Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 229 Function Reference 7 1 114 recv Provides RTCS with incoming buffer 7 1 114 1 Synopsis int_ 32 recv uint_32 socket char PTR buffer uint 32 buflen uint 32 flags Parameters socket in Handle for t
165. by setting the RTCS socket part init 2 16 2 37 RTCSCFG SOCKET PART GROW RTCS socket allocation grow granularity Override in application by setting the RTCS socket part grow 2 16 2 38 RTCSCFG SOCKET PART MAX RTCS socket maximum count Override in application by setting the RTCS socket part max 2 16 2 39 RTCSCFG UDP MAX QUEUE SIZE UDP maximum queue size Override in application by setting the UDP max queue size 2 16 2 40 RTCSCFG ENABLE UDP STATS Set to 0 for disable UDP statistics 2 16 2 41 RTCSCFG ENABLE TCP STATS Set to 0 for disable TCP statistics 2 16 2 42 RTCSCFG_TCP_MAX_CONNECTIONS Default value 0 Maximum number of simultaneous connections allowed Define as 0 for no limit 2 16 2 43 RTCSCFG TCP MAX HALF OPEN Default value 0 Maximum number of simultaneous half open connections allowed Define as 0 to disable the SYN attack recovery feature 2 16 2 44 RTCSCFG ENABLE RIP STATS Default value RTCSCFG ENABLE STATS enable RIP statistics 2 16 2 45 RTCSCFG QUEUE BASE Override in application by setting RTCSQUEUE base 2 16 2 46 RTCSCFG STACK SIZE Override in application by setting RTCSTASK stacksize Freescale MQX RTCS User s Guide Rev 10 36 Freescale Semiconductor Setting Up the RTCS 2 16 2 47 RTCSCFG LOG PCB By default RTCS logs packet generation and parsing in the MQX kernel log subject to whether the application calls RTCSLOG enable Set this value to 0 zero to have RTCS
166. cal endpoint identification by providing the port number Before it is bound the socket is called an unbound socket after it is called a bound socket block verb When the active task blocks MQX removes it from the ready queue and makes another task active See also dispatch verb boot file Also called executable image and executable file BootP Bootstrap Protocol The protocol that is used to get an IP address based on an ethernet address load an executable file and run that file Bootstrap Protocol See BootP broadcast address See address BSD See UNIX BSD 4 4 Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 409 byte swap Converts from one endian format to the other See also big endian host byte order little endian and network byte order C cache See ARP cache callback function A function that an application provides and RTCS calls when RTCS detects a certain event The application can provide callback functions for DHCP by calling RTCS if bind DHCP and for PPP by calling RTCS if bind IPCP carrier sense Each interface on a network can listen for carrier wave to determine whether another interface 1s using the network See also CSMA CD carrier sense multiple access with collision detection See CSMA CD CCITT International Telegraph and Telephone Consultative Committee An international organization that sets standards for data communications including alg
167. confusion the instance of a task is simply called the task task error code The error code that MQX assigns to a task if certain calls to MQX functions cause an error TCP Transmission Control Protocol TCP IP The entire IP stack Telnet A network protocol for a virtual terminal TFTP Trivial File Transfer Protocol Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 425 Transmission Control Protocol See TCP transport layer That portion of the OSI system that is responsible for the reliability and multiplexing of data transfer across the network over and above which the network layer provides transport layer protocol A protocol that provides transparent transfer of data between network hosts Transport layer protocols rely on network layer protocols to route datagrams over a network transport protocol One of UDP or TCP Sometimes called a delivery service Trivial File Transfer Protocol See TFTP TRUE Not FALSE that is any non zero value U UDP User Datagram Protocol Ul command Unnumbered Information command HDLC UNIX BSD 4 4 Berkeley distribution of the UNIX operating system version 4 3 unnumbered information command See UI command User Datagram Protocol See UDP W wait Blocking 1 O on a stream socket where wait implies wait for data to be sent or received X XDR External Data Representation protocol Used with RPC Freescale MQX R
168. controller under Ethernet MAC address See address Management Information Base See MIB mask See network mask maximum receive unit See MRU maximum transmission unit See MTU MB Megabyte Mb Megabit MD5 Message digest algorithm Used by PPP Driver for CHAP authentication media Plural of medium media address See address medium The physical connection between hosts for example a cable Singular of media Medium Access Control See MAC message See datagram message digest algorithm See MD5 MIB Management Information Base RFCs 1213 and 2287 MQX MQX The RTOS that RTCS uses MQX is an RTOS for single processor multi processor and distributed processor embedded real time applications MRU Maximum receive unit One of the LCP configuration options for PPP Driver that you cannot change Freescale MQX RTCS User s Guide Rev 10 418 Freescale Semiconductor MTU Maximum transmission unit The largest amount of user data for example the largest size of an IP datagram that can be sent in a single frame on a particular medium multicast address See address multicast group One of e Set of hosts that have joined a multicast group Same as the multicast address multihomed A host that has multiple IP addresses multiple access All interfaces are equally able to send frames onto the network No interface has a higher priority than another See also CSMA CD N
169. ction sends a cold start trap type 0 0 SNMP trap version 1 Return Value See Also e SNMPv2 trap coldStart Freescale MQX RTCS User s Guide Rev 10 302 Freescale Semiconductor Function Reference 7 1 153 SNMP_trap_authenticationFailure Synopsis void SNMP trap authenticationFailure void Description This function sends an authentification failure trap type 4 0 SNMP trap version 1 Return Value See Also e SNMPv2 trap authenticationFailure Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 303 Function Reference 7 1 154 SNMP trap linkDown Synopsis void SNMP trap linkDown pointer ihandle Parameters ihandle in interface index Description This function sends a link down trap type 2 0 SNMP trap version 1 Return Value See Also e SNMPv2 trap linkDown Freescale MQX RTCS User s Guide Rev 10 304 Freescale Semiconductor Function Reference 7 1 155 SNMP_trap_myLinkDown Synopsis void SNMP trap myLinkDown pointer ihandle Parameters ihandle in enterprise specific interface index Description This function sends a link down trap type 2 0 for enterprise specific device SNMP trap version 1 Return Value See Also e SNMPv2 trap linkDown Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 305 Function Reference 7 1 156 SNMP_trap_linkUp Synopsis void SNMP trap linkUp pointer ihandle Parameters ihandle in
170. ctor 13 Freescale MQX RTCS User s Guide Rev 10 14 Freescale Semiconductor Chapter 1 Before You Begin 1 1 About This Book This book is a guide and reference manual for using the MQX RTCSTM Embedded TCP IP Stack which is part of Freescale MQX Real Time Operating System distribution This RTCS User Guide is written for experienced software developers who have a working knowledge of the C and C languages and their target processor 1 2 Where to Go for More Information e The release notes document accompanying the Freescale MQX release provides information that was not available at the time this user s guide was published e The MOX User s Guide describes how to create embedded applications that use the MOX RTOS The MOX Reference describes prototypes for the MOX API 1 3 Conventions This section explains terminology and other conventions used in this manual 1 3 1 Product Names RTCS In this book we use RTCS as the abbreviation for the MQX RTCS full featured TCP IP stack e MOX MQX is used as the abbreviation for the MQX Real Time Operating System 1 3 2 Tips Tips point out useful information TIP If your CD ROM drive is designated by another drive letter substitute that drive letter in the command 1 3 3 Notes Notes point out important information NOTE Non strict semaphores do not have priority inheritance Freescale MQX RTCS User
171. d REMOTE IP 1x n app info gt REMOTE ADDRESS Initialization of IP specific application could start here else printf AnConnection closed REMOTE IP 1x n app info gt REMOTE ADDRESS Endif Endwhile Endbody void init ppp session pointer pio pointer phandle pointer parm Body uint 32 error i Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 65 Point to Point Drivers IPCP DATA STRUCT ipcp data rtcs if handle ihandle iopcb handle boolean PPP ACCM 0 iopcb iopcb handle pio max connect TRUE iopcb open iopcb PPP lowerup PPP lowerdown phandle error RTCS i if error f add phandle RTCS IF PPP amp ihandle printf nIF add failed error lx error Endif search for UU an IP addres to give out for i 0 i lt MAX CONNECTION i if GLOBAL APP CFG i PPP HANDLE NULL max connect FALSE break Endif Endfor Jl kj if max connect or modi return Endif save the se GLOBAL APP CFG GLOBAL APP CFG GLOBAL APP CFG fy the function so that it returns FALSE ssion information i PPP HANDLE phandle i IO PCB HANDLE pio i IF HANDLE ihandle mem zero amp ipcp data sizeof ipcp data server configuration
172. d In AICS L G RR RR a ande kk XX ear aaa e ra 87 HE HI o MT OUR 87 EE o co dadas el ER oe heen tea a Nea T TE a s pt B dee OR dad 88 5 15 Telnet Server eve e rr R9 eee m RR RR ERR i d Gw pa RUE E ar 88 516 Tele CUBI MT aaa te be trata 99 93 3059 ER E33 Sede RO eer es a 3 8 eee VU d Ra sti 88 SOIT Ve le SON oou wa eae dm te PME e Ati nef Ed dE Oh te dad Ve S px de FFAN dud 88 5 17 1 Configuring TFTP Server diua rds box ea uh dt dd eee tmm Ente 88 5 1052 Starting Vie SeIVel sms piar Y O e e Bra dei ded ii e e RARE REPE 89 5 18 Quote of the Day Service Le UG CU n da i ad 89 SAS Typical ATCS IP Packet Pans acu cc e amet tat dca n i i lei de e 89 Chapter 6 Rebuilding 6 1 Why to Rebuild RTCS usus me CR DA WAD NR BOB BY Bd Body MW n d n rd 91 6 2 Before YOu BegiN ER T D TT DETTO 91 Go RICS Directory SWC au ceace cete ae datat Gri sees Se ERE dd ERES RE REUS 92 6 4 RTCS Build Projects in Freescale MOX gt gt FUD ee em RR Rn 92 6 4 1 PostBuild Process ass asd iert XA AR AREE CER RR nde eoe E C Ra dia 92 04A 2 Buld TOPES masones ES 93 6 5 Rebuilding Freescale MQX RTCS A A AA FY uad 93 Chapter 7 Function Reference 7 1 Function Listing Format ion ae arat rima eri e eee NC 95 zT neo Namel surassageuczs aa dia aa date deabia a atu aa S233 3523 95 A o 4 cud od I ee ee RN 97 7 4 JOE DOBLE WY a O HR HN HE A ads 98 7 1 4 lopcb pppoe client desWoy s lt cic
173. d values to find out useful information about your application Description Describes the function function_name This section also describes any special characteristics or restrictions that might apply Function blocks or might block under certain conditions Function must be started as a task Function creates a task Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 95 Function Reference Function has pre conditions that might not be obvious Function has restrictions or special behavior Return Value Specifies any value or values returned by function function namewy See Also Lists other functions or data types related to function function name Example Provides an example or a reference to an example that illustrates the use of function function name Function Listings This section provides function listings in alphabetical order Freescale MQX RTCS User s Guide Rev 10 96 Freescale Semiconductor Function Reference 7 1 2 _ opcb_open Opens the I O PCB driver for PPP Synopsis void _iopcb_open _iopcb handle ioppp _CODE_PTR_ PPP lowerup CODE PTR_ PPP lowerdown ppp handle PPP handle Parameters ioppp in VO PCB handle PPP lowerup in Pointer to callback function to use when the lower layer is up PPP lowerdown in Pointer to the callback function to use when the lower layer is down PPP handle in Pointer to the PPP in
174. ddress see ethernet address and IP address Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 407 address class A method to determine the boundary between the network and host portions of an IP address For example Class A Class B See also network mask and CIDR address family The field in sockaddr sockaddr_in sockaddr_in6 structures that identifies the family that RTCS supports for sockets See also AF_INET AF INET6 protocol family address mask See network mask address resolution Mapping an IP address onto a physical address Address Resolution Protocol See ARP ACFC Address and Control field compression One of the LCP configuration options for PPP Driver that you cannot change Address and Control fields compression See ACFC AF INET Internet address family using IP addresses It is the address family that RTCS supports for sockets See also PF INET AF INET6 This is similar to AF NET but refers to the IPv6 protocol AH Authentication Header security protocol ALG See application level gateway all stations address See address AP Authentication protocol for host authentication One of the LCP configuration options for PPP Driver The default is no AP You can change it to CHAP PAP or both API Application Programming Interface application level gateway Application level gateways connect host and target applications transparently through NAT devices An
175. dentification ip_data in pointer to bind ip data structure Description This function tries to bind device to network using given IPv6 address data information If the address is already used an error is returned This is blocking function i e doesn t return until the process is finished or error occurs Any failure during bind leaves the network interface in unbound state Return Value e IPCFG OK success e RTCSERR IPCFG BUSY RTCSERR IPCFG DEVICE NUMBER RTCSERR IPCFG INIT RTCSERR IPCFG BIND See Also e ipcfg6_unbind addr Example See example in shell source rtcs sh_ipconfig c Shell ipconfig staticip Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 205 Function Reference 7 1 91 ipcfg6 unbind addr Unbinds the IPv6 address from the Ethernet device Synopsis uint 32 ipcfg6 unbind addr uint 32 device IPCFG6 UNBIND ADDR DATA PTR ip data Parameters device in device identification ip data in pointer to unbind ip data structure Description This function releases the IPv6 address information bound to a given device It is blocking function i e doesn t return until the process is finished or error occurs Return Value IPCFG OK success RTCSERR IPCFG BUSY RTCSERR IPCFG DEVICE NUMBER RTCSERR IPCFG INIT See Also e ipcfg6 bind addr Example See example in shell source rtcs sh_ipconfig c Shell ipconfig unbind6 Freescale MQX RTCS User s
176. ductor Data Types 8 3 12 HTTPD_SESSION_STRUCT HTTP session structure contains run time data for session typedef struct httpd session struct HTTPD_SES_STATE state int valid unsigned int keep alive int sock HTTPD REQ STRUCT request HTTPD RES STRUCT response int header int req lines int remain HTTPD TIME STRUCT time char recv buf HTTPDCFG RECV BUF LEN 1 char recv rd int recv used dif HTTPDCFG POLL MODE char line int line used fendif HTTPD SESSION STRUCT state actual session status valid describe session validity keep alive connection persistance sock Socket used by session request http request data storage response http response data storage header flag for header sending req lines remain time Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 347 Pe Data Types state start time in ticks recv_buf temporary receiving buffer recv_rd reading pointer in recv buf recv_used recv_buf used size line line_used Freescale MQX RTCS User s Guide Rev 10 348 Freescale Semiconductor 8 3 13 HTTPD STRUCT Main HTTP server structure typedef struct httpd struct HTTPD PARAMS STRUCT params runtime data int sock HTTPD SESSION STRUCT session HTTPD STRUCT params pointer to server parameters structure sock runtime data listen socket se
177. e Interface Parameter to RTCS if add Ethernet RTCS IF ENET Local loopback RTCS IF LOCALHOST PPP RTCS IF PPP typedef struct uint 32 CODE uint 32 CODE uint 32 CODE PTR OPEN struct ip if PTR OSE struct ip if PTR PTR SEND struct ip if PTR struct rtcspcb P ip address ip address uint 32 CODE PTR JOIN struct ip if PTR Bi p ti FU 3 ys a _ip address uint 32 CODE PTR LEAVE struct ip if PTR ip address RTCS IF STRUCT PTR RTCS IF STRUCT PTR The IP interface structure ip if contains information to let RTCS send packets ethernet or datagrams PPP OPEN Called by RTCS to register with a packet driver ethernet or to open a link PPP e Parameter pointer to the IP interface structure Returns a status code CLOSE Called by RTCS to unregister with the packet driver ethernet or to close the link PPP e Parameter pointer to the IP interface structure Returns a status code SEND Called by RTCS to send a packet ethernet or datagram PPP First parameter pointer to the IP interface structure Second parameter pointer to the packet ethernet or datagram PPP to send Third parameter For ethernet Protocol to use ENETPROT IP or ENETPROT ARP For PPP Next hop source address Fourth parameter For ethernet IP address of the destination Freescale MQX RTCS
178. e Change use with getsockopt only returns value in optval Socket type Datagram or stream Comments Returns local IP address Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 295 Function Reference Examples Example 7 1 Changing the Send Push Option to FALSE uint 32 handle uint 32 opt length sizeof uint 32 uint 32 opt value FALSE uint 32 status status setsockopt handle 0 OPT SEND PUSH amp opt value opt length if status RTCS OK printf Mnsetsockopt status getsockopt handle 0 amp opt value if status RTCS OK printf Mngetsockopt failed with error failed with error 1x status OPT SEND PUSH uint 32 ptr amp opt length 1x status Example 7 2 Changing the Receive Nowait Option to TRUE uint 32 handle uint 32 opt length sizeof ui uint 32 opt value TRUE uint 32 status status setsockopt handle 0 amp opt value if status RTCS OK printf A nError setsockopt nt_32 i OPT RECEIV opt lengt OWAIT n failed with error lx status Example 7 3 Changing the Checksum Bypass Option to TRUE uint 32 handle uint 32 opt length sizeof ui uint 32 opt value TRUE uint 32 status status setsockopt handle SOL amp opt value if status RTCS OK printf AnError setsockopt UDP
179. e 27 2 154 Getting NAT SIIBSIBS cue qe O O O AAA 28 2 15 5 Supported Protocols Li os s sauer E toten a E ien RR RR da 28 2 15 0 Example Seting Up RTOS alu beeen weed ERE2OEREEPIDEE UR Ga ala GA 30 2 10 Gompie Time OB ONS s teen 43 x Coo rado C ODER PER Pa E A A QU EERE Re E 31 Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 3 2 16 1 Recommended Settings ieuo da par dar a 32 2 16 2 Configuration Options and Default Settings VVV YY 32 2 16 3 Application specific default settings FF ua 38 2 16 4 HTTP Server default configuration iese sea Fere e ai Re x RR ea ba UR 40 Chapter 3 Using Sockets E Before You BEI Y ri e 43 3 2 Protocols SUDDOIIBO AAA ERES 43 20 MORELL DONOR TT TT UED OO OOH I O i EE 43 3 4 O aso o APP o 44 3 5 Comparison of Datagram and Stream Sockets FFF e 44 3 6 Datagram ATP 44 SE GONMMECUONISES a tsi e Ri y O WW Tr AES Pd re ERES 44 3 7 Unreliable Transfer sean seca ie ar UG DRO cn ap AB OR ea Eni n t pal e ears 44 8 ls cc cise HR FF d dna aa d plai LES 45 o o ST r t eri n i BS PS SS Dna eR 45 39 10 Connection Based scree r r ea POR O TE TARA pa PAIR IE Rp TIN 45 3 11 Hellable Wane cuis eta ata ana d Gib m ne fede a ra bn a d berii ne del dt ee d d 45 3 12 Character Oriented uua sesso eee see II ia e _ N Ie kmda 45
180. e PPP device and one ethernet device rtcs if handle ihandle uint 32 error For Ethernet driver enet handle ehandle For PPP Driver FILE PTR pfile _iopcb handle pio ppp handle phandle IPCP DATA STRUCT ipcp data LWSEM STRUCT ppp sem Static void PPP linkup pointer lwsem lwsem post lwsem Change the priority RTCSTASK priority 7 error RTCS create if error printf AinFailed to create RTCS error SX error return Enable IP forwarding IP forward TRUE Set up the Ethernet driver error ENET initialize ENET DEVICE enet local 0 amp ehandle if error printf AnFailed to initialize Ethernet driver s ENET strerror error return error RTCS if add ehandle RTCS IF ENET amp ihandle if error printf AinFailed to add interface for Ethernet error x error return error RTCS if bind ihandle enet ipaddr enet ipmask if error printf AnFailed to bind interface for Ethernet error x error return printf AnEthernet device d bound to X ENET DEVICE enet ipaddr Set up PPP Driver pfile fopen PPP DEVICE NULL pio iopcb ppphdlc init pfile error PPP initialize pio amp phandle if error Freescale MQX RTCS User s Guide Rev 10 30 Freescale Semiconductor Set
181. e buffer of data to send buflen in Number of bytes in the buffer no restriction flags in Flags to underlying protocols selected from three independent groups Perform a bitwise OR of one flag only from one or more of the groups described under Section Flags Description The function sends the data at buffer as a UDP datagram to the remote endpoint at destaddr This function can also be used when a remote endpoint has been prespecified through connect The datagram is sent to destaddr even if it is different than the prespecified remote endpoint If the socket address has been prespecified you can call sendto with destaddr set to NULL and addrlen equal to zero this combination sends to the prespecified address Calling sendto with destaddr set to NULL and addrlen equal to zero without first having prespecified the destination will result in an error The override is temporary and lasts for the current call to sendto only Setting flags to RTCS MSG NOLOOP is useful when broadcasting or multicasting a datagram to several destinations When lags is set to RTCS MSG NOLOOP the datagram is not duplicated for the local host interface If the function returns RTCS ERROR the application can call RTCS geterror to determine the cause of the error This function blocks but the command is immediately serviced and replied to Return Value Number of bytes sent success RTCS ERROR failure See Also e setsockopt
182. e list 1 Task number Entry point Stack Pri String Auto 1 ain task 2000 9 Main MQX AUTO START TASK 0 0 0 0 0 0 TASK Function Name Main task Returned Value void Comments H END void Main task uint 32 temp Body rtcs if handle ihandle char ptr taskname uint 32 error time i enet handle ehandle _iopcb handle pio ppp handle phandle IPCP DATA STRUCT ipcp data PPPOE CLIENT INIT DATA STRUCT PTR init ptr LWSEM STRUCT ppp sem uint 16 pingid 0 uint 32 PingTargetAddr Ej t ct taskname RTCS error RTCS create if error printf Ain s failed to initialize error X taskname error Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 67 Point to Point Drivers _ task block Life BEndlt Enable IP forwarding IP forward TRUE Initialize the Ethernet device error ENET initialize ENET DEVICE enet local 0 amp ehandle if error printf AnENET initialize s ENET strerror error task block initialize the init structure Alt ptr _mem alloc zero sizeof PPPOE CLIENT INIT DATA STRUCT init ptr gt EHANDLE ehandle _lwsem create amp ppp sem 0 use the default v
183. e num _enet address address uint 32 flags _enet handle PTR emet handle Parameters device num in Device number for the device to initialize address in Ethernet address of the device to initialize flags in One of the following non zero use the ethernet address from the device s EEPROM Zero use address THIS PARAMETER IS NOT USED ANYMORE AND IS IGNORED enet handle out Pointer to the ethernet handle for the device interface Description The function is not a part of RTCS If you are using MQX the function is available to you and you can use it If you are porting RTCS to another operating system the application must supply the function Note This function can be called only once per device number The function does the following It initializes the ethernet hardware and makes it ready to send and receive ethernet packets e It installs the ethernet interrupt service routine Jtsets up send and receive buffers which are usually a representation of the ethernet device s own buffers e Itallocates and initializes the ethernet handle which the upper layer uses with other functions from the Ethernet Driver API and from the RTCS API Return Value e ENET OK success Ethernet error code failure Example See Section 2 15 6 Example Setting Up RTCS Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 137 Function Reference 7 1 36 FTP close T
184. ecretPassword PPP PAP LSECRET amp MySecrets 0 PPP CHAP LSECRETS NULL PPP CHAP LNAME NULL EndIf error RTCS if bind IPCP ihandle amp ipcp data if error printf AinFailed to bind interface for PPP error Sx error return _lwsem wait amp ppp sem printf Connection established with the server Freescale MQX RTCS User s Guide Rev 10 102 Freescale Semiconductor Function Reference 7 1 6 _pppoe_client_stats Gets a pointer to the statistics for PPP over Ethernet Driver Synopsis PPPOEIF STATS STRUCT PTR PPPOE client stat iopcb handle pio Parameters pio in VO PCB handle Description Function pppoe client stats returns a pointer to statistics for PPP over Ethernet Driver Parameter pio is returned by iopcb pppoe client init Return Value Pointer to a PPPOEIF STATS STRUCT structure success NULL failure pio was invalid See Also e jopcb pppoe client init e PPPOEIF STATS STRUCT Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 103 Function Reference 7 1 7 pppoe server destroy Destroy the PPPoE Server tasks Synopsis uint 32 pppoe server destroy pppoe srv handle pppoe handle Parameters pppoe handle in PPPoE Server handle Description Function pppoe server destroy destroys the PPPoE Server task and frees the resources that are allocated to that task Return
185. ed Service Set Identifier string Description This function returns ESSID for selected device Return Value e ENET OK success ENET ERROR ENETERR INVALID DEVICE Example define DEFAULT DEVICE 1 char 20 ssid name iwcfg get ssid DEFAULT DEVICE amp ssid name Freescale MQX RTCS User s Guide Rev 10 208 Freescale Semiconductor Function Reference 7 1 94 iwcfg commit Synopsis uint 32 iwcfg commit uint 32 dev num Parameters dev num in Device identification index Description Commits the requested change Some cards may not apply changes done immediately they may wait to aggregate the changes This command forces the card to apply all pending changes Return Value e ENET OK success ENETERR INVALID DEVICE Other device specific errors Example define SSID NGZG define DEFAULT DEVICE 1 initialize rtcs before iwcfg set essid DEFAULT DEVICE SSID iwcfg commit DEFAULT DEVICE Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 209 Function Reference 7 1 95 iwcfg set mode Synopsis uint 32 iwcfg set mode uint 32 dev num char ptr mode Parameters dev num in Device identification index mode in Wifi device mode accepted values are managed and adhoc Description Set the operating mode of the device which depends on the network topolo
186. ed by RTCS if add This function blocks until DHCP completes initialization but not until it binds the interface Return Value e RTCS OK success Error code failure See Also RICS if add e RICS if bind e RTCS if bind BOOTP e RTCS if bind IPCP DHCP DATA STRUCT Example enet handl handle Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 257 Function Reference _rtcs if handle ihandle uint 32 error uint 32 optlen 100 Use the size that you need for the number of params that you are using with DHCP uchar option array 100 uchar _PTR_ optptr DHCP DATA STRUCT params uchar parm options 3 DHCPOPT SERVERNAME DHCPOPT FILENAME DHCPOPT FINGER SRV uint 32 timeout 120 two minutes error ENET initialize 0 enet local 0 amp ehandle if error printf AnFailed to initialize Ethernet driver s ENET strerror error return error RTCS create if error RTCS OK printf AnFailed to create RTCS error x error return error RTCS if add ehandle RTCS IF ENET amp ihandle if error printf AnFailed to add the interface error x error return You supply the following functions if any is NULL DHCP Client follows its default behavior params CHOICE FUNC DHCPCLNT test choice func params BIND FUNC DHCPCLNT test bind func
187. ed by the tuple of source IP address ICMP query ID and target IP address All other sessions are identified through the tuple of source IP address target IP address and IP protocol See also VAT session stage PPPoE PPPoE has two distinct stages a Discovery stage and a PPP Session stage silently discard See discard silently Simple Network Management Protocol See SNMP SMI Structure of Management Information SNMP Simple Network Management Protocol SOCK DGRAM Literal that indicates a datagram socket type SOCK STREAM Literal that indicates a stream socket type Freescale MQX RTCS User s Guide Rev 10 424 Freescale Semiconductor socket An object that an application uses to communicate with a remote endpoint A socket is independent of the transport protocol socket type Datagram SOCK DGRAM or stream SOCK STREAM software interface See API SREC Motorola S Record A file format for boot files See also B N and COFF S Record See SREC station An ethernet equipped computer stream The sequential nature of TCP data transfers Structure of Management Information See SMI switch See hub system resource In the MQX sense allocated memory might be a system resource which means that any task can use it and any task can free it T task A body of C code usually an infinite loop that performs some function There can be multiple instances of a task Unless it would create
188. eescale MQX distribution lbuild Icodewarror CodeWarrior specific build files project files lexamples example Source files c for the example and the example s build project source All RTCS source code files lib lt board gt lt comp gt rtcs RTCS library files built for your hardware and environment 6 4 RTCS Build Projects in Freescale MQX The RTCS build project is constructed very much like the other core library projects included in Freescale MQX RTOS The build project for a given development environment for example CodeWarrior is located in the rtcs build lt compiler gt directory Although the RTCS code is not specific to any particular board nor to processor derivative a separate RTCS build project exists for each supported board Also the resulting library file is built into a board specific output directory in lib lt board gt lt compiler gt The main reason why is this board independent code built into the board specific output directory is because it may be configured for each board separately The compile time user configuration file is taken from board specific directory config lt board gt In other words the user may want to build the resulting library code differently for two different boards See the MOX User Guide for more details about user configuration files or about how to create customized configurations and build projects 6 4 1 Post Build Processing All RTCS build project
189. endpoint or sets a remote endpoint for a datagram socket Synopsis uint 32 connect uint 32 socket sockaddr PTR destaddr uint 16 addrlen Parameters socket in Handle for the stream socket to connect destaddr in Pointer to the remote endpoint identifier addrlen in Length in bytes of what destaddr points to Description The connect function might be used multiple times Whenever connect is called the current endpoint is replaced by the new one A connection can be dissolved by calling connect and specifying an address family of AF UNSPEC This dissolves the association places the socket into the bound state and returns the error code RTCSERR SOCK INVALID AF If connect fails the socket is left in a bound state no remote endpoint When used with stream sockets the function fails if the remote endpoint Rejects the connection request which it might do immediately e Is unreachable which causes the connection timeout to expire If the function is successful the application can use the socket to transfer data When used with datagram sockets the function has the following effects The send function can be used instead of sendto to send a datagram to destaddr e The behavior of sendto is unchanged it can still be used to send a datagram to any peer The socket receives datagrams from destaddr only This task blocks until the connection is accepted or until the connection timeout
190. er s Guide Rev 10 58 Freescale Semiconductor Point to Point Drivers 4 2 3 Changing Authentication By default PPP Driver does not use an authentication protocol although it does support the following PAP CHAP Each protocol uses ID password pairs PPP SECRET structure For details ofthe structure see the listing for PPP SECRET in Chapter 8 Data Types 4 2 3 1 PAP PPP Driver either as the client or the server controls PAP with two global variables e PPP PAP LSECRET One of NULL LCP does not let the peer request the PAP protocol Pointer to the ID password pair PPP SECRET to use when we authenticate ourselves to the peer PPP PAP RSECRETS One of NULL LCP does not require that the peer authenticates itself Pointer to a NULL terminated array of all the ID password pairs PPP SECRET to use when authenticating the peer LCP requires that the peer authenticates itself If the peer rejects negotiation of the PAP authentication protocol LCP terminates the link immediately when the link reaches the opened state 4 2 3 2 CHAP PPP Driver controls CHAP with the following global variables e PPP CHAP LNAME Pointer to a NULL terminated string On the server side it is the server s name On the client side it is the client s name PPP CHAP LSECRETS One of NULL LCP does not let the peer request the CHAP protocol Pointer to a NULL terminated array of ID password
191. erence server in pointer to server structure returned by httpd init or httpd_server_init val in pointer to CGI functions table array of HTTPD CGI LINK STRUCT Example HTTPD CGI LINK STRUCT cgi_ln ipstat icmpstat udpstat tcpstat analog rtcdata toggleledl toggleled2 toggleled3 toggleled4 H server initialization k tbl 4 cgi ipstat cgi icmpstat cgi udpstat cgi tcpstat cgi analog data cgi rtc data cgi toggle 1 cgi toggle 1 cgi toggle 1 cgi toggle 1 0 O table termination record HTTPD SET PARAM CGI TBL server cgi Ink tbl Freescale MQX RTCS User s Guide Rev 10 ledl led2 led3 led4 Freescale Semiconductor 165 Function Reference 7 1 57 ICMP stats Gets a pointer to the ICMP statistics Synopsis ICMP STATS PTR ICMP stats void Description Function ICMP stats takes no parameters and returns a pointer to the ICMP statistics that RTCS collects Return Value Pointer to the CMP STATS structure See Also ARP stats ENET get stats ICMP stats inet pton IPIF stats TCP stats UDP stats ICMP STATS Example See ARP stats Freescale MQX RTCS User s Guide Rev 10 166 Freescale Semiconductor Function Reference 7 1 58 IGMP_stats Gets a pointer to the IGMP statistics Synopsis IGMP STATS PTR IGMP stats void Description Function IG
192. erminates an FTP session Synopsis int 32 FTP close pointer handle FILE PTR ctrl_fd Parameters handle in FTP session handle ctrl fd in Device to write control connection responses to Description Function FTP close issues a QUIT command to the FTP server closes the control connection and then frees any resources that were allocated to the FTP session handle Return Value e The FTP response code success e l failure See Also FTPd init Example See FTPd init Freescale MQX RTCS User s Guide Rev 10 138 Freescale Semiconductor 7 1 37 FTP_command Issues a command to the FTP server Synopsis int 32 FTP command pointer handle char ptr command FILE PTR ctrl_fd Parameters handle in FTP session handle command in FTP command ctrl fd in Device to write control connection responses to Description Function FTP command sends a command to the FTP server Return Value The FTP response code success e failure See Also e FTP command data Example See FTPd init Freescale MQX RTCS User s Guide Rev 10 Function Reference Freescale Semiconductor 139 Function Reference 7 1 38 FTP command data Issues a command to the FTP server that requires a data connection Synopsis int 32 FTP command pointer handle char ptr command FILE PTR ctrl fd FILE PTR data fd uint 32 flags P
193. error information The following are included in ST RX DISCARDED ST RX BAD PORT Segments with the destination port zero ST RX BAD CHECKSUM Segments with an invalid checksum ST RX BAD OPTION Segments with invalid options ST RX BAD SOURCE Segments with an invalid source Freescale MQX RTCS User s Guide Rev 10 388 Freescale Semiconductor ST RX SMALL HDR Segments with the header too small ST RX SMALL DGRAM Segments smaller than the header ST RX SMALL PKT Segments larger than the frame ST RX BAD ACK Received ACK for unsent data ST RX BAD DATA Received data outside the window ST RX LATE DATA Received data after close ST RX OPT MSS Segments with the MSS option set ST RX OPT OTHER Segments with other options ST RX DATA Data segments received ST RX DATA DUP Duplicate data received ST RX ACK ACKs received ST RX ACK DUP Duplicate ACKs received ST RX RESET RST segments received ST RX PROBE Window probes received ST RX WINDOW Window updates received Freescale MQX RTCS User s Guide Rev 10 Data Types Freescale Semiconductor 389 Data Types ST RX SYN EXPECTED Expected SYN not received ST RX ACK EXPECTED Expected ACK not received ST RX SYN NOT EXPECTED Received SYN not expected ST RX MULTICASTS Multicast packets ST TX DATA Data segments sent ST TX DATA DUP Data segments retransmitted ST TX ACK ACK only segments sent ST TX AC
194. erver httpd init params Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 155 Function Reference 7 1 48 httpd init This function initializes the HTTP server Synopsis HTTPD STRUCT httpd init Parameters HTTPD PARAMS STRUCT params params in pointer to parameter structure to be used by the HTTP server This should not be NULL Description This is the main HTTP initialization function which should be called before the server is started This function uses the information passed in the parameter structure to allocate internal memory buffers and to initialize internal server and session structures After the HTTP server is initialized by this call some of the server parameters can still be changed using one ofthe HTTP SET xxx calls macros However parameters like port number or number of sessions can not be changed after this call Return Value Pointer to HTTP to server structure See Also e httpd default params e httpd server init Example allocate default values params httpd default params NULL if params change some parameter values params gt root_dir HTTPD ROOT DIR STRUCT root dir params gt index page index html params max ses 1 initialize HTTP server httpd init params Freescale MQX RTCS User s Guide Rev 10 156 Freescale Semiconductor Function Reference 7 1 49 htt
195. es that determine the authentication protocol see Section 4 2 2 Configuring PPP Driver 4 2 1 4 MRU By default PPP Driver does not negotiate the MRU but is prepared to advertise any MRU that is up to 1500 bytes Additionally in accordance with RFC 791 IP PPP Driver accepts from the peer any MRU that is no fewer than 68 bytes 4 2 1 5 PFC By default PFC is FALSE so PPP Driver does not compress the Protocol field If PFC becomes TRUE the driver sends the Protocol field as a single byte whenever its value the protocol number does not exceed OxOOFF That is the most significant byte is not sent if it is zero PPP Driver always tries to negotiate PFC 4 2 2 Configuring PPP Driver PPP Driver uses some global variables whose default values are assigned according to RFC 1661 An application can change the configuration of PPP Driver by assigning its own values to the global variables before it initializes PPP Driver for any link that is before the first time that it calls PPP initialize Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 57 Point to Point Drivers To change From this default Change this global variable Additional stack size needed for PPP Driver 0 _PPPTASK_stacksize Authentication info for CHAP NULL NULL _PPP_CHAP_LNAME _PPP_CHAP_LSECRETS _PPP_CHAP_RSECRETS Authentication info for PAP NULL NULL _PPP_PAP_LSECRET _PPP_PAP_
196. es 4 bytes Destination Source Type Data FCS address address Figure A 1 Ethernet Frame A2 ARP Address Resolution Protocol RFC 826 resolves a logical IP address to a physical ethernet address ARP maintains a local list of IP addresses and their corresponding ethernet addresses in a data structure called the ARP cache When ARP initializes the ARP cache is empty that is it contains no IP to ethernet address pairs When a source host prepares a packet to send to a destination IP address on the local subnet ARP examines its ARP cache to determine whether it already knows the destination ethernet address If ARP does not already know the ethernet address which is the case immediately after ARP initializes ARP broadcasts on the local subnet an ARP request that asks all hosts on the subnet whether they are the destination IP address All the hosts receive the ARP request but only the destination host replies The destination host sends directly to the source host that is it does not use a broadcast message an ARP reply that contains the destination host s ethernet address Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 395 Protocols and Policies When the source host receives the ARP reply ARP places the destination host IP address and ethernet address in the ARP cache ARP includes a timestamp with each entry and deletes the entry after two minutes Hardware type Protocol type Sender hardware addr
197. escale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 171 Function Reference 7 1 62 IPIF_stats Gets a pointer to the IPIF statistics that RTCS collects for the device interface Synopsis IPIF STATS PTR IPIF stats _rtcs if handle rtcs_if handle Parameters rtcs if handle in RTCS interface handle Description Function IPIF stats returns a pointer to the IPIF statistics that RTCS collects for the device interface Return Value Pointer to the PIF STATS structure success e NULL failure rtcs if handle is invalid See Also ARP stats e ENET get stats CMP stats IGMP stats jnet pton e TCP stats e UDP stats IPIF STATS Example See ARP stats Freescale MQX RTCS User s Guide Rev 10 172 Freescale Semiconductor Function Reference 7 1 63 ipcfg init device Initializes the Ehternet device adds network interface and setups the IPCFG context for it Synopsis uint 32 ipcfg init device uint 32 device _enet address mac Parameters device in device identification index mac in Ethernet MAC address Description This function initializes the ethernet device calls ENET initialize internally adds network interface RTCS if add to the RTCS and sets up ipcfg context for the device Return Value e IPCFG OK success RTCSERR IPCFG BUSY RTCSERR IPCFG DEVICE NUMBER RTCSERR IPCFG INIT See Also e ipcfg init interface
198. ess octets 0 3 Sender hardware address octets 4 5 Sender IP octets 0 1 Sender IP octets 2 3 Target hardware address octets 0 1 Target hardware address octets 2 5 Target IP Figure A 2 ARP Datagram In an ethernet frame that contains an ARP datagram the Type field contains 0x806 ARP datagram ARP Data Figure A 3 ARP Datagram in an Ethernet Frame A3 IP Internet Protocol RFC 791 lets applications view multiple interconnected physical networks as one single logical network IP provides an unreliable connectionless datagram transport protocol between hosts in the logical network 0 3 16 24 31 Lc XI Source IP address Destination IP address IP options optional Padding Data Figure A 4 IP Datagram Freescale MQX RTCS User s Guide Rev 10 396 Freescale Semiconductor Protocols and Policies In an ethernet frame that contains an IP datagram the Type field contains 0x800 IP datagram IP Data Figure A 5 IP Datagram in an Ethernet Frame A 4 ICMP IP uses Internet Control Message Protocol RFC 792 to send and receive error and status information 0 8 18 24 31 Type dependent data Figure A 6 ICMP Message In an IP datagram that contains an ICMP message the Protocol field contains one ICMP message ICMP message Ethernet frame Data Figure A 7 ICMP Message in an Ethernet Frame 4 A 5 UDP User Datagram Protocol RFC 768 provides the same unreliab
199. et of application callback functions that RTCS is to call when certain events occur For details see IPCP DATA STRUCT in Chapter 8 Data Types Return Value e RTCS OK success Error code failure See Also PPP initialize e RTCS if add e RTCS if bind IPCP DATA STRUCT Example Initialize PPP and bind to the interface void boot done pointer sem _lwsem post sem int 32 init ppp void FILE PTR pppfile _iopcb handle pppio _ppp handle phandle _rtcs if handle ihandle IPCP DATA STRUCT ipcp data LWSEM STRUCT boot sem pppfile fopen ittya NULL if pppfile NULL return 1 Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 259 Function Reference pppio iopcb ppphdlc init pppfile if pppio NULL return 1 error PPP initialize pppio amp phandle if error return error iopcb open pppio PPP lowerup PPP lowerdown phandle error RTCS if add phandle RTCS IF PPP amp ihandle if error return error _lwsem create amp boot sem 0 memset amp ipcp data 0 sizeof ipcp data ipcp data IP UP boot done ipcp data IP DOWN NULL ipcp data IP PARAM amp boot sem ipcp data ACCEPT LOCAL ADDR FALSE ipcp data ACCEPT REMOTE ADDR FALSE ipcp data LOCAL ADDR PPP LOCADDR ipcp data REMOTE ADDR PPP PEERADDR ipcp data DEFAULT NETMASK TRUE ipcp data DEFAULT ROUTE TRUE
200. etrics 150 152 removing 14 151 logging 14 parameters creation 11 running 11 23 PCBs max 11 protocol stack 9 Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 431 protocols defining 10 setting up overview 10 socket error getting 153 stack size additional 11 statistics Ethernet getting 12 106 structure 224 PPP getting 42 128 task priority 11 RTCS applications DHCP Client 51 DHCP Server 52 DNS Resolver 53 Echo Server 54 EDS Server Winsock 55 FTP Client 55 FTP Server 55 SNMP Agent 56 SNTP Client 57 Telnet Client 57 Telnet Server 57 TFTP Client 57 TFTP Server 58 rtcs h 216 RTCS ERROR STRUCT 252 RTCS IF ENET 154 RTCS IF LOCALHOST 154 RTCS IF PPP 154 RTCS IF STRUCT 253 RTCS protocol table 255 RTCS protocol table 255 RTCS SO IGMP ADD MEMBERSHIP 188 RTCS SO IGMP DROP MEMBERSHIP 189 RTCS SO IGMP GET MEMBERSHIP 189 RTCS SO LINK RX 8021Q PRIO 191 RTCS SO LINK RX 8023 192 RTCS SO LINK TX 8021Q PRIO 194 RTCS SO LINK TX 8023 194 RTCS SO NAT PORTS 191 RTCS SO NAT TIMEOUTS 190 RTCS TASK structure 256 rtcscfg h 19 RTCSCFG CHECK ADDRSIZE 20 RTCSCFG CHECK ERRORS 20 RTCSCFG CHECK MEMORY ALLOCATION ERROR 20 RTCSCFG CHECK VALIDITY 20 RTCSCFG IP DISABLE DIRECTED BROADCAST 21 RTCSCFG LINKOPT 8021Q PRIO 21 RTCSCFG LINKOPT 8023 21 RTCSCFG LOG PCB 21 RTCSCFG LOG SOCKET API 21 rtcsinit c 255 RTCSlite 6 running parameters RTC
201. ev 10 108 Freescale Semiconductor Function Reference 7 1 12 _pppoe server session stats Gets a pointer to statistics on the PPP session Synopsis PPPOE SESSION STATS STRUCT PTR pppoe server session stats _iopeb handle lopcb Parameters iopcb in VO PCB handle Description Function pppoe server session stats provides statistics on the PPP session using the I O PCB handle iopcb Return Value Pointer to a PPPOE SESSION STATS STRUCT structure success Error code failure See Also e PPPOE SESSION STATS STRUCT Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 109 Function Reference 7 1 13 accept Creates a new stream socket to accept incoming connections from the remote endpoint Synopsis uint 32 accept uint 32 socket sockaddr _PTR_ peeraddr uint_16 _PTR_ addrlen Parameters socket in Handle for the parent stream socket peeraddr out Pointer to where to place the remote endpoint identifier addrlen in out When passed in Pointer to the length in bytes of the location peeraddr points to When passed out Full size in bytes of the remote endpoint identifier Description The function accepts incoming connections by creating a new stream socket for the connections The parent socket socket must be in the listening state it remains in the listening state after each new socket is created from it The new socket created by accept i
202. ev 10 264 Freescale Semiconductor Function Reference 7 1 136 RTCS if unbind Unbinds the IP address from the device interface Synopsis uint 32 RTCS if unbind rtcs if handle rtcs if handle ip address address Parameters rtcs if handle in RTCS interface handle address in IP address to unbind Description Function RTCS if unbind unbinds IP address address from the device interface associated with rtcs if handle Parameter rtcs if handle is returned by RTCS if add Return Value RTCS OK success Error code failure See Also RICS if add e RTCS if bind e RTCS if bind BOOTP e RTCS if bind DHCP e RTCS if bind IPCP e RTCS if rebind DHCP Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 265 Function Reference 7 1 137 RTCS load TFTP BIN Downloads the binary file Synopsis uint 32 RTCS load TFTP BIN ip address Server char ptr filename uchar ptr start download address Parameters server in IP address of the TFTP Server filename in Name of the file to download start download address in Address at which to download the file Description This function downloads the binary file from the TFTP Server It is the same as RTCS exec TFTP BIN with the exception that it does not run the file after it downloads the file For information on the values of server and filename see Table 7 1 Return Value RTCS OK success
203. f the variable system sysServices SNMPCFG SYSSERVICES 8 5 12 2 Starting SNMP Agent To start the SNMP Agent server an application calls e MIBI1213 init which installs the standard MIBs that are defined in RFC 1213 This function or any other MIB initialization functions must be called before SNMP init SNMP init with the name of the task that implements the agent the task s priority and its stack size initializes and runs the agent Alternatively the SNMP init with traps function may be called with the same arguments plus a pointer to list of trap recepients When the service is started the application should make the priority of the task lower than the TCP IP task that is make the task s priority 7 8 9 or greater See information on the RTCSTASK priority variable in Section 2 6 Changing RTCS Creation Parameters Note 5 12 3 Communicating with SNMP Clients SNMP Agent communicates with a client on the host network management station the client is not a part of RTCS 5 12 4 Defining Management Information Base MIB The MIB database objects nodes are described with a special syntax definition def file The definition file is processed by the mib2c script which generates set of initialized RTCSMIB_ NODE structures and a bit of infrastructure code The structures contain pointers to parent child and sibling nodes so they effectively implement the MIB tree database in
204. faces 13 155 using BootP 156 using DHCP 158 160 162 166 using IPCP 164 boot files loading BIN format 171 COFF format 172 S Record format 173 loading and running BIN format 14 144 COFF format 14 146 S Record format 14 147 BootP 6 269 performing 13 using to bind an IP address 13 156 BOOTP DATA STRUCT 221 bootstrapping 269 performing 13 Phase 2 performing 14 144 146 147 Broadcast Datagrams protocol 7 Broadcasting Internet Datagrams in the Presence of Subnets 7 BSD 44 23 C call graphs see code paths callback functions DHCP 11 158 160 162 166 Ethernet 154 253 IPCP 11 164 PPP 41 67 154 253 PPP over Ethernet 244 245 246 CCITT 16 271 CCP 6 41 135 CHAP 6 37 38 39 example 39 checksum bypass socket option 187 checksums RTCS bypassing 11 CIDR 6 client DHCP releasing 97 code paths 58 Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 427 code size reducing 255 COFF boot files loading 172 loading and running 14 146 community string SNMPv1 SNMPv2c 56 compile time options configuring RTCS 19 recommended settings 19 configuring RTCS compile time options 19 recommended settings 19 creation parameters 11 running parameters 11 23 connect timeout socket option 187 188 connections establishing for stream sockets 29 accept 80 connect 86 listen 129 creation parameters RTCS 11 D data types for portabi
205. fg bind dhep Example Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 199 Function Reference 7 1 85 ipcfg task create Creates and starts the IPCFG Ethernet link status monitoring task Synopsis uint 32 ipcfg task create uint 32 priority uint 32 task period ms Parameters priority in task priority task period ms in task polling period in milliseconds Description Link status task periodically checks Ethernet link status of each initialized Ethernet device If the link is lost the task automatically unbinds the interface When the link goes on again the task tries to bind the interface to network using information from last successful bind operation If the device was unbound by calling ipcfg unbind the task leaves the interface in unbound state An alternative way to monitor the Ethernet link status without a separate task is to call ipcfg task poll periodically in the user s task Return Value MOX OK success MQX DUPLICATE TASK TEMPLATE INDEX MOX INVALID TASK ID See Also e ipcfg task destroy ipcfg task status e ipcfg task poll Example void main uint 32 param setup network ipcfg task create 8 1000 if ipcfg task stats task block ipcfg task destroy TRUE while 1 time delay 1000 ipcfg task poll Freescale MQX RTCS User s Guide Rev 10 200 Freescale Semiconductor Function Reference
206. ge Handshake Authentication Protocol 1334 used by PPP CIDR Classless Inter Domain Routing 1519 Freescale MQX RTCS User s Guide Rev 10 18 Freescale Semiconductor Table 2 1 RTCS Features continued Protocol e Description RFC policy DHCP Dynamic Host Configuration Protocol 2131 DHCP DHCP Options and BootP vendor extensions 2132 Options DNS Domain Names implementation and 1035 specification Echo Echo protocol 862 EDS Winsock client server Ethernet IEEE 802 3 FTP File Transfer Protocol 959 HDLC High Level Data Link Control protocol ISO 3309 HTTP Hypertext Transport Protocol 2068 ICMP Internet Control Message Protocol 792 IGMP Internet Group Management Protocol 1112 IP Internet Protocol 791 919 922 Broadcasting internet datagrams in the 922 presence of subnets Internet Standard Subnetting Procedure 950 IPCP Internet Protocol Control Protocol used by 1332 PPP IP E A standard for the transmission of IP 894 datagrams over ethernet networks IPIP IP in IP tunneling 1853 LCP Link Control Protocol used by PPP 1661 1570 MD5 RSA Data Security Inc MD5 Message Digest 1321 Algorithm MIB Management Information Base part of 1902 SNMPv2 1907 NAT Network Address Translation Traditional IP Network Address Translator 3022 Traditional NAT IP Network Address Translator NAT 2663 terminology and considerations PAP Password Authent
207. gging call RTCSLOG disable 2 15 Starting Network Address Translation NAT allows sites using private addresses to initiate uni directional outbound access to a host on an external network Network address port translation is supported When NAT is enabled a block of external routable IP addresses is reserved by the NAT router RTCS in this case to represent the private unroutable addresses of the hosts behind the border router A large pool of hosts can share the NAT connection with a small pool of routable addresses When a packet leaves the private network the border router translates the source IP address to an address from the reserved pool and also translates the source transport identifier TCP UDP port or ICMP query ID to a random number of its choosing When responses come back the border router is able to untranslate the random NAT flow identifier map that info back to the original sender IP address and transport identifier of the host on the private network The router translates the destination address and related fields of all inbound packets into the addresses transport IDs and related fields of hosts on the private network To start Network Address Translation the application calls NAT init with the private network address and the subnet mask of the private network For Network Address Translation to begin the global RTCS running parameter P forward must be TRUE Freescale MQX RTCS User s Guide Rev 10
208. gotiate a DNS server address for the peer resolver Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 363 Data Types 8 3 21 IPIF_STATS A pointer to this structure is returned by IPIF_stats typedef struct uint 32 ST RX TOTAL uint 32 ST RX MISSED uint 32 ST RX DISCARDED uint 32 ST RX ERRORS uint 32 ST Te TOTAL uint 32 ST TX MISSED uint 32 ST TX DISCARDED uint 32 ST TX ERRORS RTCS ERROR STRUCT ERR RX RTCS ERROR STRUCT ERR TX uint 32 ST RX OCTETS uint 32 ST RX UNICAST uint 32 ST RX MULTICAST uint 32 ST RX BROADCAST uint 32 ST TX OCTETS uint 32 ST TX UNICAST uint 32 ST TX MULTICAST uint 32 ST TX BROADCAST IPIF STATS PTR IPIF STATS PTR ST RX TOTAL Total number of received packets ST RX MISSED Incoming packets discarded due to lack of resources ST RX DISCARDED Incoming packets discarded for all other reasons ST RX ERRORS Internal errors detected while processing an incoming packet ST TX TOTAL Total number of transmitted packets ST TX MISSED Packets to be sent that were discarded due to lack of resources ST TX DISCARDED Packets to be sent that were discarded for all other reasons ST TX ERRORS Freescale MQX RTCS User s Guide Rev 10 364 Freescale Semiconductor Internal errors detected while trying to send a packet ERR_RX RX error information ERR_TX TX err
209. grated Profiler running on a host computer establishes a connection with the server the server allows the Integrated Profiler to communicate with the EDS task We recommend that you make priority lower than the priority of the RTCS task that is make it a higher number Return Value e RTCS OK success Error code failure Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 135 Function Reference 7 1 34 ENET_get_stats Gets a pointer to the ethernet statistics that RTCS collects for the ethernet interface Synopsis ENET STATS PTR ENET get stats _enet handle PTR handle Parameters handle in Pointer to the Ethernet handle Description The function is not a part of RTCS If you are using MQX the function is available to you and you can use it If you are porting RTCS to another operating system the application must supply the function Return Value Pointer to the ENET STATS structure See Also ICMP stats inet pton IPIF stats RTCS if add TCP stats UDP stats ENET STATS Example ENET STATS PTR enet enet handle ehandle enet ENET get stats printf Nn d Ethernet packets received enet gt ST RX TOTAL Freescale MQX RTCS User s Guide Rev 10 136 Freescale Semiconductor Function Reference 7 1 05 ENET initialize Initializes the interface to the ethernet device Synopsis uint 32 ENET initialize uint 32 devic
210. gy The mode can be Ad Hoc network composed of only one cell and without Access Point or Managed node connects to a network composed of many Access Points with roaming Return Value e ENET OK success e ENETERR INVALID DEVICE Other device specific errors Example define DEMOCFG SECURITY none define DEMOCFG SSID NGZG define DEMOCFG NW MODE managed define DEFAULT DEVICE 1 error RTCS_create ip data ip ENET IPADDR ip data mask ENET IPMASK ip data gateway ENET IPGATEWAY ENET get mac address DEFAULT DEVICE ENET IPADDR enet address error ipcfg init device DEFAULT DEVICE enet address iwcfg set essid DEFAULT DEVICE DEMOCFG SSID iwcfg set sec type DEFAULT DEVICE DEMOCFG SECURITY iwcfg set mode DEFAULT DEVICE DEMOCFG NW MODE error ipcfg bind staticip DEFAULT DEVICE amp ip data Freescale MQX RTCS User s Guide Rev 10 210 Freescale Semiconductor Function Reference 7 1 96 iwcfg get mode Synopsis uint 32 iwcfg get mode uint 32 dev num char ptr mode Parameters dev num in Device identification index mode out Current wifi mode string Description Return current wifi module mode Possible values are managed or adhoc Return Value ENET OK succe
211. har mysecret2 password2 PPP SECRET CHAP secrets sizeof serverl l sizeof mysecret1 1 serverl mysecretl sizeof server2 1 sizeof mysecret2 1 server2 mysecret2 0 0 NULL NULL e _PPP CHAP LNAME myname _PPP CHAP LSECRETS CHAP secrets In this example RTCS is running on host server and there are three users Freescale MQX RTCS User s Guide Rev 10 60 Freescale Semiconductor User Password arcl password1 arc2 password2 arc3 password3 4 2 3 6 PAP Server Side On the server side for PAP authentication initialize the global variables as follows char userl arcl char secretl passwordl char user2 arc2 char secret2 password2 char user3 arc3 char secret3 password3 PPP SECRET secrets sizeof userl 1 sizeof secret1 1 userl secretl sizeof user2 1 sizeof secret2 1 user2 secret2 sizeof user3 1 sizeof secret3 1 user3 secret3 0 0 NULL NULL _PPP_PAP_RSECRETS secrets 4 2 3 7 CHAP Server Side On the server side for CHAP authentication initialize the global variables as follows char myname server char userl arcl char secretl passwordl char user2 arc2 char secret2 password2 char user3 arc3 char secret3 password3 PPP SECRET
212. he connected stream socket buffer out Pointer to the buffer in which to place received data buflen in Size of buffer in bytes flags in Flags to underlying protocols One of the following RTCS MSG PEEK for a UDP socket receives a datagram but does not consume it ignored for stream sockets Zero ignore Description Function recv provides RTCS with a buffer for data incoming on a stream or datagram socket When the flags parameter is RTCS MSG PEEK the same datagram is received the next time recv or recvfrom is called Ifthe function returns RTCS ERROR the application can call RTCS geterror to determine the reason for the error If the peer gracefully closed the connection recv returns RTCS_ERROR rather than zero as BSD 4 4 specifies A subsequent call to RTCS_geterror returns RTCSERR_TCP_CONN_CLOSING NOTE Stream Socket If the receive nowait socket option is TRUE RTCS immediately copies internally buffered data up to buflen bytes into the buffer at buffer and recv returns If the receive wait socket option is TRUE recv blocks until the buffer 1s full or the receive push socket option is satisfied Ifthe receive push socket option is TRUE a received TCP push flag causes recv to return with whatever data has been received If the receive push socket option is FALSE RTCS ignores incoming TCP push flags and recv returns when enough data has been received t
213. he source of the packet Freescale MQX RTCS User s Guide Rev 10 402 Freescale Semiconductor Protocols and Policies When a reply is received for a specific packet the router modifies the packet by setting the destination to be the private host that originally sent the packet For more information about NAT see the following RFCs The IP Network Address Translator NAT RFC 3022 IP Network Address Translator NAT Terminology and Considerations RFC 2663 NOTE When IP security IPsec is being used the contents of IP headers including the source and destination addresses are protected from modification Therefore NAT and IPsec cannot be used together Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 403 Protocols and Policies Freescale MQX RTCS User s Guide Rev 10 404 Freescale Semiconductor Appendix B Internet Protocol Configuration B 1 Shell command ipconfig configures IP ipconfig Shell Command Usage ipconfig lt device gt lt command gt Description Shell command ipconfig displays all current TCP IP network configuration values and refreshes Dynamic Host Configuration Protocol DHCP Used without parameters ipconfig displays the MAC address IP address subnet mask default gateway and DNS for all adapters Used with parameters ipconfig can configure IP internet protocol configuration See list of available commands belo
214. hen initializing the HTTP server 2 16 4 3 HTTPDCFG DEF INDEX PAGE HTTP Server index page filename Default value index htm Override in application when initializing the HTTP server Freescale MQX RTCS User s Guide Rev 10 40 Freescale Semiconductor Setting Up the RTCS 2 16 4 4 HTTPDCFG_DEF_SES CNT Maximal HTTP server session count count of simultaneous evaluated requests Default value 2 Override in application when initializing the HTTP server 2 16 45 HTTPDCFG_DEF_URL_LEN Maximal evaluated URL length Default value 128 Override in application when initializing the HTTP server 2 16 4 66 HTTPDCFG_DEF_AUTH_LEN Maximal length for evaluated authorization string in http request header Default value 16 Override in application when initializing the HTTP server Override in application when initializing the HTTP server 2 16 4 7 HTTPDCFG MAX BYTES TO SEND Maximal send length in step block size Default value 512 2 16 4 8 HTTPDCFG MAX SCRIPT LN Maximal evaluated script line length Default value 16 2 16 4 9 HTTPDCFG RECV BUF LEN Receiving temporary buffer size Default value 32 2 16 4 10 HTTPDCFG MAX HEADER LEN Maximal response header length Default value 256 2 16 4 11 HTTPDCFG SES TO Session timeout Default value 20000ms 2 16 4 12 HTTPCFG TX WINDOW SIZE Maximum transmit packet size 2 16 4 13 HTTPCFG RX WINDOW SIZE Maximum receive packet size Freescale MQX RTCS User
215. hes the network netmask and metric Return Value e RTCS OK success Error code failure See Also e RTCS gate add metric Example error RTCS gate remove metric GATE ADDR INADDR ANY INADDR ANY 42 Freescale MQX RTCS User s Guide Rev 10 246 Freescale Semiconductor Function Reference 7 1 126 RTCS_geterror Gets the reason why the RTCS function returned an error for the socket Synopsis uint 32 RTCS geterror uint 32 socket Parameters socket in Socket handle Description This function does not block Use this function if accept returns RTCS SOCKET ERROR or any of the following functions return RTCS ERROR recv recvfrom send e sendto Return Value e RTCS OK no socket error e Last error code for the socket See Also e accept e recv recvfrom e send sendto Example See accept recv recvfrom send and sendto Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 247 Function Reference 7 1 127 RTCS if add Adds device interface to RTCS Synopsis uint 32 RTCS if add pointer dev_handle RTCS IF STRUCT PTR callback ptr _rtcs if handle PTR r cs if handle Parameters dev handle in Handle from ENET initialize or PPP initialize callback ptr in One of the following Pointer to the callback functions for the device interface RTCS IF ENET Ethernet only uses default callback functi
216. httpd server init af This function initializes the HTTP server task using the default parameters Synopsis HTTPD STRUCT httpd server init af HTTPD ROOT DIR STRUCT root dir const char index page uint 32 af inet family Parameters root dir in pointer to HTTPD ROOT DIR STRUCT which contains web server root directories mapping between web derectories and physical filesystem paths index page in Filename of the default index page relative to root directory af inet family in define IP protocol for this server Http server can support IPv4 or IPv6 protocol af inet family should be AF INET for IPv4 protocol or AF INET6 for IPv6 protocol Description This function is a simple wrapper around httpd default params and httpd init functions Use this call to prepare the HTTP to be started with the default compiled in settings After the HTTP server is initialized by this call some of the server parameters can still be changed using one ofthe HTTP SET xxx calls macros However parameters like port number or number of sessions can not be changed after this call Return Value Pointer to HTTP to server structures or NULL if error See Also e httpd default params e httpd server run e httpd server poll Example a IPv4 protocol HTTPD ROOT DIR STRUCT root dir WM t s Es 0 O table termination record e HTTPD STRUCT server server httpd server init root dir NWngx html
217. ication Protocol used by 1334 PPP Freescale MQX RTCS User s Guide Rev 10 Setting Up the RTCS Freescale Semiconductor 19 Setting Up the RTCS Table 2 1 RTCS Features continued Protocol Qr Description RFC policy ping Implemented with ICMP Echo message 792 PPP Point to Point Protocol 1661 PPP HDLC PPP in HDLC like framing 1662 like framing PPP LCP 1570 Extensions PPPoE PPP over Ethernet 2516 Quote Quote of the Day protocol 865 Reqs Requirements for internet hosts Communication layers 1122 Application and Support protocols 1123 Requirements for IP version 4 routers 1812 RIP Routing Information Protocol 2453 RPC Remote Procedure Call protocol 1057 RTCS loaders S records COFF BIN SMI Structure of Management Information 1155 SNMPv1 Simple Network Management Protocol 1157 version 1 SNMPv1 MIB SNMPv1 Management Information Base 1213 SNMPv2 SNMP version 2 1902 1907 SNMPv2 MIB SNMPv2 Management Information Base 1902 1907 SNMPv3 SNMPv3 2570 2571 2572 2574 2575 SNTP Simple Network Time Protocol 2030 TCP Transmission Control Protocol 793 Telnet Telnet protocol specification 854 TFTP Trivial File Transfer Protocol 1350 UDP User Datagram Protocol 768 XDR External Data Representation protocol 1014 Freescale MQX RTCS User s Guide Rev 10 20 Freescale Semiconductor A ii Set
218. id init ppp session pointer pointer pointer void remove ppp session pointer pointer pointer TASK TEMPLATE STRUCT MOX template list Task number Entry point Stack Pri String Auto 1 ain task 2000 9 Main MOX AUTO START TASK O 0 0 0 0 0 y typedef struct ppp handle PPP HANDLE iopcb handle IO PCB HANDLE uint 32 LOCAL ADDRESS uint 32 REMOTE ADDRESS _rtcs if handle IF HANDLE SERVER APP CFG STRUCT _PTR SERVER APP CFG STRUCT PTR kk tf n ERV _rtcs msggueue t address eil s Endbody TASK Function Name net local ER APP CFG STRUCT GLOBAL APP CFG MAX CONNECTION tatic void PPP session up down Initialize global variables EN ETADDR ET EN APP MSGQ pointer msg RTCS msgqueue trysend amp APP MSGO msg Main task Returned Value void Comments ENDS SSS Sr tase SSeS cm gos Ts SO AA void Main task uint 32 temp Body rtcs if handle ihandle char ptr taskname uint 32 error i address time enet handle ehandle PPPOE SERVER INIT DATA STRUCT PTR init ptr pppoe srv handle srv handle uint 16 pingid 0 uint 32 PingTargetAddr SERVER APP CFG STRUCT PTR app info taskname RTCS error RTCS create Freescale MQX RTCS User s Guide Rev 10 64 Freescale Semiconductor Point to Point Drivers if error printf
219. ide Rev 10 372 Freescale Semiconductor 8 8 27 PPPOE SESSION STATS STRUCT Statistics for the PPP session that is registered with the PPPoE Server typedef struct pppoe session stats struct uint 32 ST RX TOTAL uint 32 ST RX MISSED uint 32 ST RX DISCARDED uint 32 ST RX ERRORS uint 32 ST TX TOTAL uint 32 ST TX MISSED uint 32 ST TX DISCARDED uint 32 ST TX ERRORS uint 32 ST RX UNICAST uint 32 ST RX BROADCAST PPPOE SESSION STATS STRUCT PTR PPPOE SESSION STATS STRUCT PTR ST RX TOTAL Total number of received packets to the session ST RX MISSED Incoming packets discarded due to lack of resources ST RX DISCARDED Incoming packets discarded for all other reasons ST RX ERRORS Internal errors detected while processing an incoming packet ST TX TOTAL Total number of transmitted packets ST TX MISSED Packets to be sent that were discarded due to lack of resources ST TX DISCARDED Packets to be sent that were discarded for all other reasons ST TX ERRORS Internal errors detected while trying to send a packet ST RX UNICAST Unicast packets received ST RX BROADCAST Broadcast packets received Freescale MQX RTCS User s Guide Rev 10 Data Types Freescale Semiconductor 373 Data Types 8 3 28 PPPOEIF_STATS_STRUCT Statistics for the PPP over Ethernet driver layer typedef struct pppoeif stats struct
220. ied priority Default value Change use with getsockopt only returns value in optval Socket type Stream Ethernet Comments Returned information is for the last frame that the socket received Receive Ethernet 802 3 Frames Option name RTCS SO LINK RX 8023 Protocol level SOL LINK Values TRUE last received frame was an 802 3 frame FALSE last received frame was an Ethernet II frame Default value Change use with getsockopt only returns value in optval Socket type Stream Ethernet Comments Returned information is for the last frame that the socket received Receive Nowait Option name OPT_RECEIVE_NOWAIT Protocol level SOL_TCP Values TRUE recv returns immediately regardless of whether there is data to be received FALSE recv waits until there is data to be received Default value FALSE Change Anytime Socket type Stream Comments Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 289 Function Reference Receive Push Option name OPT_RECEIVE_PUSH Protocol level SOL_TCP Values TRUE recv returns immediately if it receives a push flag from the remote endpoint even if the specified receive buffer is not full FALSE recv ignores push flags and returns only when its buffer is full or if the receive timeout
221. ify you have the latest information available refer to http www freescale com maqx The following revision history table summarizes changes contained in this document Revisi Revision o Number Dale Description of Changes Rev 0 01 2009 Initial Release Rev 1 04 2009 Minor formatting updates for MQX 3 2 Rev 2 04 2009 Minor formatting updates for MQX 3 2 1 Rev 3 01 2010 Updated for MQX 3 5 Description of setsockopt call changed Rev 4 07 2010 Changing RTCS Creation Parameters section updated MQX Embedded gt Freescale MQX Reva Seem Description of RTCS Logging updated IWCFG description added IPCFG description updated Rev 6 04 2011 Examples and features not supported in the current MQX release were labeled HTTP Server chapter updated Description of ENET initialize function parameters updated HR 12200 Example Using PPP Driver section updated Rev 8 06 2012 Several typos corrected in chapters 3 2 7 1 111 example 2 16 2 33 2 16 2 35 Rev 9 10 2012 Configuration Options and Default Settings chapter updated by new options setsockopt chapter updated by new RTCS SO IP TX TOS option Rev 10 11 2012 Updated by IPv6 related description Freescale and the Freescale logo are trademarks of Freescale Semiconductor Inc O Freescale Semiconductor Inc 2008 2012 All rights reserved Freescale MQX RTCS User s Guide Rev 10 Freescale Semicondu
222. ils Depending on the state of the remote endpoint connect fails immediately or after the time that the connect timeout socket option specifies If the remote endpoint accepts the connection the application uses the original socket handle for all its communication with that remote endpoint and RTCS maintains the connection until either or both endpoints close the connection 3 24 Getting Stream Socket Names After an application establishes a stream socket connection it can get the identifiers for the local endpoint by calling getsockname and for the remote endpoint by calling getpeername 3 25 Sending Stream Data An application sends data on a stream socket by calling send When the function returns depends on the values of the send nowait OPT SEND NOWAIT socket option An application can change the value by calling setsockopt Send nowait send returns when non blocking I O FALSE default TCP has buffered all data but not necessarily sent it TRUE Immediately the result is a filled or partially filled buffer Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 49 Using Sockets 3 26 Receiving Stream Data An application receives data on a stream socket by calling recv The application passes the function a buffer into which RTCS places the incoming data When the function returns depends on the values of the receive nowait OPT RECEIVE NOWAIT and receive
223. in addr s addr 24 amp OxFF raddr sin addr s addr 16 amp OxFF raddr sin addr s addr gt gt 8 amp OxFF raddr sin addr s addr amp OxFF raddr sin port continue Send back a quote sendto sock Quotes index strlen Quotes index 1 0 amp raddr rlen index if Quotes index NULL index 0 Freescale MQX RTCS User s Guide Rev 10 54 Freescale Semiconductor Chapter 4 Point to Point Drivers 4 1 Before You Begin This chapter describes how to set up and use the following point to point drivers e PPP Driver e PPP over Ethernet Driver For information about See Data types mentioned in this Chapter 8 Data Types chapter MQX MQX User s Guide MQX Reference Protocols Appendix A Protocols and Policies Prototypes for functions Chapter 7 Function Reference mentioned in this chapter Setting up RTCS Chapter 2 Setting Up the RTCS Using RTCS and sockets Chapter 3 Using Sockets 4 2 PPP and PPP Driver PPP Driver conforms to RFC 1661 which is a standard protocol for transporting multi protocol datagrams over point to point links As such PPP Driver supplies A method to encapsulate multi protocol datagrams e HDLC like framing for asynchronous serial devices Link Control Protocol LCP to establish configure and test the data link connection One network control protocol IPCP to establish and configure IP 4
224. in the fromaddr buffer or if the provided buffer was too small socket address was truncated the length before truncation Description If a remote endpoint has been specified with connect only datagrams from that source will be received When the flags parameter is RTCS MSG PEEK the same datagram is received the next time recv or recvfrom is called If fromlen is NULL the socket address is not written to fromaddr If fromaddr is NULL and the value of fromlen 1s not NULL the result is unspecified If the function returns RTCS ERROR the application can call RTCS geterror to determine the reason for the error This function blocks until data is available or an error occurs Return Value Number of bytes received success e RTCS ERROR failure See Also e bind e RTCS geterror e sendto Freescale MQX RTCS User s Guide Rev 10 232 Freescale Semiconductor socket Example Receive up to 500 bytes of data uint_32 handle sockaddr_in remote sin uint_32 count char my buffer 500 uint 16 remote len sizeof remote sin count recvfrom handle my buffer 500 0 struct sockaddr amp remote len if count RTCS ERROR printf nrecvfrom failed with error 1x RTCS geterror handle else printf nReceived ld bytes of data count Freescale MQX RTCS User s Guide Rev 10 Function Reference amp remote sin Freescale Semiconductor
225. ing to connect n _lwsem wait amp ppp sem block the task until connection printf AnConnection established with the server n printf AnMy IP address 1x IPCP get local addr ihandle PingTargetAddr IPCP get peer addr ihandle qe D while TRUE time 5000 5 seconds error RTCS ping PingTargetAddr amp time pingid if error RTCSERR ICMP ECHO TIMEOUT printf Request timed out n itt if 1 gt 10 break Endif else if error printf Error 0x 04X n error else printf Reply from 0x X time ldms n PingTargetAddr time if time lt 1000 time delay 1000 time Endif Endif Endwhile _iopcb close pio printf AnClient connection closed n _task block Endbody Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 69 Point to Point Drivers Freescale MQX RTCS User s Guide Rev 10 70 Freescale Semiconductor Chapter 5 RTCS Applications 5 1 Before You Begin This chapter describes RTCS applications that implement servers and clients for the application layer protocols that RTCS supports For information about See Data types mentioned in this Chapter 8 Data Types chapter MQX MQX User s Guide MQX Reference Protocols Section Appendix A Protocols and Policies Prototypes for functions Chapter 7 Function Reference mentioned in this chapter
226. int 32 depends on the compiler u char uchar rpctypes h u int uint 32 rpctypes h u long uint 32 rpctypes h u short uint 16 rpctypes h Function Definition Fields Freescale MQX RTCS User s Guide Rev 10 330 Freescale Semiconductor Data Types 8 3 1 iopcb handle iopcb table A variable of iopcb handle structure is an input parameter to PPP initialize typedef struct iopcb table uint 32 CODE PTR OPEN struct iopcb table PTR void CODE PTR pointer void CODE PTR pointer pointer uint 32 CODE PTR CLOSE struct iopcb table PTR PCB PTR CODE PTR READ struct iopcb table PTR uint 32 void CODE PTR WRITE struct iopcb table PTR PCB PTR uint 32 uint 32 CODE PTR IOCTL struct iopcb table PTR uint 32 pointer PTR iopcb handle OPEN Called by PPP Driver to open a link First parameter pointer to an I O handle Second parameter pointer to a function that PPP Driver uses to put the link down Third parameter pointer to a function that PPP Driver uses to put the link up e Fourth parameter the parameter for the up and down functions Returns a status code CLOSE Called by PPP Driver to close a link and free memory e Parameter pointer to an I O handle Returns a status code READ Called by PPP Driver to receive data First parameter pointe
227. int connection over ethernet MQX The RTOS that RTCS uses MQX is an RTOS for single processor multi processor and distributed processor embedded real time applications RTCS A real time embedded internet stack procedure See remote procedure program See remote program protocol family A collection of transport protocols for sockets RTCS supports one PF INET protocol family using IP addresses See also address family Protocol Field Compression See PFC push The push flag which forces data delivery through a stream socket Freescale MQX RTCS User s Guide Rev 10 422 Freescale Semiconductor Q Quote Protocol Quote of the Day Protocol R ready queue MQX maintains a linked list of ready queues one ready queue for each task priority Each ready queue holds tasks that have the specific priority and that are in the ready state To distinguish it from other ready queues the ready queue that a task 1s in 1s referred to as the task s ready queue ready task A task that is on the ready queue for its priority remote The non local endpoint or part of the endpoint of a stream socket See also ocal peer remote procedure An application makes a remote procedure call by calling clnt_call Remote Procedure Call See RPC remote program A collection of remote procedures Reguest for Comments See RFC RFC Reguest for Comments The Internet Standards Committee documentation for protocol sta
228. ip address destination uint 32 poll Parameters name in Name of the SNTP Client task priority in Priority of SNTP Client task we recommend that you make the priority lower than the priority of the RTCS task that is make it a higher number stacksize in Stack size for the SNTP Client task destination in Where SNTP time requests are sent One of the following IP address of the time server unicast mode A local broadcast address or multicast group anycast mode poll in Time to wait between time updates must be between one and 4294967 seconds Description The function starts the SNTP Client task that will first update the local time and then wait for a number of seconds as specified by poll Once this time has expired the SNTP Client repeats the same cycle The local time is set in UTC coordinated universal time The SNTP Client task works in unicast or anycast mode Return Value e RTCS OK success e RTCSERR INVALID PARAMETER failure resulting from either destination not being specified or poll is out of range Specific error code failure resulting from socket and bind calls See Also e socket e bind e SNTP oneshot Example uint 32 error Start the SNTP Client task with the following settings Task Name SNTP Client Priority 7 Stacksize 1000 Freescale MQX RTCS User s Guide Rev 10 314 Freescale Semiconductor F
229. ired state Returns the target IPCFG state for a given Etherent device Synopsis IPCFG STATE ipcfg get desired state uint 32 device Parameters device in device identification Description This function returns the target state the user requires to reach with the given Ethernet device Return Value The desired IPCFG status enum IPCFG_STATE value One of IPCFG STATE UNBOUND IPCFG STATE STATIC IP e IPCFG STATE DHCP IP IPCFG STATE AUTO IP IPCFG STATE DHCPAUTO IP IPCFG STATE BOOT See Also e ipcfg get state string e ipcfg get state Freescale MQX RTCS User s Guide Rev 10 190 Freescale Semiconductor 7 1 76 ipcfg get link active Returns immediate Ethernet link state Synopsis boolean ipcfg get link active uint 32 device Parameters device in device identification Description This function returns the immediate Etherenet link status of a given device Return Value TRUE if link active FALSE otherwise See Also e ipcfg get state string e ipcfg get state e ipcig get desired state Freescale MQX RTCS User s Guide Rev 10 Function Reference Freescale Semiconductor AN Function Reference 7 1 77 ipcfg get dns ip Returns the n th DNS IP address from the registerred DNS list Synopsis ip address ipcfg get dns ip uint 32 device uint 32 n Parameters device in device identification n in DNS IP address inde
230. is HTTPD PARAMS STRUCT httpd default params HTTPD PARAMS STRUCT params Parameters params in pointer to parameter structure which will be set to default values If NULL the strucuture is allocated dynamically Description This function prepares HTTP server parameter structure and sets all its members to default values If params argument is NULL the function allocates the parameter structure dynamically Default parameter values are defined as constants in internal HTTP header files and can be overriden by user config h user configuration file This function should be called if a HTTP server is to be run with other than default parameters compiled in during RTCS and HTTP build The parameters and structure returned by this function may be further modified before it is passed to httpd init function Return Value Pointer to HTTP parameters structure If a valid pointer is passed to the function in params argument the returned pointer is equal to this value If NULL is passed as params argument this function returns pointer to a newly allocated memory containing the initialized structure See Also e httpd init e httpd server init Example allocate default values params httpd default params NULL if params change some parameter values params gt root_dir HTTPD ROOT DIR STRUCT root dir params gt index page index html params max ses 1 initialize HTTP s
231. is not in any group The application can change the following socket options for the socket IGMP add membership IGMP drop membership send nowait e checksum bypass For information about the options see the listing for setsockopt in Chapter 7 Function Reference For information about how to change the default behavior so that RTCS does not use IGMP see Section 2 5 Defining RTCS Protocols Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 47 Using Sockets 3 19 Transferring Datagram Data An application transfers data by making calls to sendto or send and recvfrom or recv With each call RTCS either sends or receives one UDP datagram which contains up to 65 507 bytes of data If an application specifies more data the functions return an error The functions send and sendto return when the data is passed to the ethernet interface The functions recv and recvfrom return when the socket port receives the packet or immediately if a queued packet is already at the port The receive buffer should be at least as large as the largest datagram that the application expects to receive If a packet overruns the receive buffer RTCS truncates the packet and discards the truncated data 3 19 1 Buffering By default send and sendto do not buffer outgoing data This behavior can be changed by using either the OPT SEND NOWAIT socket option or the RTCS MSG NONBLOCK send fl
232. iseconds to wait for activity Zero waits indefinitely does not block Description If timeout is not 1 the function blocks until activity is detected on at least one of the sockets in the set For a description of what constitutes activity see RTCS selectall Return Value Socket handle activity was detected Zero timeout expired e RTCS SOCKET ERROR error See Also e RTCS selectall Example Echo UDP data that is received on ports 2010 2011 and 2012 int 32 socklist 3 sockaddr in local sin uint 32 result memset char amp local sin 0 sizeof local sin local sin sin family AF INET local sin sin addr s addr INADDR ANY local sin sin port 2010 socklist 0 socket AF INET SOCK DGRAM 0 result bind socklist 0 struct sockaddr amp local sin sizeof sockaddr in local sin sin port 2011 socklist 1 socket AF INET SOCK DGRAM 0 Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 273 Function Reference result bind socklist 1 struct sockaddr amp local sin sizeof sockaddr in local sin sin port 2012 socklist 2 socket AF INET SOCK DGRAM 0 result bind socklist 2 struct sockaddr amp local sin sizeof sockaddr in while TRUE sock RTCS selectset socklist 3 0 ll rlen sizeof raddr length recvfrom sock buffer BUFFER SIZE 0 struct sockaddr amp raddr amp rlen sendto sock
233. itiation packet in the Discovery process of PPP over Ethernet PADO packet Active Discovery Offer packet in the Discovery process of PPP over Ethernet PADR packet Active Discovery Request packet in the Discovery process of PPP over Ethernet PADS packet Active Discovery Session confirmation packet in the Discovery process of PPP over Ethernet PADT packet Active Discovery Terminate packet in the Discovery process of PPP over Ethernet PAP Password Authentication Protocol One of the authentication protocols that PPP Driver supports See also CHAP passive open The sequence of events that occurs when an application entity informs TCP that it is willing to accept connections Password Authentication Protocol See PAP payload Data portion in an IP datagram PCB Packet Control Block which RTCS uses to hold a packet peer The non local end of a PPP link See also ocal remote PFC Protocol Field Compression One of the LCP configuration options for PPP Driver that you cannot change PF INET Protocol family using IP addresses It is the one protocol family that RTCS supports for sockets See also AF INET physical address See address physical layer That portion of the OSI model that is responsible for the electromechanical interface to the communications media Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 421 ping A program that tests IP level connectivity from one IP address to ano
234. ived arp gt ST RX TOTAL Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 113 Function Reference 7 1 15 bind Binds the local address to the socket Synopsis uint 32 bina uint 32 socket sockaddr PTR localaddr uint 16 addrlen Parameters socket in Socket handle for the socket to bind localaddr in Pointer to the local endpoint identifier to which to bind socket see description addrlen in Length in bytes of what ocaladdr points to Description The following ocaladdr input values are required sockaddr y A field Required input value sin_family AF_INET sin_port One of Local port number for the socket Zero to determine the port number that RTCS chooses call getsockname sin_addr One of IP address that was previously bound with a call to one of the RTCS if bind functions INADDR ANY sockaddr field Required input value sin6 family AF INET6 sin6 port One of Local port number for the socket Zero to determine the port number that RTCS chooses call getsockname sin6_addr IPv6 address sin6_scope_id Scope zone index Usually TCP IP servers bind to INADDR_ANY so that one instance of the server can service all IP addresses This function blocks but RTCS immediately services the command and is replied to by the socket layer Freescale MQX RTCS User s Guide Rev
235. kaga e a e pE ai apei de Fs EE a ie dd 244 N24R GS un i NR aa inte di td a 245 125RTCS_gate_remove_metric ic ca i setarea ei ot de ae mire dd es A A ee e ea 246 JEDRTOS USloHDI ct cccnend sua SG oro e aa weed 247 127 RICSA 88d corrcar ia rad es didus iasa FE 248 EH LEN DINA essct soi ara aan iei a AAA E AA oe 249 J29RTCS I bind BOOTP see ctre manat ae e ex ae ace seen titi n ni E Da ae er 250 BORIS SUE DING DMG cobrarse rr AA 252 ASIRIGS Wd bind DHCP aged otro rar tepi hU a eo 254 IS2RTOS I bind DHCP MMCO s2ccccscucseh DRE ueu dem daia a 257 AS E A 259 134RTCS_if_rebind__DHCP 2435351 ett pa wd deus Scd bee veda Raw dei ai dics 261 J9SRTCS if PONV a ict chee NO K O Y U ok ioi fe a S RR e inire e dia 264 Esc pecmo p np ecc 265 di Too loud TPI BING 59 ER ca ae ee EA ERE WE REA Ed UE pP RE d ERR Rae S 266 AGBRTOS Ioan TFTF COPE scsi dieras e hc em 267 ISIRTOS load TFTP SHEC sei ea eee deep AO A I ata aaa aa ai SES 268 SOROS PI NT dea e p Ed ded tat d dea ai n ar i VENISSE rar 269 141ATGS_ request DACP Inform coco eee mm ae AG erm he YA 270 RATOS Selec ue ias die kd ninti AA v bre ien did AF FNAN 2n 143RTCS_selectset ocres 273 IMARTESLOS disablal 5 22 25 a Gu we rai 275 J45HTOSLOG enablal 54377 A RD mm meh 276 A HA dai dd P ETE arene is aa de ai d rad 277 a y NI NBA Pas O 280 NOISE AA iq Eod qat ae data res dd i a la ditai laic dal 282 IAN e ce e ea e ae ri dea do ie Borcea ie ei de ee da
236. ket Synopsis uint 32 shutdown uint 32 socket uint 16 how Parameters socket in Handle of the socket to shut down how in One of the following see description FLAG CLOSE TX FLAG ABORT CONNECTION Description Note that after calling shutdown the application can no longer use socket The shutdown blocks but the command is processed and returns immediately Type of socket Value of how Action Datagram Ignored e Shuts down socket immediately Calls to recvfrom return immediately Discards queued incoming packets Unconnected Ignored Shuts down socket immediately stream Connected FLAG CLOSE TX e Gracefully shuts down socket ensuring that all sent data is acknowledged Calls to send and recv return immediately If RTCS is originating the disconnection it maintains the internal socket context for four minutes twice the maximum TCP segment lifetime after the remote endpoint closes the connection stream FLAG ABORT CONNECTION Immediately discards the internal socket context Sends a TCP reset packet to the remote endpoint Calls to send and recv return immediately Return Value RTCS OK e Specific error code Freescale MQX RTCS User s Guide Rev 10 298 Freescale Semiconductor Function Reference See Also socket Example uint 32 handle uint 32 status status shutdown handle 0 if status RTCS OK
237. ld reffer the the udpEntry as their parent udpEntry udpTable 1 SEQUENCE not accessible mandatory udpAddr udpPort udpAddr udpEntry 1 IpAddress read only mandatory udpPort udpEntry 2 INTEGER read only mandatory Special Lines Comment lines Lines that begin with and have text on the same line are treated as comments by the code generation script This is a comment Type definition lines Line that begins with defines type based on an existing one new type existing type Separator line A line that consists only of two percent signs 22 and separates the object definition section from the verbatim C code section The code generator script copies all lines following the separator line to the output C source file 5 12 4 2 MIB Definition File Verbatim C Code The C code generated by the script references other variables and functions that must be provided by user Such a user code may be placed anywhere in the application but it may be a good idea to keep it in the same file with the MIB definition lines Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 83 RTCS Applications The following table summarizes what user code is needed for different kinds of MIB objects MIB Object User C Code Required Root object in the definition file A call to RTCSMIB mib add amp MIBNODE objectname registers the one without parent defined in the the object with the SNM
238. le connectionless datagram transport protocol as IP In addition UDP adds to IP the concept of a source and a destination port which lets multiple applications on source and destination hosts have independent communication paths That is an IP communication path is defined by the source IP address and the destination IP address A UDP communication path is defined by the source port on the source host and the destination port on the destination host Therefore with UDP it is possible to have multiple independent communication paths between a source host and a destination host Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 397 Protocols and Policies 16 24 31 UDP destination port UDP checksum Figure A 8 UDP Datagram In an IP datagram that contains a UDP datagram the Protocol field contains 17 UDP datagram UDP datagram Ethernet frame Data Figure A 9 UDP Datagram in an Ethernet Frame A 6 TCP Transmission Control Protocol RFC 793 provides a reliable stream oriented transport protocol TCP like UDP incorporates the concept of source and destination ports However TCP applications deal with connections not endpoints With UDP any endpoint IP address and port number can communicate with any other endpoint With TCP before communication is possible source and destination endpoints must first define a connection TCP differs from UDP in that TCP is reliable Stream oriented
239. len if status RTCS OK printf inError getsockname failed with error code 1x status else printf AnLocal address family is x local sin sin family printf inLocal port is d local sin sin port printf inLocal IP address is 1x local sin sin addr s addr Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 153 Function Reference 7 1 46 getsockopt Gets the value of the socket option Synopsis uint 32 getsockopt uint 32 socket int 32 level uint 32 optname pointer optval uint 32 PTR optlen Parameters socket in Socket handle level in Protocol level at which the option resides optname in Option name see description optval in out Pointer to the option value optlen in out When passed in Size of optval in bytes When passed out Full size in bytes of the option value Description An application can get all socket options for all protocol levels For a complete description of socket options and protocol levels see setsockopt This function blocks but the command is immediately serviced and replied to Return Value e RTCS_OK success Specific error code failure See Also e setsockopt Freescale MQX RTCS User s Guide Rev 10 154 Freescale Semiconductor Function Reference 7 1 47 httpd default params Initializes the HTTP server parameter structure to default values Synops
240. lication see rtcs examples shell 4 3 PPP over Ethernet Driver PPP over Ethernet Driver conforms to RFC 2516 which is a standard protocol for building PPP sessions and encapsulating PPP packets over the ethernet PPPoE is not supported by this MQX release and will be added in the future MQX Note i versions Freescale MQX RTCS User s Guide Rev 10 62 Freescale Semiconductor 4 3 1 Point to Point Drivers Setting Up PPP over Ethernet Driver 4 3 1 1 On the Client Side On the client side take these general steps to set up and use PPP over Ethernet PPPoE Client Initialize an ethernet driver by calling ENET _initialize which returns an ethernet handle Ina PPPOE CLIENT INIT DATA STRUCT initialize the EHANDLE field with the ethernet handle Initialize PPPoE Client by calling iopcb pppoe client init with the PPPOE CLIENT INIT DATA STRUCT to get an I O PCB handle Initialize PPP Driver by calling PPP initialize with the I O PCB handle to get a PPP handle Continue as for PPP Driver 4 3 1 2 On the Server Side On the server side take these general steps to set up and use PPPoE Server Initialize an ethernet driver by calling ENET initialize which returns an ethernet handle Initialize PPPOE SERVER INIT DATA STRUCT and provide callback functions to be referenced through the SESSION UP SESSION DOWN and AC NAME fields see Section 4 3 2 Examples Using PPP over Ethe
241. lity 215 datagram sockets about 24 comparison with stream sockets 24 data receiving 28 138 sending 28 184 options getting 124 setting 27 186 shutting down 28 using 27 debugging embedded 55 debugging over Winsock connection 55 device interfaces adding to RTCS 13 154 binding to IP addresses 13 155 using BootP 156 using DHCP 158 160 162 166 using IPCP 164 initializing 12 Ethernet 12 107 point to point 12 PPP 41 135 removing from RTCS 13 169 unbinding IP addresses 13 170 DHCP 6 callback functions 11 158 160 162 166 Client 51 example 98 158 160 162 167 releasing 97 options adding 16 bit quantity 91 32 bit quantity 92 8 bit quantity 93 IP address 89 IP address list 90 string 94 variable length quantity 95 options searching for 88 96 performing 13 Server 52 adding block of IP addresses 100 information 175 starting 98 using to bind an IP address 13 158 160 162 166 DHCP Options and BootP Vendor Extensions 6 DHCP DATA STRUCT 222 DHCPSRV DATA STRUCT 223 dhshosts c 54 directory structure RTCS 61 DNS 7 Client 53 services 54 starting 103 host from IP address getting 117 host from name getting 118 DNS Resolver 53 DNS server 53 DNS Local network name 54 DNS Local server name 54 document conventions 3 DoS attacks Smurf reducing risk of 21 E Echo protocol 7 Server 54 starting 104 EDS Server Winsock opening connection to
242. lue Change use with getsockopt only returns value in optval Socket type Datagram or stream Comments Gets the TTL time to live field of incoming packets Returned information is for the last frame that the socket received Type of Service RX Option name RTCS SO IP RX TOS Protocol level SOL IP Values Default value Freescale MQX RTCS User s Guide Rev 10 294 Freescale Semiconductor Function Reference Change use with getsockopt only returns value in optval Socket type Datagram or stream Comments Returns the TOS type of service field of incoming packets Returned information is for the last frame that the socket received Type of Service TX Option name RTCS SO IP TX TOS Protocol level SOL IP Values uchar Default value 0 Change Anytime Socket type Datagram or stream Comments Sets or gets the IPv4 TOS type of service field of outgoing packets Time to Live TX Option name RTCS SO IP TX TTL Protocol level SOL IP Values TTL field of the IP header in outgoing datagrams Default value 64 Change Anytime Socket type Datagram or stream Comments Sets or gets the TTL time to live field of outgoing packets Local Address Option name RTCS SO IP LOCAL ADDR Protocol level SOL IP Values Default valu
243. mber Return Value TRUE if successfull MAC address filled otherwise FALSE Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 187 Function Reference 7 1 73 ipcfg get state Returns the IPCFG state for a given Etherent device Synopsis IPCFG STATE ipcfg get state uint 32 device Parameters device in device identification Description This function returns an immediate state of Ethernet device as it is evaluated by the IPCFG engine Return Value Actual IPCFG status enum IPCFG_STATE value One of PCFG STATE INIT PCFG STATE UNBOUND PCFG STATE BUSY PCFG STATE STATIC IP PCFG STATE DHCP IP PCFG STATE AUTO IP PCFG STATE DHCPAUTO IP PCFG STATE BOOT Hi H HH HH H H See Also e ipcfg get state string e ipcfg get desired state Example Freescale MQX RTCS User s Guide Rev 10 188 Freescale Semiconductor 7 1 74 ipcfg get state string Converts IPCFG status value to string Synopsis const char ptr ipcfg get state string IPCFG STATE state Parameters state in status 1dentification Description This function may be used to display the IPCFG status value in text messages Return Value Pointer to status string or NULL See Also e ipcfg get state e ipcfg get desired state Freescale MQX RTCS User s Guide Rev 10 Function Reference Freescale Semiconductor 189 Function Reference 7 1 75 ipcfg get des
244. ms GET TYPE PARAM type casting Description RTCSMIB_NODETYPE_ int_32 Constant signed integer supplied INT_CONST directly as the PARAM value RTCSMIB_NODETYPE_ int_32 Pointer to signed integer value INT_PTR RTCSMIB_NODETYPE_ INT FN RTCSMIB INT FN PTR function pointer int 32 function pointer Pointer to function that takes an instance pointer void returning the signed int 32 value RTCSMIB NODETYPE uint 32 Constant unsigned integer UINT CONST supplied directly as the PARAM value RTCSMIB NODETYPE uint 32 Pointer to unsigned integer value UINT PTR RTCSMIB NODETYPE UINT FN RTCSMIB UINT FN PTR function pointer uint 32 function pointer Pointer to function that takes an instance pointer void returning the unsigned uint 32 value NULL terminated OCTET STRING whose value SNMP agent computes when SNMP manager performs GET RTCSMIB NODETYPE uchar ptr PARAM points to C string directly DISPSTR FN RTCSMIB NODETYPE RTCSMIB UINT FN PTR Pointer to function that takes an DISPSTR FN instance pointer void returning function pointer uchar ptr function pointer the C string pointer OCTET STRING whose value SNMP agent computes when SNMP manager performs GET RTCSMIB NODETYPE OCTSTR FN RTCSMIB OCTSTR FN PTR function pointer uchar ptr function pointer uint 32 PTR Pointer to function that takes an instance pointer void returning addres
245. n Reference 7 1 68 ipcfg bind staticip Binds Ethernet device to network using constant static IP address information Synopsis uint 32 ipcfg bind staticip uint 32 device IPCFG IP ADDRESS DATA PTR static ip data Parameters device in device identification static ip data in pointer to ip mask and gateway structure Description This function tries to bind device to network using given IP address information If the address is already used an error is returned This is blocking function i e doesn t return until the process is finished or error occurs Any failure during bind leaves the network interface in unbound state Return Value e IPCFG OK success RTCSERR IPCFG BUSY RTCSERR IPCFG DEVICE NUMBER RTCSERR IPCFG INIT RTCSERR IPCFG BIND See Also ipcfg unbind Example See ipcfg init device Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 183 Function Reference 7 1 69 ipcfg_get_device_number Returns the Ethernet device number for given RTCS interface Synopsis uint 32 ipcfg get device number rtcs if handle ihandle Parameters ihandle in interface handle Description Simple function returning the Ethernet device number by giving an RTCS interface handle Return Value Device number if successful otherwise 1 See Also e ipcfg get ihandle Freescale MQX RTCS User s Guide Rev 10 184 Freescale Semiconductor 7 1
246. n previous sections RTCS create 2 Initialize network device using ipcfg init device 3 Initialize wifi device using followed commnads iwcfg set essid iwcfg set passphrase iwcfg set wep key iwcfg set sec type iwcfe set mode 4 Use one of the ipcfg bind xxx functions to bind the interface to an IP address mask and gateway 5 12 SNMP Agent The Simple Network Management Protocol SNMP is used to manage TCP IP based internet objects Objects such as hosts gateways and terminal servers that have an SNMP agent can perform network management functions in response to requests from network management stations The Freescale MQX SNMPvl Agent conforms to the following RFCs e RFC1155 e RFC 1157 e RFC 1212 e RFC 1213 The Freescale MQX SNMPv2c Agent is based on the following RFCs e RFC 1905 e RFC 1906 Freescale MQX RTCS User s Guide Rev 10 80 Freescale Semiconductor RTCS Applications 5 12 1 Configuring SNMP Agent SNMP Agent uses several constants defined in snmpcfg h Those values may be overridden in user config h Constant Default value Community strings that SNMPv1 and SNMPv2c use SNMPCFG COMMUNITY LIST public Size of the static buffer for receiving responses and the SNMPCFG BUFFER SIZE 512 static buffer for generating responses RFCs 1157 and 1906 require it to be at least 484 bytes Value of the variable system sysDescr SNMPCFG SYSDESCR RTCS version 3 0 Value o
247. nction that can parse extra tags with PADO packets If you set the field to NULL it is ignored PARSE PADS TAGS EXTRA Callback function that can parse extra tags with PADS packets If you set the field to NULL it is ignored Freescale MQX RTCS User s Guide Rev 10 370 Freescale Semiconductor Data Types 8 3 26 PPPOE_SERVER_INIT_DATA_STRUCT PPPoE Server parameter configuration structure typedef struct pppoe server init data struct char ptr SERVICE NAME char ptr AC NAME uint 32 SERVER TASK PRIORITY uint 32 SERVER TASK STACK uint 32 ECHO TIMEOUT uint 32 ECHO MAX RETRY void CODE PTR SESSION UP pointer pointer pointer void CODE PTR SESSION DOWN pointer pointer pointer pointer PARAM uint 32 CODE PTR_ SEND PADO TAGS EXTRA uchar ptr uint 32 CODE PTR SEND PADS TAGS EXTRA uchar ptr boolean CODE PTR PARSE PADI TAGS EXTRA pointer boolean CODE PTR_ PARSE PADR TAGS EXTRA pointer PPPOE SERVER INIT DATA STRUCT PTR PPPOE SERVER INIT DATA STRUCT PTR SERVICE NAME Pointer to the service name to open for the session If you set the field to NULL it is ignored AC NAME Pointer to the access concentrator name SERVER TASK PRIORITY Task priority for the PPPoE Server task If you set the field to zero pppoe server init sets it to the default value six SE
248. nd option DHCPSRV ippool add DHCP option addr DHCP option addrlist DHCP option int8 DHCP option int16 DHCP option int32 DHCP option variable Example See DHCPSRV init Freescale MQX RTCS User s Guide Rev 10 124 Freescale Semiconductor Function Reference 7 1 24 DHCP_option_variable Adds a variable length option to a list of DHCP options for DHCP Server Synopsis uint 32 DHCP option variable uchar ptr PTR_ optptr uint_32 _PTR_ optlen uchar opttype uchar PTR optdata uint 32 datalen Parameters optptr in out Pointer to the option list optlen in out Pointer to the number of bytes remaining in the option list Passed in before optval is added Passed out after optval is added opttype in Option type to add to the list see RFC 2132 optdata in Sequence of bytes to add datalen in Number of bytes optdata points to Description Function DHCP option variable adds a variable length option to a list of DHCP options for DHCP Server Use this function to create the optptr buffer that you pass to DHCPSRV ippool add and RTCS if bind DHCP Return Value TRUE success FALSE failure See Also DHCPCLNT find option e DHCPSRV ippool add e DHCP option addr e DHCP option addrlist e DHCP option int8 e DHCP option int16 e DHCP option int32 e DHCP option string e RTCS if bind DHCP Example See RTCS if bind DHCP
249. ndards RIP Routing Information Protocol RTCS supports RIPv2 and interoperates with RIPv1 Round Trip Time See RTT router See gateway routing See direct routing or indirect routing Routing Information Protocol See RIP RPC Remote Procedure Call protocol See also XDR Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 423 RPC program The description of a set of RPC procedures Along with the procedures the description includes their return values parameters and the data types for the return values and parameters One RPC program is usually associated with one socket RTCS RTCS an embedded internet stack optimized to run on the MQX RTOS RTOS Real Time Operating System RTT Round Trip Time The time it takes for a signal to get from one end of the complete media system and back S schedule verb MQX finds the next ready task and makes it the active task segment The unit of transmission for TCP the TCP term for packet server An application that is above the transport layer and that usually has a well known endpoint service name In PPP over Ethernet the service name tag can indicate an ISP name or a class or quality of service session The set of traffic that is managed as a unit for Network Address Translation NAT UDP sessions are identified by the tuple of source IP address source UDP port target IP address and target UDP port ICMP query sessions are identifi
250. ndpoint identifier structure sockaddr in 257 error getting 153 example 32 function summary 32 names getting for stream sockets 29 122 ownership relinquishing RTCS detachsock 143 taking RTCS attachsock 140 peer names getting for stream sockets 120 shutting down stream sockets 31 199 using summary 25 SOL IGMP 186 SOL LINK 186 SOL NAT 186 SOL SOCKET 186 SOL TCP 186 SOL UDP 186 S Record boot files loading 173 loading and running 14 147 stack size additional PPP Driver 37 RTCS 11 Standard for the Transmission of IP Datagrams over Ethernet N t works 7 statistics ARP getting 82 structure 219 Ethernet 12 getting 106 structure 224 ICMP getting 125 structure 227 IGMP getting 126 structure 230 IP getting 127 IPIF getting 42 128 PPP getting 42 128 PPP over Ethernet getting 73 77 79 TCP getting 206 UDP getting 212 stream sockets aborting 31 about 25 comparison with datagram sockets 24 connections establishing 29 accept 80 connect 86 listen 129 data buffering 30 receiving 30 136 sending 29 182 throughput improving 30 names getting 29 122 options getting 124 setting 28 186 peer names getting 120 round trip time 190 shutting down 31 199 using 28 Subnetting Procedure 7 system sysDescr 56 system sysService 56 T task priority PPP Driver 38 RTCS 11 TCP 8 268 checksums bypassing 11 in RTCS protocol table 255
251. neral steps to create and use sockets The steps are summarized in the following diagrams and described in subsequent sections Create a new socket by calling socket indicating whether the socket is a datagram socket or a stream socket e Bind the socket to a local address by calling bind Ifthe socket is a stream socket assign a remote IP address by doing one of the following Calling connect Calling listen followed by accept Send data by calling sendto for a datagram socket or send for a stream socket Receive data by calling recvfrom for a datagram socket or recv for a stream socket When data transfer is finished optionally destroy the socket by calling shutdown Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 45 Using Sockets The process for datagram sockets is illustrated in Figure 3 1 socket connect Pu N bindO Y N SendtoO e N connect connect Bound recvfrom X N mag d sendto sendtoQ a a ruf recul send 7 recvfrom0 Figure 3 1 Creating and Using Datagram Sockets UDP The process for stream sockets is illustrated in Figure 3 2 socket connect t N disten comectO E K accepti Connected k J send gt vecul Figure 3 2 Creating and Using Stream Sockets TCP Freescale MQX RTCS User s Guide Rev 10 46 Freescale Semiconductor Using Sockets 3 14 Creating Sockets To
252. ng RTCS Creation Parameters Note 5 8 1 Communicating with an FTP Client FTP Server waits for an FTP client to connect to it As defined by RFC 959 FTP Server accepts the following commands from clients e abor aborts the previous command and any related transfer of data acct enters account information help displays information about a command pass enters a password port specifies a port number for a data connection quit ends the FTP session e retr retrieves a file from the server stor sends a file to the server user enters a user name Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 75 RTCS Applications 5 9 HTTP Server Hypertext Transfer Protocol HTTP server is a simple web server that handles evaluates and responses to HTTP requests Depending on the configuration and incoming client requests it returns static file system content web pages style sheets images or content dynamically generated by callback routines 5 9 1 Compile Time Configuration HTTPDCFG POLL MODE configures HTTP server for polling mode The user needs to poll the server periodically from a single task HTTPDCFG STATIC TASKS configures the HTTP server for static tasks mode The server creates sessions servicing tasks in advance during an initialization phase The tasks are not finished after session is closed are recycled for next sessions HTTP
253. ng RTCS logging In addition the socket API log entries belong to the kernel log functions group in the kernel To log socket API calls this group must be enabled using the MOX function klog control See Also RTCSLOG disable klog create in MOX Reference Manual klog control in MOX Reference Manual Example Create the kernel log _klog create 16384 0 Tell MOX to log RTCS functions _klog control KLOG ENABLED KLOG FUNCTIONS ENABLED TCSLOG FNBASE TRUE Tell RTCS to start logging RTCSLOG enable RTCS LOGCTRL ALL PEE eaa S Tell RTCS to stop logging RTCSLOG disable RTCS LOGCTRL ALL Freescale MQX RTCS User s Guide Rev 10 276 Freescale Semiconductor Function Reference 7 1 146 send Sends data on the stream socket or on a datagram socket for which a remote endpoint has been specified Synopsis int 32 send uint 32 socket char PTR buffer uint 32 buflen uint 32 flags Parameters socket in Handle for the socket on which to send data buffer in Pointer to the buffer of data to send buflen in Number of bytes in the buffer no restriction flags in For datagram sockets only Flags to underlying protocols selected from three independent groups Perform a bitwise OR of one flag only from one or more of the groups described in Section Flags below Description Function send
254. ng down 200 stream connecting to 87 using 140 various timeout options 198 sockets using 32 S Record boot file downloading and running 147 TFTP Server 211 F FCS 271 FLAG ABORT CONNECTION 199 FLAG CLOSE TX 199 flowcharts 58 FTP 7 Client 55 issuing commands to FTP server 109 issuing commands to FTP server that requires data connec tion 110 starting a session 114 terminating a session 108 Server 55 starting 116 G gateway metric 150 152 gateways adding to RTCS 13 149 metrics 150 152 removing from RTCS 14 151 get host by address DNS 117 get host by name DNS 118 get peer name stream sockets 120 get socket name stream sockets 122 H hard timeout socket option 188 HDLC 7 270 escape character 36 HDLC like framing device PPP initializing driver 68 host by address DNS getting 117 host by name DNS getting 118 HOSTENT STRUCT 226 HTTP 7 I O PCB handle destroying for PPPoE Client 69 getting for HDLC 68 for PPPoE Client 70 structure 217 opening driver for PPP 67 table structure 217 ICMP 7 267 statistics getting 125 structure 227 ICMP STATS structure 227 IGMP 7 add membership socket option 188 Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 429 drop membership socket option 189 get membership socket option 189 in RTCS protocol table 255 statistics getting 126 structure 230 IGMP STATS structure 23
255. nge Anytime Socket type Stream Ethernet Comments Send Ethernet 802 3 Frames Option name RTCS_SO_LINK_TX_8023 Protocol level SOL_LINK Values TRUE RTCS sends 802 3 frames FALSE RTCS sends Ethernet II frames Default value FALSE Change Anytime Socket type Stream Ethernet Comments Returns information for the last frame that the socket received Send Nowait Datagram Socket Option name OPT SEND NOWAIT can be overridden Protocol level SOL UDP Values TRUE RTCS buffers every datagram and send or sendto returns immediately e FALSE task that calls send or sendto blocks until the datagram has been transmitted datagrams are not copied Default value FALSE Change Anytime Socket type Datagram Comments Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 291 Function Reference Send Nowait Stream Socket Option name OPT_SEND_NOWAIT Protocol level SOL_TCP Values TRUE task that calls send does not wait if data is waiting to be sent RTCS buffers the outgoing data and send returns immediately FALSE task that calls send waits if data is waiting to be sent Default value FALSE Change Anytime Socket type Stream Comments Send Push Option name OPT SEND PUSH Protocol level SOL TCP
256. nherits the link layer options from the listening socket The new socket has the same local endpoint and socket options as the parent the remote endpoint is the originator of the connection This function blocks until an incoming connection is available Return Value Handle for a new stream socket success e RTCS SOCKET ERROR failure See Also bind connect e listen socket Example uint 32 handle uint 32 child handle sockaddr remote sin uint 16 remote addrlen uint 32 status status listen handle 0 if status RTCS OK printf AnError listen failed with error code 1x status Freescale MQX RTCS User s Guide Rev 10 110 Freescale Semiconductor Function Reference else remote addrlen sizeof remote sin child handle accept handle remote sin amp remote addrlen if child handle l RTCS_SOCKET_ERROR printf nConnection accepted from lx port d remote sin sin addr remote sin sin port else status RTCS geterror handle if status RTCS OK printf AnConnection reset by peer else printf Error accept failed with error code lx status Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 111 Function Reference 7 1 14 ARP_stats Gets a pointer to the ARP statistics that RTCS collects for the interface Synopsis ARP STATS PTR ARP stats rtcs if handle rtcs_if_ handle Paramete
257. nnections Only the private host can initiate a connection to the public host In addition the Freescale MQX implementation of NAT can operate only on a border router for a single private network Table 2 2 Summary Setup Functions NAT_close Stops Network Address Translation NAT init Starts Network Address Translation RTCS create Creates the RTCS RTCS exec TFTP BIN Downloads and runs a binary file RTCS exec TFTP COFF Downloads and runs a COFF file RTCS exec TFTP SREC Downloads and runs an S Record file RTCS gate add Adds a gateway to RTCS RTCS gate remove Removes a gateway from RTCS RTCS if add Adds a device interface to RTCS RTCS if bind Binds an IP address to a device interface RTCS if bind BOOTP Uses BootP to get an IP address to bind to a device interface RTCS if bind DHCP Uses DHCP to get an IP address to bind to a device interface RTCS if bind IPCP Binds an IP address to a PPP link RTCS if remove Removes a device interface from RTCS RTCS if unbind Unbinds an IP address from a device interface RTCSLOG enable Enables RTCS event logging RTCSLOG disable Disables RTCS event logging setsockopt Sets the NAT options Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 29 Setting Up the RTCS 2 15 6 Example Setting Up RTCS Set up RTCS with on
258. not log packets even if the application calls RTCSLOG_enable 2 16 2 48 RTCSCFG LOG SOCKET API By default RTCS logs socket API calls in the MQX kernel log subject to whether the application calls RTCSLOG enable Set this value to 0 zero to have RTCS not log socket API calls even if the application calls RTCSLOG enable 2 16 2 49 RTCSCFG ENABLE IP4 Enable IPv4 Protocol support Default value 1 2 16 2 50 RTCSCFG ENABLE IP6 Enable IPv6 Protocol support Default value 0 2 16 2 51 RTCSCFG ND6 NEIGHBOR CACHE SIZE Maximum number of entries in the neighbor cache per interface Default value 6 2 16 2 52 RTCSCFG ND6 PREFIX LIST SIZE Maximum number of entries in the prefix list per interface Default value 4 2 16 2 53 RTCSCFG ND6 ROUTER LIST SIZE Maximum number of entries in the Default Router list per interface Default value 2 2 16 2 54 RTCSCFG IP6 IF ADDRESSES MAX Maximum number of IPv6 addresses per interface Default value 5 2 16 2 55 RTCSCFG IP6 REASSEMBLY Enable IPv6 packet reassembling Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 37 Setting Up the RTCS Default value 1 2 16 2 56 RTCSCFG IP6 LOOPBACK MULTICAST Enable loopback of own IPv6 multicast packets Default value 0 2 16 2 57 RTCSCFG ND6 DAD TRANSMITS Maximum number of Solicitation messages sent while performing Duplicate Address Detection on a tentative address Default value 1
259. ns address HDLC term for broadcast address e Broadcast address a hardware address or an IP address that refers to all hosts on a medium The HDLC term for this is all stations address Ethernet address ethernet term for the hardware address A 48 bit address where the least significant bit of the first octet signifies whether the address is a unicast address the bit is zero or a multicast address the bit is one An ethernet address is sometimes called a MAC address Hardware address address of a physical interface A hardware address is sometimes called a media address IP address a 32 bit quantity that represents a point of attachment in an internet It consists of a network portion and a host portion The IP address is a multicast address if the four most significant bits of the first octet have the binary value 1110 An IP address is sometimes called a logical address See also address class and network mask An IP address is sometimes called a logical address Logical address see IP address MAC address see ethernet address Media address see physical address Multicast address see ethernet address and IP address e Network address a 32 bit address consisting of the network portion of an IP address and zeros in the host portion Physical address a sequent of bits that a medium uses to address a host A physical address is sometimes called a media address e Unicast a
260. nses and reasonable attorney fees arising out of directly or indirectly any claim of personal injury or death associated with such unintended or unauthorized use even if such claim alleges that Freescale Semiconductor was negligent regarding the design or manufacture of the part 2 freescale Freescale and the Freescale logo are trademarks of Freescale Semiconductor Inc All other product or service names are the property of their respective owners 1994 2008 ARC International All rights reserved Freescale Semiconductor Inc 2008 2012 All rights reserved Document Number MQXRTCSUG Rev 10 11 2012 Chapter 1 Before You Begin LT ADOM Th BOOK quida ini acea 9 ded B niui os el ra dra 15 1 2 Where to Go for More Information i c cedrus eR ur rr 15 Neo Conventions Li osa aie e mea bee albi dd det 4d EN Y CC EN Y 15 ul Product Names Lue ass pe E IRA RC ee bas 15 LESE ST TH y YN eee red A EW EPEPEERRIO Sad V E ERE 15 Wit o Tur 15 Ee o oo PD 16 Chapter 2 Setting Up the RTCS uli a e OI AN CRY ek AREA 17 22 Supported Protocols and Policies 44937397233 RR ER ua aa an 17 2 3 RTCS Included with Freescale MQX RTOS FFFY YY eee 17 2 3 1 Protocol Stack Architecture e cs im a ze EDD adan 21 24 Seting UDE Als 7 Y _ _ Y ratu e A 22 2 5 Defining ATCS Protocols e mareata ee bate ere d e e RR i e eed 22 2b Changing ATCS Creation Parameters sce enc cea bb eke aaa pas ica 23
261. o any products herein Freescale Semiconductor makes no warranty representation or guarantee regarding the suitability of its products for any particular purpose nor does Freescale Semiconductor assume any liability arising out of the application or use of any product or circuit and specifically disclaims any and all liability including without limitation consequential or incidental damages Typical parameters that may be provided in Freescale Semiconductor data sheets and or specifications can and do vary in different applications and actual performance may vary over time All operating parameters including Typicals must be validated for each customer application by customer s technical experts Freescale Semiconductor does not convey any license under its patent rights nor the rights of others Freescale Semiconductor products are not designed intended or authorized for use as components in systems intended for surgical implant into the body or other applications intended to support or sustain life or for any other application in which the failure of the Freescale Semiconductor product could create a situation where personal injury or death may occur Should Buyer purchase or use Freescale Semiconductor products for any such unintended or unauthorized application Buyer shall indemnify and hold Freescale Semiconductor and its officers employees subsidiaries affiliates and distributors harmless against all claims costs damages and expe
262. o error on reception ST TX TOTAL Transmitted total ST TX MISSED Transmitted discarded because transmit ring was full Freescale MQX RTCS User s Guide Rev 10 338 Freescale Semiconductor ST_TX_DISCARDED Transmitted discarded because packet was bad packet ST_TX_ERRORS Transmitted errors during transmission ST_TX_COLLHIST Transmitted collision histogram The following stats are for physical errors or conditions ST_RX_ALIGN Frame alignment errors ST_RX_FCS CRC errors ST_RX_RUNT Runt packets received ST_RX_GIANT Giant packets received ST_RX_LATECOLL Late collisions ST_RX_OVERRUN DMA overruns ST_TX_SQE Heartbeats lost ST TX DEFERRED Transmissions deferred ST TX LATECOLL Late collisions ST TX EXCESSCOLL Excessive collisions ST TX CARRIER Carrier sense lost ST TX UNDERRUN Freescale MQX RTCS User s Guide Rev 10 Data Types Freescale Semiconductor 339 Data Types DMA underruns Freescale MQX RTCS User s Guide Rev 10 340 Freescale Semiconductor Data Types 8 3 7 HOSTENT_STRUCT A pointer to this structure is returned by the socket functions gethostbyaddr and gethostbyname typedef struct hostent char ptr h name char ptr PTR h aliases int 16 h addrtype int 16 h length char ptr PTR h addr list HOSTENT STRUCT _PTR_ HOSTENT STRUCT PTR Sa h_name Pointer to the NULL terminated character string th
263. o fill the buffer Datagram Socket The recv function on a datagram socket is identical to recyfrom with NULL fromaddr and fromlen pointers The recv function is normally used on a connected socket Freescale MQX RTCS User s Guide Rev 10 230 Freescale Semiconductor Stream Socket uint 32 handle char buffer 20000 uint 32 count count recv handle buffer 20000 0 if count RTCS ERROR printf nError recv failed with error code 1x RTCS geterror handle else printf AnReceived ld bytes of data Freescale MQX RTCS User s Guide Rev 10 count Function Reference Freescale Semiconductor 231 Function Reference 7 1 115 recvfrom Provides RTCS with the buffer in which to place data that is incoming on the datagram socket Synopsis int 32 recvfrom uint 32 socket char PTR buffer uint 32 buflen uint 32 flags sockaddr PTR fromaddr uint 16 ptr fromlen Parameters socket in Handle for the datagram socket buffer out Pointer to the buffer in which to place received data buflen in Size of buffer in bytes flags in Flags to underlying protocols One of the following RTCS MSG PEEK receives a datagram but does not consume it Zero ignore fromaddr out Source socket address of the message fromlen in out When passed in Size of the fromaddr buffer When passed out Size of the socket address stored
264. ock Oriented A datagram socket is block oriented This means that when an application sends a block of data the bytes of data remain together If an application writes a block of data of say 100 bytes RTCS sends the data to the destination in a single packet and the destination receives 100 bytes of data 3 9 Stream Sockets 3 10 Connection Based A stream socket connection is uniquely defined by an address port number pair for each of the two endpoints in the connection For example a connection to a Telnet server uses the local IP address with a local port number and the server s IP address with port number 23 3 11 Reliable Transfer A stream socket provides reliable end to end data transfer To use stream sockets a client establishes a connection to a peer transfers data and then closes the connection Barring physical disconnection RTCS guarantees that all sent data is received in sequence 3 12 Character Oriented A stream socket is character oriented This means that RTCS might split or merge bytes of data as it sends the data from one protocol stack to another An application on a stream socket might perform for example two successive write operations of 100 bytes each and RTCS might send the data to the destination in a single packet The destination might then receive the data using for example four successive read operations of 50 bytes each 3 13 Creating and Using Sockets An application follows the following ge
265. ocket Option name OPT SOCKET ERROR Protocol level SOL SOCKET Values Default value Change use with getsockopt only returns value in optval Socket type Datagram or stream Comments Returns the last error for the socket Option name OPT SOCKET TYPE Protocol level SOL SOCKET Values Default value Change use with getsockopt only returns value in optval Socket type Datagram or stream Comments Returns the type of socket SOCK DGRAM or SOCK STREAM Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 293 Function Reference Timewait Timeout Option name OPT_TIMEWAIT_TIMEOUT Protocol level SOL_TCP Values gt Zero milliseconds Default value Two times the maximum segment lifetime which is a constant Change Before bound Socket type Stream Comments Returned information is for the last frame that the socket received RX Destination Address Option name RTCS SO IP RX DEST Protocol level SOL IP Values Default value Change use with getsockopt only returns value in optval Socket type Datagram or stream Comments Returns destination address of the last frame that the socket received Time to Live RX Option name RTCS SO IP RX TTL Protocol level SOL IP Values Default va
266. of server and filename see Table 7 1 Return Value RTCS OK success Error code failure See Also RTCS exec TFTP_SREC e RTGS if bind BOOTP BOOTP DATA STRUCT Freescale MQX RTCS User s Guide Rev 10 268 Freescale Semiconductor Function Reference 7 1 140 RTCS_ping Sends an ICMP echo request packet to the IP address and waits for a reply Synopsis uint 32 RTCS ping ip address address uint 32 ptr timeout uint 16 id Parameters address in IP address to which to send the packet timeout in out When passed in one of the following Pointer to the maximum time to wait for a reply Zero waits indefinitely When passed out pointer to the round trip time id in User ID for the echo request Description Function RTCS ping is the RTCS implementation of ping It sends an ICMP echo request packet to IP address address and waits for a reply Return Value e RTCS OK success Error code failure Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 269 Function Reference 7 1 141 RTCS_request_DHCP_inform Requests a DHCP information message Synopsis uint 32 RTCS request DHCP inform _rtcs if handle handle uchar ptr optptr uint 32 optlen ip address client addr ip address server addr void CODE PTR inform func uchar PTR uint 32 _rtcs if handle Parameters handle in RTCS interface handle optptr in One of the foll
267. ompiler options for example optimization level Change RTCS compile time configuration options Incorporate changes that you made to RTCS source code CAUTION We do not recommend you to modify RTCS data structures If you do some of the components in the Precise Solution Host Tools family of host software development tools might not perform correctly Modify RTCS data structures only if you are very experienced with RTCS 6 2 Before You Begin Before you rebuild RTCS we recommend that you Read the MOX User Guide document for MQX RTOS rebuild instructions A very similar concept applies also to the RTCS Read the MOX Release Notes that accompany Freescale MOX to get information that is specific to your target environment and hardware Have the required tools for your target environment compiler assembler linker Be familiar with the RTCS directory structure and re build instructions as they are described in the release notes document and also the instructions provided in the following sections Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 91 Rebuilding 6 3 RTCS Directory Structure The following table shows the RTCS directory structure config The main configuration directory board Board specific directory which contains the main configuration file user config h rics Root directory for RTCS within the Fr
268. on DHCPCLNT release does the following e It cancels timer events in the DHCP state machine e Jt sets the state to RELEASING resulting in the release of resources with this state e tunbinds from an interface e It stops listening on the DHCP port e Itreleases resources Return Value void success Error code failure See Also e RTCS if bind DHCP Example _rtcs if handle ihandle start RTCS task add an interface and bind it with RTCS if bind DHCP do some stuff with the interface all done DHCPCLNT release ihandle Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 127 Function Reference 7 1 27 DHCPSRV_init Starts DHCP Server Synopsis uint 32 DHCPSRV init char ptr name uint 32 priority uint 32 stacksize Parameters name in Name of the server s task priority in Priority for the server s task stacksize in Stack size for the server s task Description Function DHCPSRV init starts the DHCP server and creates DHCPSRV task Return Value RTCS OK success Error code failure See Also DHCPCLNT find option e DHCP option addr e DHCP option addrlist e DHCP option int8 e DHCP option int16 e DHCP option int32 e DHCP option string e DHCP option variable Example Start DHCP Server and set up its options DHCPSRV DATA STRUCT dhcpsrv data uchar dhcpsrv options 200 ip address routers 3
269. on Reference 7 1 121 RTCS_exec_TFTP_SREC Downloads and runs the S Record boot file Synopsis uint 32 RTCS exec TFTP SREC ip address Server char ptr filename Description This function downloads the Motorola S Record file from the TFTP Server decodes the file and runs it For information on the values of server and filename see Table 7 1 Parameters server in IP address of the TFTP server from which to get the file filename in Name of the file to download Return Value Nothing RTCS OK on success Error code on failure See Also e RTCS create e RTCS exec TFTP BIN e RTCS exec TFTP COFF BOOTP DATA STRUCT Example Initialize RTCS using BootP download the S Record file and run it uint 32 boot function void BOOTP DATA STRUCT boot data enet handle ehandle rtcs if handle ihandle uint 32 error error ENET initialize 0 enet local 0 amp ehandle if error return error error RTCS create if error return error error RTCS if add ehandle RTCS IF ENET amp ihandle if error return error memset amp boot data 0 sizeof boot data error RTCS if bind BOOTP ihandle amp boot data if error return error printf IinDownloading the boot file n Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 241 Function Reference rror RTCS exec TFTP SREC boot data SADDR char ptr boot data BOOTFILE return err
270. onductor RTCS if bind IPCP DHCP DATA STRUCT Example enet handl handle rtcs if handle ihandle uint 32 error uint 32 optlen 100 Use the size that you need for the number of params that you are using with DHCP uchar option array 100 uchar _PTR_ optptr DHCP DATA STRUCT params uchar parm options 3 DHCPOPT SERVERNAME DHCPOPT FILENAME DHCPOPT FINGER SRV error ENET initialize 0 enet local 0 amp ehandle if error printf AnFailed to initialize Ethernet driver s ENET strerror error return error RTCS create if error RTCS OK printf AinFailed to create RTCS error x error return error RTCS if add ehandle RTCS IF ENET amp ihandle if error printf nFailed to add the interface rror x error return You supply the following functions if any is NULL DHCP Client follows its default behavior params FLAGS 0 params FLAGS DHCP SEND INFORM MESSAGE params FLAGS DHCP MAINTAIN STATE ON INFINITE LEASE params FLAGS DHCP SEND PROBE params CHOICE FUNC DHCPCLNT test choice func params BIND FUNC DHCPCLNT test bind func params UNBIND FUNC DHCPCLNT test unbind func optptr option array Fill in the requested params Request a three minute lease DHCP option int32 amp optptr amp optlen DHCPOPT LEASE 180 Request a TFTP Server FILENAME and Finger Server
271. ons for Ethernet interfaces RTCS IF LOCALHOST uses default callback functions for local loopback RTCS IF PPP PPP only uses default callback functions for PPP interfaces rtcs if handle out Pointer to the RTCS interface handle Description The application uses the RTCS interface handle to call RTCS if bind functions Return Value e RTCS OK success Error code failure See Also e ENET initialize e PPP _ initialize e RTCS create e RICS if bind e RTCS IF STRUCT Example See Section 2 15 6 Example Setting Up RTCS Freescale MQX RTCS User s Guide Rev 10 248 Freescale Semiconductor Function Reference 7 1 128 RTCS if bind Binds the IP address and network mask to the device interface Synopsis uint 32 RTCS if bind _rtcs if handle rtcs if handle ip address address ip address netmask Parameters rtcs if handle in RTCS interface handle address in IP address for the device interface netmask in Network mask for the interface Description Function RTCS if bind binds IP address address and network mask netmask to the device interface associated with handle rtcs if handle Parameter rtcs if handle is returned by RTCS if add Return Value e RTCS OK success Error code failure See Also e RTCS if add RTCS if bind BOOTP RTCS if bind DHCP e RTCS if bind DHCP flagged e RTCS if rebind DHCP Example See Section 2 15 6 Example Setting Up RTCS
272. or Freescale MQX RTCS User s Guide Rev 10 242 Freescale Semiconductor Function Reference 7 1 122 RTCS gate add Adds the gateway to RTCS Synopsis uint 32 RTCS gate add ip address gateway ip address network ip address netmask Parameters gateway in IP address of the gateway network in IP network in which the gateway is located netmask in Network mask for network Description Function RTCS gate add adds gateway gateway to RTCS with metric zero Return Value e RTCS OK success Error code failure See Also RTCS gate remove e RTCS if bind family of functions Example Add a default gateway error RTCS gate add GATE ADDR INADDR ANY INADDR ANY Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 243 Function Reference 7 1 123 RTCS_gate_add_metric Adds a gateway to the RTCS routing table and assign it s metric Synopsis uint 32 RTCS gate add metric ip address gateway ip address network ip address netmask uint 16 metric Parameters gateway in IP address of the gateway network in IP network in which the gateway is located netmask in Network mask for network metric in Gateway metric on a scale of zero to 65535 Description Function RTCS gate add metric associates metric metric with gateway gateway Return Value RTCS OK success Error code failure See Also e RTCS gate remove metric e RI
273. or information ST_RX_OCTETS Total bytes received ST_RX_UNICAST Unicast packets received ST_RX_MULTICAST Multicast packets received ST_RX_BROADCAST Broadcast packets received ST_TX_OCTETS Total bytes sent ST_TX_UNICAST Unicast packets sent ST_TX_MULTICAST Multicast packets sent ST_TX_BROADCAST Broadcast packets sent Freescale MQX RTCS User s Guide Rev 10 Data Types Freescale Semiconductor 365 Data Types 8 3 22 nat ports Used by Freescale MQX NAT to control the range of ports between and including the minimum and maximum ports specified typedef struct uint 16 port min uint 16 port max nat ports PORT MIN Minimum port number PORT MAX Maximum port number Freescale MQX RTCS User s Guide Rev 10 366 Freescale Semiconductor Data Types 8 8 23 NAT STATS Network address translation statistics typedef struct uint 32 ST SESSIONS uint 32 ST SESSIONS OPEN uint 32 ST SESSIONS OPEN MAX uint 32 ST PACKETS TOTAL uint 32 ST PACKETS BYPASS uint 32 ST PACKETS PUB PRV uint 32 ST PACKETS PUB PRV ERR uint 32 ST PACKETS PRV PUB uint 32 ST PACKETS PRV PUB ERR NAT STATS PTR AT STATS PTR ST SESSIONS Total amount of sessions created to date ST SESSIONS OPEN Number of sessions currently open ST SESSIONS OPEN MAX Maximum number of sessions open simultaneously to date ST PACKETS TOTAL Number of packets processed by Freescale MQX
274. oreign addrv6 res Socket udp socket AF INET6 SOCK DGRAM 0 error bind socket udp sockaddr local addrv6 res ai addr sizeof struct sockaddr in6 sendto socket udp Hello world 13 0 sockaddr foreign addrv6 res ai addr sizeof sockaddr in6 Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 281 Function Reference 7 1 148 setsockopt Sets the value of the socket option Synopsis uint 32 setsockopt uint 32 socket uint 32 level uint 32 optname pointer optval uint 32 optlen Parameters socket in One of the following if level is anything but SOL NAT handle for the socket whose option is to be changed if level is SOL NAT socket is ignored level in Protocol levels at which the option resides SOL IGMP SOL LINK SOL NAT SOL SOCKET SOL TCP SOL UDP SOL IP optname in Option name see Section Description optval in Pointer to the option value optlen in Number of bytes that optval points to Return Value RTCS OK success Specific error code failure See Also bind getsockopt ip mreq nat ports nat timeouts Freescale MQX RTCS User s Guide Rev 10 282 Freescale Semiconductor Description Function Reference You can set most socket options by calling setsockopt However the following options cannot be set you can use them only with getsocko
275. orithms for computing CRC checksums such as CCITT 16 and CCITT 32 CCITT 16 An algorithm proposed by CCITT for calculating a 16 bit CRC checksum CCITT 32 An algorithm proposed by CCITT for calculating a 32 bit CRC checksum CCP Compression Control Protocol which is used by PPP Driver Challenge Handshake Authentication Protocol See CHAP CHAP Challenge Handshake Authentication Protocol One of the authentication protocols that PPP Driver supports See also PAP checksum See CRC CIDR Classless Inter Domain Routing Classless Inter Domain Routing See CIDR COFF Common Object File Format One format of a boot file See also B N and SREC Freescale MQX RTCS User s Guide Rev 10 410 Freescale Semiconductor collision Because signals take a finite time to travel from one end of a system to the other the first bits of a sent frame do not reach all parts of the network simultaneously Therefore two interfaces might sense that the network is idle and start to send their frames simultaneously When this happens there is a collision See also collision detection and CSMA CD collision detection If ethernet detects the collision of signals it stops the transmission and re sends the frame Common Object File Format See COFF Compression Control Protocol See CCP configuration options See the individual LCP configuration options for PPP Driver ACCM ACFC AP MRU and PFC configure a link Negotia
276. ovides functions for obtaining information about servers on the network by address or by name To get the HOSTENT STRUCT for an IP address use function gethostbyaddr To get the HOSTENT STRUCT for a host name use function gethostbyname Table 5 4 Summary Using DNS Services gethostbyaddr Gets the HOSTENT STRUCT for an IP address gethostbyname Gets the HOSTENT STRUCT for a host name 5 5 Echo Server Echo Server implements a server that complies with the Echo protocol RFC 862 The echo service sends any data that it receives back to the originating source To start Echo Server an application calls ECHOSRV _init with the name of the task that implements the Echo protocol the task s priority and its stack size When the server is started the application should make the priority of the task lower than the TCP IP task that is make the task s priority 7 8 9 or greater See information on the HTCSTASK priority variable in Section 2 6 Changing RTCS Creation Parameters Note Echo Server communicates with a client on the host the client is not part of RTCS Freescale MQX RTCS User s Guide Rev 10 74 Freescale Semiconductor RTCS Applications 5 6 EDS Server EDS Server communicates with a host that is running a performance analysis tool available from Freescale MQX The tool initiates a connection between the host and target systems so that TCP IP packets can be
277. owing Pointer to the buffer of DHCP options see RFC 2132 NULL optlen in Number of bytes in the buffer pointed to by optptr client addr in IP address where the application is bound server addr in IP address of the server for which information 1s needed inform func Function to call when DHCP is finished Description Function RTCS request DHCP inform requests an information message about server server Return Value Server DHCP information success Error code failure Freescale MQX RTCS User s Guide Rev 10 270 Freescale Semiconductor Function Reference 7 1 142 RTCS_selectall If option RTCSCFG_ SOCKET OWNERSHIP is enabled then this function waits for activity on any socket that caller owns Otherwise it waits for activity on any socket Synopsis uint 32 RTCS selectall uint 32 timeout Parameters timeout in One of the following Maximum number of milliseconds to wait for activity Zero waits indefinitely does not block Description If timeout is not 1 the function blocks until activity is detected on any socket that the calling task owns Activity consists of any of the following Socket Receives Unbound datagram Datagrams Listening stream Connection requests Connected stream is or chua requests that are initiated by the remote endpoint Return Value Socket handle activity was detected Zero timeout expired RT
278. p DNS Resolver 3 o LG ne ESFERA 73 5 4 2 Using DNS Resolver ccc cei GE reed iai e a e re n ai 73 5 4 3 Communicating with a DNS Server VYY FFY eee 74 544 USING DNS SOU lt 2 ae caca aaa ariba earag ai da borrar 74 A A EAQUE eee bein edh Exit dite ess 74 56 EDS Ser ee oc pees ke m 75 57 PIP CCW 26d FE i e i nv CUD CREDERE RE RR d er e e E Deer e dn A 75 59 FUP SONG pirani arii teta O OI FY FN a da ES 75 5 8 1 Communicating with an FTP Client ae nana ama asha 75 OMEN A 10 PRETERITO 76 5 9 1 Compile Time Configuration eiu GG GR DR GERDD 76 59 2 Bis USAS ar p sta aia la AE ROS CC LR ao RARA A 76 5 9 3 Providing Static Content so cre at ii did 76 5 9 4 Dynamic Content CGI Liko Pages s s si uunc carta I4 5 9 5 Dynamic Content ASP Like Page Callbacks 78 5 10 IPCFG High Level Network Interface Management 79 5 11 IWCFG High Level Wireless Network Interface Management 80 512 SNMP Agent RET TERT 80 5 121 Configunng SNMP AGG uu 12 7352 e sea a aa etala a ie ad te i ai 81 5 122 Starting SNMP Agent e e REG EUO a aa aceia UE ENA aaa 81 5 12 6 Communicating wih SNMP Oen s i o lt s lt cescavecivnwrtsececs anias 81 5 12 4 Defining Management Information Base MIB V 81 Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 5 5 12 5 Processing Wie MIB File iura be e a a 87 5 12 6 Standard MIB Include
279. packets ST RX MISSED Incoming packets discarded due to lack of resources Freescale MQX RTCS User s Guide Rev 10 350 Freescale Semiconductor ST RX DISCARDED Incoming packets discarded for all other reasons ST RX ERRORS Internal errors detected while processing an incoming packet ST TX TOTAL Total number of transmitted packets ST TX MISSED Packets to be sent that were discarded due to lack of resources ST TX DISCARDED Packets to be sent that were discarded for all other reasons ST TX ERRORS Internal errors detected while trying to send a packet ERR RX RX error information ERR TX TX error information The following are included in ST RX DISCARDED ST RX BAD CODE Datagrams with unrecognized code ST RX BAD CHECKSUM Datagrams with an invalid checksum ST RX SMALL DGRAM Datagrams smaller than the header ST RX RD NOTGATE Redirects received from a non gateway Stats on each CMP type ST RX DESTUNREACH Received Destination Unreachables ST RX TIMEEXCEED Received Time Exceeded Freescale MQX RTCS User s Guide Rev 10 Data Types Freescale Semiconductor 351 Data Types ST_RX_PARMPROB Received Parameter Problems ST RX SRCQUENCH Received Source Quenches ST RX REDIRECT Received Redirects ST RX ECHO REQ Received Echo Requests ST RX ECHO REPLY Received Echo Replies ST RX TIME REQ Received Timestamp Requests ST RX TIME REPLY Received Timestamp Replie
280. pd server init This function initializes the HTTP server task using the default parameters Synopsis HTTPD STRUCT httpd server init HTTPD ROOT DIR STRUCT root dir const char index page Parameters root dir in pointer to HTTPD ROOT DIR STRUCT which contains web server root directories mapping between web derectories and physical filesystem paths index page in Filename of the default index page relative to root directory Description This function is a simple wrapper around httpd default params and httpd init functions Use this call to prepare the HTTP to be started with the default compiled in settings After the HTTP server is initialized by this call some of the server parameters can still be changed using one ofthe HTTP SET xxx calls macros However parameters like port number or number of sessions can not be changed after this call Return Value Pointer to HTTP to server structure See Also e httpd default params e httpd server run e httpd server poll Example HTTPD ROOT DIR STRUCT root dir id teg 0 O table termination record uH HTTPD STRUCT server server httpd server init root dir mqx html HTTPD SET PARAM CGI TBL server cgi Ink tbl HTTPD SET PARAM FN TBL server fn Ink tbl httpd server run server Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 157 Function Reference 7 1 50
281. ped character 0x7D Escaped character with bit five toggled For example if bit zero of the ACCM is one every 0x00 byte to be sent over the link is sent as the two bytes Ox7D and 0x20 PPP Driver always insists on the ACCM as a minimal ACCM for both sides of the link An application can change the default value for ACCM For example if XON XOFF flow control is used over the link an application should set ACCM to 0x000A0000 which escapes XON 0x11 and XOFF 0x13 whenever they occur in a frame 4 2 1 2 ACFC By default ACFC is FALSE so PPP Driver does not compress the Address field and Control field in PPP frames If ACFC becomes TRUE the driver omits the fields and assumes that they are always OxFF for Address field and 0x03 for Control field To avoid ambiguity when Protocol field compression is enabled that is when the PFC configuration option is TRUE and the first Data field octet is 0x03 RFC 1661 PPP prohibits the use of 0x00FF as the value of the Protocol field which is the protocol number PPP Driver always tries to negotiate ACFC Freescale MQX RTCS User s Guide Rev 10 56 Freescale Semiconductor Point to Point Drivers 4 2 1 3 AP On some links a peer must authenticate itself before it can exchange network layer packets PPP Driver supports these authentication protocols e PAP CHAP For more information about authentication and how to change the default values of the global variabl
282. per build project in the development environment and building it Don t forget to select the proper build target to be built or build all targets For specific information about rebuilding MQX RTCS and the example applications see the release notes that accompany the Freescale MQX distribution Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 93 Rebuilding Freescale MQX RTCS User s Guide Rev 10 94 Freescale Semiconductor Chapter 7 Function Reference 7 1 Function Listing Format This is the general format of an entry for a function compiler intrinsic or macro 7 1 1 function name A short description of what function function namer does Synopsis Provides a prototype for function function namewy return type function name type 1 parameter 1 type 2 parameter 2 type n gt parameter n Parameters parameter 1 in Pointer to x parameter 2 out Handle for y parameter n in out Pointer to z Parameter passing is categorized as follows e n means the function uses one or more values in the parameter you give it without storing any changes Out Out means the function saves one or more values in the parameter you give it You can examine the saved values to find out useful information about your application e nout e n out means the function changes one or more values in the parameter you give it and saves the result You can examine the save
283. ple Get a pointer to the start of the DHCP server s name from a packet like a DH OFFER packet recieved from the server uchar _PTR buffer ptr This is a DHCP packet recieved from a server uint 32 buffer size uchar _PTR optptr optptr DHCPCLNT find option buffer ptr buffer size DHCPOPT SERVERNAME Freescale MQX RTCS User s Guide Rev 10 118 Freescale Semiconductor Function Reference 7 1 18 DHCP_option_addr Adds the IP address to the list of DHCP options for DHCP Server Synopsis boolean DHCP option addr uchar ptr _PTR_ optptr uint 32 PTR optlen uchar opttype ip address optval Parameters optptr in out Pointer to the option list optlen in out Pointer to the number of bytes remaining in the option list in before optval is added Passed out after optval is added opttype in Option type to add to the list see RFC 2132 optval in IP address to add Description Function DHCP option addr adds IP address optval to the list of DHCP options for the DHCP server The application subsequently passes parameter optptr pointer to the option list to DHCPSRV ippool add Return Value TRUE success FALSE failure not enough room in the option list See Also DHCPCLNT find option e DHCPSRV ippool add e DHCP option addrlist e DHCP option int8 e DHCP option int16 e DHCP option int32 e DHCP option string e DHCP
284. pp sem 0 mem zero amp ipcp data sizeof ipcp data ipcp data IP UP PPP linkup ipcp data IP DOWN NULL ipcp data IP PARAM pointer amp ppp sem ipcp data ACCEPT LOCAL ADDR TRUE ipcp data LOCAL ADDR INADDR ANY ipcp data ACCEPT REMOTE ADDR TRUE ipcp data REMOTE ADDR INADDR ANY ipcp data DEFAULT NETMASK TRUE ipcp data NETMASK 0 ipcp data DEFAULT ROUTE TRUE ipcp data NEG LOCAL DNS FALSE ipcp data ACCEPT LOCAL DNS 0 ipcp data LOCAL DNS 0 ipcp data NEG REMOTE DNS FALSE ipcp data ACCEPT REMOTE DNS 0 ipcp data REMOTE DNS 107 login string lt login name gt password password strcpy MySecretName login string strcpy MySecretPassword password if ENABLE CHAP MySecrets 1 PPP ID LENGTH MySecrets 1 PPP PW LENGTH 0 PPP CHAP LSECRETS amp MySecrets 1 Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 101 Function Reference _PPP_CHAP_LNAME MySecretName MySecrets 0 PPP PW PTR MySecretPassword MySecrets 0 PPP PW LENGTH strlen MySecretPassword PPP PAP LSECRET NULL else ySecrets 0 PPP ID PTR MySecretName ySecrets 0 PPP ID LENGTH strlen MySecretName ySecrets 0 PPP PW PTR MySecretPassword ySecrets 0 PPP PW LENGTH strlen MyS
285. ppoe server if add Freescale MQX RTCS User s Guide Rev 10 106 Freescale Semiconductor Function Reference 7 1 10 _pppoe server if stats Gets a pointer to statistics on the ethernet interface Synopsis uint 32 pppoe server if stats pppoe srv handle pppoe handle enet handle enet handle Parameters pppoe handle in PPPoE server handle enet handle in Ethernet interface handle Description Function pppoe server if stats returns a pointer to the statistics on the ethernet interface for the PPPoE server Return Value Pointer to a PPPOEIF STATS STRUCT structure success Error code failure See Also e pppoe server if add pppoe server if remove e PPPOEIF STATS STRUCT Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 107 Function Reference 7 1 11 _pppoe_server_init Initializes PPPoE Server Synopsis uint 32 pppoe server init _pppoe srv handle PTR pppoe_handle PPPOE SERVER INIT DATA STRUCT PTR pppoe init data Parameters pppoe_handle out PPPoE Server handle pppoe_init_data in Initialization parameters Description Function pppoe server init initializes the PPPoE Server so the PPPoE Server can respond to PPP over Ethernet discovery packets sent via the Ethernet Driver Return Value PPPOE OK success Error code failure See Also e PPPOE SERVER INIT DATA STRUCT Freescale MQX RTCS User s Guide R
286. pt IGMP get membership receive Ethernet 802 10 priority tags receive Ethernet 802 3 frames socket error socket type The user changeable options have default values If you want to change the value of some of the options you must do so before you bind the socket For other options you can change the value anytime after the socket is created This function blocks but the command is immediately serviced and replied to NOTE For more information see send and sendto Some options can be temporarily overridden for datagram sockets Options This section describes the socket options Checksum Bypass Option name OPT CHECKSUM BYPASS can be overridden Protocol level SOL UDP Values TRUE RTCS sets the checksum field of sent datagram packets to zero and the generation of checksums is bypassed FALSE RTCS generates checksums for sent datagram packets Default value FALSE Change Before bound Sockettype Datagram Comments Connect Timeout Option name OPT_CONNECT_TIMEOUT Protocol level SOL_TCP Values gt 180 000 RTCS maintains the connection for this number of milliseconds Default value 480 000 eight minutes Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 283 Function Reference Change Before bound Socket type Stream Connect timeout corre
287. push OPT RECEIVE PUSH socket options The application can change the values by calling setsockopt Receive nowait Receive push recv returns when non blocking I O delay transmission FALSE default TRUE default One of A push flag in the data is received Supplied buffer is completely filled with incoming data Receive timeout expires the default receive timeout is an unlimited time FALSE default FALSE Either Supplied buffer is completely filled with incoming data Receive timeout expires TRUE Ignored Immediately after it polls TCP for any data in the internal receive buffer 3 27 Buffering Data The size of the RTCS per socket send buffer is determined by the socket option that controls the size of the send buffer RTCS copies data into its send buffer from the buffer that the application supplies As the peer acknowledges the data RTCS releases space in its buffer If the buffer is full calls to send with the send push OPT SEND PUSH socket option FALSE block until the remote endpoint acknowledges some or all of the data The size of the RTCS per socket receive buffer is determined by the socket option that controls the size of the receive buffer RTCS uses the buffer to hold incoming data when there are no outstanding calls to recv When the application calls reev RTCS copies data from its buffer to the buffer that the application supplies and consequently the remote
288. r ptr passphrase Parameters dev num in Device identification index passphrase out SSID passpharse string Description Get the wpa passpharse from initialized wifi device Return Value e ENET OK success ENETERR INVALID DEVICE Freescale MQX RTCS User s Guide Rev 10 Function Reference Freescale Semiconductor 215 Function Reference 7 1 101 iwcfg set sec type Synopsis uint 32 iwcfg set sec type uint 32 dev num char ptr sec type Parameters dev num in Device identification index ow on ow sec type in Security type Accepted values are none wep wpa wpa2 Description Set security type to device Return Value e ENET OK success ENETERR INVALID DEVICE Example See the iwcfg set passphrase example Freescale MQX RTCS User s Guide Rev 10 216 Freescale Semiconductor 7 1 102 iwcfg_get_sectype Synopsis uint 32 iwcfg get sec type uint 32 dev num char ptr sec type Parameters dev num in Device identification index sec type out Security type string Description Get security type from device Possible values are none wep wpa wpa2 Return Value e ENET OK success ENETERR INVALID DEVICE Freescale MQX RTCS User s Guide Rev 10 Function Reference Freescale Semiconductor 217 Function Reference 7 1 103 iwcfg set power Synopsis uint 32 iwcfg set power
289. r to an I O handle Second parameter flags ignored must be zero Returns a pointer to a PCB WRITE Called by PPP Driver to send data First parameter pointer to an I O handle Second parameter pointer to a PCB to send Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 331 A Data Types Third parameter Flags Zero use negotiated options One use default HDLC options IOCTL Called by PPP Driver to store and set I O control commands First parameter pointer to an I O handle Second parameter command to use Third parameter pointer to the value of the command Returns a status code Freescale MQX RTCS User s Guide Rev 10 332 Freescale Semiconductor 8 3 2 ARP_STATS A pointer to this structure is returned by ARP_stats typedef struct uint 32 ST RX TOTAL uint 32 ST RX MISSED uint 32 ST RX DISCARDED uint 32 ST RX ERRORS uint 32 ST Te TOTAL uint 32 ST TX MISSED uint 32 ST TX DISCARDED uint 32 ST TX ERRORS RTCS ERROR STRUCT ERR RX RTCS ERROR STRUCT ERR TX uint 32 ST RX REQUESTS uint 32 ST RX REPLIES uint 32 ST TX REQUESTS uint 32 ST TX REPLIES uint 32 ST ALLOCS FAILED uint 32 ST CACHE HITS uint 32 ST CACHE MISSES uint 32 ST PKT DISCARDS ARP STATS _PTR_ ARP STATS PTR ST RX TOTAL Received total
290. re void Description This function sends authentification failure trap type 2 message Return Value See Also SNMP trap authenticationFailure Freescale MQX RTCS User s Guide Rev 10 310 Freescale Semiconductor Function Reference 7 1 161 SNMPv2_trap_linkDown Synopsis void SNMPv2 trap linkDown pointer ihandle Parameters ihandle in interface index Description This function sends link down trap type 2 message Return Value See Also e SNMP trap linkDown Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 311 Function Reference 7 1 162 SNMPv2_trap_linkUp Synopsis void SNMPv2 trap linkUp pointer ihandle Parameters ihandle in interface index Description This function sends link up trap type 2 message Return Value See Also e SNMP trap linkUpQ Freescale MQX RTCS User s Guide Rev 10 312 Freescale Semiconductor Function Reference 7 1 163 SNMPv2_trap_userSpec Synopsis void SNMPv2 trap userSpec RTCSMIB NODE PTR trap node Parameters trap node in user specific trap node Description This function sends user specified trap type 2 message Return Value See Also SNMP trap userSpec Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 313 Function Reference 7 1 1464 SNTP init Starts the SNTP Client task Synopsis uint 32 SNTP init char ptr name uint 32 priority uint 32 stacksize
291. reescale Semiconductor 253 Function Reference 7 1 131 RTCS_if_bind_DHCP_flagged Gets an IP address using DHCP and binds it to the device interface using parameters defined by the flags in dhcp h 7 1 131 1 Synopsis uint 32 RTCS if bind DHCP flagged _rtcs if handle rtcs if handle DHCP DATA STRUCT PTR params char ptr opiptr uint_32 optlen Parameters rtcs_if_handle in RTCS interface handle params in Optional parameters params gt CHOICE_ FUNC params gt BIND_FUNC params gt REBIND_FUNC params gt UNBIND_FUNC params gt FAILURE_FUNC params gt FLAGS optptr in One of the following Pointer to the buffer of DHCP params see RFC 2132 NULL optlen in Number of bytes in the buffer pointed to by optptr Description Function RTCS if bind DHCP flagged uses DHCP to get an IP address and bind it to the device interface The TCPIP PARM IF DHCP structure is defined in dhcp_prv h The FLAGS are defined in dhcp h Parameter rtcs if handle is returned by RTCS if add To have the DHCP client accept offered IP addresses without probing the network do not set DHCP SEND PROBE in params gt FLAGS This function blocks until DHCP completes initialization but not until it binds the interface Return Value e RTCS OK success Error code failure See Also e RICS if add e RTCS if bind RTGS if bind BOOTP Freescale MQX RTCS User s Guide Rev 10 254 Freescale Semic
292. rence 7 1 20 DHCP_option_int16 Adds a 16 bit value to the list of DHCP options for DHCP Server Synopsis boolean DHCP option int16 uchar ptr PTR_ optptr uint_32 PTR optlen uchar opttype uint 16 optval Parameters optptr in out Pointer to the option list optlen in out Pointer to the number of bytes remaining in the option list Passed in before optval is added Passed out after optval is added opttype in Option type to add to the list see RFC 2132 optval in Value to add Description Function DHCP option int16 adds the 16 bit value optval to the list of DHCP options for DHCP Server The application subsequently passes parameter optptr pointer to the option list to DHCPSRV ippool add Return Value TRUE success FALSE failure not enough room in the option list See Also DHCPCLNT find option e DHCPSRV ippool add e DHCP option addr DHCP option addrlist e DHCP option int8 e DHCP option int32 e DHCP option string e DHCP option variable Example See DHCPSRV init Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 121 Function Reference 7 1 24 DHCP_option_int32 Adds a 32 bit value to the list of DHCP options for DHCP Server Synopsis boolean DHCP option int32 uchar ptr _PTR_ optptr uint 32 PTR optlen uchar opttype uint 32 optval Parameters optptr in out Pointer to the option list
293. returns the last TFTP server name if such was assigned by the last DHCP or BOOTP bind process Return Value Pointer to server name string See Also e ipcfg get tftp serveraddress e ipcfg get boot filename Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 197 Function Reference 7 1 83 ipcfg get boot filename Returns the TFTP boot filename if any Synopsis uchar ptr ipcfg get boot filename uint 32 device Parameters device in device identification Description This function returns the last boot file name if such was assigned by the last DHCP or BOOTP bind process Return Value Pointer to boot filename string See Also e ipcfg get tftp serveraddress e ipcfg get tftp servername Freescale MQX RTCS User s Guide Rev 10 198 Freescale Semiconductor Function Reference 7 1 84 ipcfg poll dhcp Polls finishes the Ethernet device DHCP binding process Synopsis uint 32 ipcfg poll dhcp uint 32 device boolean try auto ip IPCFG IP ADDRESS DATA PTR auto ip data Parameters device in device identification try auto ip in try the auto ip automatic assign address if DHCP binding fails auto ip data in ip mask and gateway address information to be used if DHCP bind fails Description See ipefg bind dhcp Return Value IPCFG OK success e RTCSERR IPCFG BUSY RTCSERR IPCFG DEVICE NUMBER RTCSERR IPCFG INIT e RTCSERR IPCFG BIND See Also e ipc
294. rface already intialized by other RTCS calls Return Value IPCFG OK success RTCSERR IPCFG BUSY RTCSERR IPCFG DEVICE NUMBER RTCSERR IPCFG INIT See Also ipcfg init device Example Fdefine ENET IPADDR IPADDR 192 168 1 4 define ENET IPMASK IPADDR 255 255 255 0 define ENET IPGATEWAY IPADDR 192 168 1 1 uint 32 setup network void uint_32 error IPCFG IP ADDRESS DATA ip data enet address enet address enet handle ehandle rtcs if handle ihandle ip data ip ENET IPADDR ip data mask ENET IPMASK ip data gateway ENET IPGATEWAY error RTCS create if error return error ENET get mac address BSP DEFAULT ENET DEVICE ENET IPADDR enet address error ENET initialize BSP DEFAULT ENET DEVICE enet address 0 amp ehandle if error return error Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 175 Function Reference error RTCS if add ehandle RTCS IF ENET amp ihandle if error return error error ipcfg init interface BSP DEFAULT ENET DEVICE ihandle if error return error return ipcfg bind autoip BSP DEFAULT ENET DEVICE amp ip data Freescale MQX RTCS User s Guide Rev 10 176 Freescale Semiconductor 7 1 65 ipcfg bind boot Binds Ethernet device to network using the BOOT procotol Synopsis uint 32 ipcfg bind boot uint 32 device Parameters device in device identification Description F
295. rnet Driver Initialize PPPoE Server by calling pppoe server init with the PPPOE SERVER INIT DATA STRUCT to get a PPPoE Server handle Call pppoe server if add with the ethernet handle and PPPoE Server handle to register the ethernet interface with PPPoE Server and open discovery and session protocols for the ethernet port Continue as for PPP Driver Table 4 2 Summary Using PPP over Ethernet Driver iopcb pppoe client destroy Destroys the PPPoE Client task and frees the allocated resources iopcb pppoe client init Initializes PPPoE Client _pppoe_client_stats Gets a pointer to the statistics for the PPPoE Client _pppoe_server_destroy Destroys the PPPoE Server task and frees the allocated resources pppoe_server_if_add Adds an ethernet interface to the PPPoE Server pppoe_server_if_remove Removes the ethernet interface to the PPPoE Server pppoe_server_if_stats Gets a pointer to statistics on the ethernet interface _pppoe_server_init Initializes PPPoE Server pppoe_server_session_stats Gets a pointer to statistics on the PPP session Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 63 Point to Point Drivers 4 3 2 Examples Using PPP over Ethernet Driver 4 3 2 1 Example Initializing the Ethernet Device and PPPoE Server void Main task uint 32 vo
296. robing flag Description By default the RTCS DHCP server probes the network for a requested IP address before issuing the address to a client If the server receives a response it sends a NAK reply and waits for the client to request a new address If you have previously disabled probing pass the DICPSVR FLAG DO PROBE flag to DHCPSRvV set config flag on to reenable probing Return Value e RTCS OK success Error code failure See Also DHCPSRV set config flag off e DHCPSRV init Example define DHCP DO PROBING 1 int dhcp do probing DHCP DO PROBING init setup if dhcp do probing DHCPSRV set config flag on DHCPSVR FLAG DO PROBE else DHCPSRV set config flag off DHCPSVR FLAG DO PROBE Freescale MQX RTCS User s Guide Rev 10 132 Freescale Semiconductor Function Reference 7 1 31 DNS init Starts a DNS client in order to use DNS services Synopsis uint 32 DNS init void Description Function DNS init starts a DNS client in order to use DNS services and creates DNS Resolver task Before your application calls the function it should bind an IP address to an interface by calling one of the RTCS if bind family of functions Return Value RTCS OK success Error code The function returns an error if it cannot do any of the following Allocate memory for DNS control structures Create a temporary datagram socket Detach from the tempor
297. rs rtcs if handle in RTCS interface handle from RTCS if add Return Value Pointer to the ARP STATS structure for rtcs if handle success e NULL failure rtcs if handle is invalid See Also ENET get stats CMP stats e inet pton e IPIF stats e RTCS if add e TCP stats e UDP stats ARP STATS Example Use RTCS statistics functions to display received packets statistics void display rx stats void IP STATS PTR ip IGMP STATS PTR igmp IPIF STATS ipif ICMP STATS PTR icmp UDP_STATS PTR udp TCP STATS PTR tcp ARP_STATS PTR arp _rtcs_if handle ihandle enet handle ehandle ENET initialize ENET DEVICE enet local 0 amp ehandle RTCS if add ehandle RTCS IF ENET amp ihandle ip IP Stats igmp IGMP stats ipif IPIF stats ihandle icmp ICMP stats udp UDP stats tcp TCP stats arp ARP stats ihandle Freescale MQX RTCS User s Guide Rev 10 112 Freescale Semiconductor Function Reference printf n d IP packets received ip gt ST RX TOTAL printf An d IGMP packets received igmp gt ST RX TOTAL printf An d IPIF packets received ipif gt ST RX TOTAL printf n d TCP packets received tcp gt ST RX TOTAL printf Mn d UDP packets received udp gt ST RX TOTAL printf ind ICMP packets received icmp gt ST RX TOTAL printf Mn d ARP packets rece
298. s RTCS OK printf inError getpeername failed with error code 1x status else printf inRemote address family is x remote sin sin family printf inRemote port is d remote sin sin port Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 151 Function Reference printf inRemote IP address is lx remote sin sin addr s addr Freescale MQX RTCS User s Guide Rev 10 152 Freescale Semiconductor Function Reference 7 1 45 getsockname Gets the local endpoint identifier of the socket Synopsis uint 32 getsockname uint 32 socket sockaddr _PTR_ name uint_16 _PTR_ namelen Parameters socket in Socket handle name out Pointer to a placeholder for the remote endpoint identifier of the socket namelen in out When passed in Pointer to the length in bytes of what name points to When passed out Full size in bytes of the remote endpoint identifier Description Function getsockname returns the local endpoint for the socket as was defined by bind This function blocks but the command is immediately serviced and replied to Return Value e RTCS OK success Specific error code failure See Also e bind getpeername socket Example uint 32 handle sockaddr in local sin uint 32 status uint 16 namelen namelen sizeof sockaddr in status getsockname handle struct sockaddr amp local sin amp name
299. s ST RX INFO REQ Received Information Requests ST RX INFO REPLY Received Information Replies ST RX OTHER Received all other types ST TX DESTUNREACH Transmitted Destination Unreachables ST TX TIMEEXCEED Transmitted Time Exceeded ST TX PARMPROB Transmitted Parameter Problems ST TX SRCQUENCH Transmitted Source Quenches ST TX REDIRECT Transmitted Redirects Freescale MQX RTCS User s Guide Rev 10 352 Freescale Semiconductor ST TX ECHO REQ Transmitted Echo Requests ST TX ECHO REPLY Transmitted Echo Replies ST TX TIME REQ Transmitted Timestamp Requests ST TX TIME REPLY Transmitted Timestamp Replies ST TX INFO REQ Transmitted Information Requests ST TX INFO REPLY Transmitted Information Replies ST TX OTHER Transmitted all other types Freescale MQX RTCS User s Guide Rev 10 Data Types Freescale Semiconductor 353 AN Data Types 8 3 15 IGMP STATS A pointer to this structure is returned by IGMP stats typedef struct uint 32 ST RX TOTAL uint 32 ST RX MISSED uint 32 ST RX DISCARDED uint 32 ST RX ERRORS wink 39 ST TX TOTAL uint 32 ST TX MISSED uint 32 ST TX DISCARDED uint 32 ST TX ERRORS RTCS ERROR STRUCT ERR RX RTCS ERROR STRUCT ERR TX uint 32 ST RX BAD TYPE uint 32 ST RX BAD CHECKSUM uint 32 ST RX SMALL DGRAM uint 32 ST RX QUERY uint 32 ST RX REPORT uint 32 ST TX QUERY _32 ST TX REPORT
300. s Guide Rev 10 Freescale Semiconductor 41 Setting Up the RTCS Freescale MQX RTCS User s Guide Rev 10 42 Freescale Semiconductor Chapter 3 Using Sockets 3 1 Before You Begin This chapter describes how to use RTCS and its sockets After an application sets up RTCS it uses a socket interface to communicate with other applications or servers over a TCP IP network For information about See Data types mentioned in this Chapter 8 Data Types chapter MQX MQX User s Guide MQX Reference Protocols Section Appendix A Protocols and Policies Prototypes for functions mentioned Chapter 7 Function Reference in this chapter Setting up RTCS Chapter 2 Setting Up the RTCS Remember you can change RTCS running parameters anytime RTCS uses some global variables after an application has created it All the variables have default values most of which you Note need never change If you want to change the values an application can do so anytime after it creates RTCS that is anytime after it calls RTCS create 3 2 Protocols Supported RTCS sockets provide an interface to the following protocols e TCP e UDP 3 3 Socket Definition A socket is an abstraction that identifies an endpoint and includes A type of socket one of datagram uses UDP stream uses TCP A socket address which is identified by port number Freescale MQX
301. s are configured to generate the resulting binary library file in the top level lib lt board gt lt compiler gt rtcs directory For example the CodeWarrior libraries for the M52259EVB board are built into the ib m52259evb cw rtcs directory The RTCS build project is also set up to execute post build batch file which copies all the public header files to the destination directory This makes the output ib directory the only place accessed by Freescale MQX RTCS User s Guide Rev 10 92 Freescale Semiconductor Rebuilding the application code The projects of MQX applications which need to use the RTCS services do not need to make any reference to the RTCS source tree at all 6 4 2 Build Targets Code Warrior development environment enables to have multiple build configurations so called build targets All projects in the Freescale MQX RTCS contain at least two build targets Debug Target compiler optimizations are set low to enable easy debugging Libraries built using this target are named with q postfix for example ib m52259evb cw rtcs rtcs_d a Release Target compiler optimizations are set to maximum to achieve the smallest code size and fast execution The resulting code is very hard to debug Generated library name does not get any postfix for example ib m52259evb cw rtcs rtcs a 6 5 Rebuilding Freescale MQX RTCS Rebuilding the MQX RTCS library is a simple task which involves only opening the pro
302. s of a static buffer that contains value and length of variable object must be static because SNMP does not free it OBJECT ID RTCSMIB NODETYPE OID PTR RTCSMIB NODE PTR Pointer to Address of an initialized RTCSMIB NODE variable RTCSMIB NODETYPE OID FN RTCSMIB OID FN PTR function pointer RTCSMIB NODE PTR function pointer Pointer to function that takes an instance pointer void returning address of an initialized RTCSMIB NODE structure Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 85 RTCS Applications Table Row Objects For each variable object that is in a table you must provide MIB find objectname function where objectname is the name of the variable object See the 2 3 c file in the rtcs source snmp for the example boolean MIB find objectname uint 32 op IN pointer index IN pointer _PTR_ instance OUT Writable Objects For each variable object that is writable you must provide MIB set objectname function where objectname is the name of the variable object See the 2 3 c file in the rtcs source snmp for the example uint 32 MIB set objectname pointer instance IN uchar ptr value ptr OUT uint 32 value len OUT instance NULL if objectname is not in a table or is a pointer returned by MIB find objectname value ptr Pointer to the value to which the object is to be set
303. ses all ports within a specified range as defined in the nat h header file The range of ports can be changed dynamically through the setsockopt function which accepts a NAT port structure nat ports The structure provides the lower and higher bound of port numbers used by NAT TCP UDP and ICMP ID By default the minimum port number is 10000 and the maximum port number is 20000 The minimum and maximum port numbers are overwritten each time the application provides a nat ports structure To avoid changing an existing port number the application must supply a zero value for the minimum or maximum The application must not use reserved ports and ICMP queries should not use these ports as sequence numbers When the session is over NAT performs address unbinding and cleans up automatically 2 15 3 Disabling NAT Application Level Gateways The active TFTP ALG and FTP ALG are resident on the NAT device when NAT is started If they are not needed to perform application specific payload monitoring and alterations they can be disabled by Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 27 Setting Up the RTCS redefining the NAT alg table table at compile time The table corrects and acknowledges numbers with source or destination port TFTP and FTP The NAT alg table table is defined in natalg c It contains an array of function pointers to ALGs An application can use only the ALGs that are in the table When
304. sions between IPsec hosts For more information refer to one of the following RFCs PF KEY Key Management API Version 2 RFC 2367 Security Architecture for the Internet Protocol RFC 2401 IP Authentication Header RFC 2402 The Use of HMAC MD5 96 within ESP and AH RFC 2403 The Use of HMAC SHA 1 96 within ESP and AH RFC 2404 The ESP DES CBC Cipher Algorithm With Explicit IV RFC 2405 IP Encapsulating Security Payload ESP RFC 2406 HMAC Keyed Hashing for Message Authentication RFC 2104 IP Security Document Roadmap RFC 2411 The NULL Encryption Algorithm and Its Use With IPsec RFC 2410 8 7 NAT NAT helps to solve the problem of IP address depletion Under NAT a few IP address ranges are reserved as private realms and are not forwarded on the Internet They can thus be reused by multiple organizations without risking address conflict Public IP addresses must be globally unique private IP addresses may be reused by any organization and need only be locally unique inside the organization A NAT router acts as a gateway between the two realms The router maps reusable local IP addresses to globally unique addresses and the other way around NAT allows hosts in a private network to transparently communicate with hosts outside of the network NAT runs on the router that connects the private network to a public network and it modifies all outbound packets that pass through the router by making the router t
305. sponds to R2 as defined in RFC 793 and is sometimes called the hard timeout It indicates how much time RTCS spends attempting to establish a connection before it gives up Comments If the remote endpoint does not acknowledge a sent segment within the connect timeout as would happen if a cable breaks for example RTCS shuts down the socket connection and all function calls that use the connection return Receive Wait Nowait Option name OPT RECEIVE NOWAIT Protocol level SOL UDP Values TRUE recv and recvfrom return immediately regardless of whether data to be received is present FALSE recv and recvfrom wait until data to be received is present Default value FALSE Change Anytime Socket type Datagram Comments Freescale MQX RTCS User s Guide Rev 10 284 Freescale Semiconductor IGMP Add Membership Function Reference Option name RTCS_SO_IGMP_ADD_MEMBERSHIP Protocol level SOL_IGMP Values Default value Not in a group Change Anytime Socket type Datagram Comments IGMP must be in the RTCS protocol table To join a multicast group uint_32 sock struct ip mreg group group imr multiaddr multicast ip address group imr interface local ip address error setsockopt sock SOL IGMP RTCS SO IGMP ADD MEMBERSHIP amp group sizeof group IGMP Drop Membership Option name RT
306. ss ENETERR INVALID DEVICE Example define DEFAULT DEVICE char 20 ssid_name iwcfg get mode DEFAULT DEVICE amp ssid name Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 211 Function Reference 7 1 97 Synopsis iwcfg_set_wep_key uint_32 iwcfg set wep key Parameters uint 32 dev num char ptr wep key uint 32 key len uint 32 key index dev num in Device identification index wep key in Wep key key len in Lenght of the key key index in Aditional optional device specific parameters Index must be lower than 256 Description Set wep key to wifi device Return Value e ENET OK success e ENETERR INVALID DEVICE Example iwcfg set wep key DEFAULT DEVICE DEMOCFG WEP KEY strlen DEMOCFG WEP Di EMOCFG W EP K EY INDEX Freescale MQX RTCS User s Guide Rev 10 212 Freescale Semiconductor Function Reference 7 1 98 wcfg_get_wep_key Synopsis uint 32 iwcfg get wep key uint 32 dev num char ptr wep key uint 32 key index Parameters dev num in Device identification index wep key in Wep key key index in Aditional optional device specific parameters Index must be lower than 256 Description Get the wep key Return Value e ENET OK success e ENETERR INVALID DEVICE Freescale MQX RTCS
307. ssion runtime data field of pointers to session specific structure Freescale MQX RTCS User s Guide Rev 10 Data Types Freescale Semiconductor 349 Data Types 8 3 14 ICMP_STATS A pointer to this structure is returned by ICMP_stats typedef struct uin uin uin uin uin uin uin uin tb 32 t 32 t 32 Lt 32 Co N w N E cr scr oct CO CO N N si a sq 81 sq 81 81 a P RX TOTAL RX MISSED RX DISCARDED RX ERRORS P TX TOTAL l TX MISSED l TX DISCARDED TX ERRORS RTCS ERROR STRUCT ERR RX RTCS ERROR STRUCT ERR TX uint 32 ST RX BAD CODE uint 32 ST RX BAD CHECKSUM uint 32 ST RX SMALL DGRAM uint 32 ST RX RD NOTGATE uint 32 ST RX DESTUNREACH uint 32 ST RX TIMEEXCEED uint 32 ST RX PARMPROB uint 32 ST RX SRCQUENCH uint 32 ST RX REDIRECT uint 32 ST RX ECHO REQ uint 32 ST RX ECHO REPLY uint 32 ST RX TIME REQ uint 32 ST RX TIME REPLY uint 32 ST RX INFO REQ uint 32 ST RX INFO REPLY uint 32 ST RX OTHER uint 32 ST TX DESTUNREACH uint 32 ST TX TIMEEXCEED uint 32 ST TX PARMPROB uint 32 ST TX SRCQUENCH uint 32 ST TX REDIRECT uint 32 ST TX ECHO REO uint 32 ST TX ECHO REPLY uint 32 ST TX TIME REQ uint 32 ST TX TIME REPLY uint 32 ST TX INFO REQ uint 32 ST TX INFO REPLY wint 32 ST TX OTHER ICMP STATS PTR ICMP STATS PTR 8 3 14 0 1 ST RX TOTAL Total number of received
308. standard ASN 1 encoded type One of INTEGER OCTET for OCTET STRING OBJECT for OBJECT IDENTIFIER SEQUENCE for SEQUENCE and SEQUENCE OF IpAddress Counter Gauge TimeTicks Opaque access required for leaf nodes object accessibility read only read write write only not accessible status required for leaf nodes this field is ignored but should be present for leaf node definition index required for table row objects row identifier object name one for each of the table row indices Each such index must be subsequently defined as a variable object with the table entry as its parent Freescale MQX RTCS User s Guide Rev 10 82 Freescale Semiconductor RTCS Applications Examples Object definition for the system subtree object that is a non leaf node Defines object system as the child number one of node mib 2 System mib 2 1 Object definition for the syspescr variable in the system subtree sysDescr is child number one of node system It is a variable of type OCTET STRING it is read only and its implementation is mandatory this information is not used sysDescr system 1 OCTET read only mandatory e Object definition for the udpEntry table entry The line defines the format of a uapgEnt ry entry in the udpTable table The entry is indexed by variables udpaddr and udpPort The object definition for udpAddr and one for udpPort shou
309. struct void CODE PTR IP UP pointer void CODE PTR IP DOWN pointer pointer IP PARAM unsigned ACCEPT LOCAL ADDR L unsigned ACCEPT REMOTE ADDR 1 unsigned DEFAULT NETMASK ER unsigned DEFAULT ROUTE L unsigned NEG LOCAL DNS L unsigned NEG REMOTE DNS L unsigned ACCEPT_LOCAL DNS 1 Ignored if NEG_LOCAL DNS 0 unsigned ACCEPT REMOTE DNS 1 Ignored if NEG REMOTE DNS 0 unsigned 0 ip address OCAL ADDR ip address REMOTE ADDR ip address NETMASK Ignored if DEFAULT NETMASK 1 ip address CAL DNS Ignored if NEG LOCAL DNS 0 ip address REMOTE DNS Ignored if NE G REMOTE IPCP DATA STRUCT _PTR_ IPCP DATA STRUCT _DNS 0 PTR IP UP IP DOWN IP PARAM RTCS calls With When IPCP successfully IP UP IP PARAM Enters the opened state IP DOWN IP PARAM Leaves the opened state ACCEPT LOCAL ADDR LOCAL ADDR IPCP attempts to negotiate LOCAL ADDR as its local IP address If ACCEPT LOCAL ADDR is IPCP does this TRUE Allows the peer to negotiate a different local IP address FALSE Accepts only LOCAL ADDR as its local IP address ACCEPT REMOTE ADDR REMOTE ADDR Freescale MQX RTCS User s Guide Rev 10 Data Types Freescale Semiconductor 361 Data Types IPCP attempts to negotiate REMOTE ADDR as the peer IP address
310. structure returned by httpd init or httpd server init val in pointer to string with index page filename char ptr type Description This macro sets the file name relative path to the default HTTP server page Example HTTPD ROOT DIR STRUCT root dir mM tfs usb Maan e 0 O table termination record allocate default values params httpd default params NULL if params 1 server httpd init params HTTPD SET PARAM ROOT DIR server root dir HTTPD SET PARAM INDEX PAGE server index htm Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 163 Function Reference 7 1 55 HTTPD SET PARAM FN TBL Macro setting the HTTP server ASP like callback functions table Synopsis HTTPD SET PARAM FN TBL server val Parameters server in pointer to server structure returned by httpd init or httpd server init val in pointer to script support functions table array of HTTPD FN LINK STRUCT Example HTTPD FN LINK STRUCT cgi Ink tbl time fn time 0 O table termination record H server initialization HTTPD SET PARAM FN TBL server fn Ink tbl Freescale MQX RTCS User s Guide Rev 10 164 Freescale Semiconductor 7 1 56 HTTPD SET_PARAM CGI TBL Macro setting the HTTP server CGI callback functions table Synopsis HTTPD SET PARAM CGI TBL server val Parameters Function Ref
311. t accompanying the Freescale MQX RTOS to see if there are any new RTCS features supported The major changes in the RTCS introduced in Freescale MQX RTOS distribution are The RTCS is now distributed within the Freescale MQX RTOS package Also the RTCS adopts version numbering of the Freescale MQX RTOS distribution starts with 3 0 The RTCS build process and compile time configuration follows the same principles as other MQX core libraries see more details in Chapter 6 Rebuilding The RTCS Shell and all shell functions were removed from RTCS library and were moved to a separate library in the Freescale MQX distribution Freescale MQX contains just the core parts of the original RTCS package The IPsec PPPoE SNMPv3 and some other components are not included in the distribution although this document may still refer to such features Anew HTTP server functionality was added in the Freescale MQX release Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 17 Setting Up the RTCS Figure 2 1 Protocols and Policies Discussed in This Manual Table 2 1 RTCS Features Rrotoco 9 Description RFC policy ARP Address Resolution Protocol for ethernet 826 Assigned RFC 1700 is outdated for current numbers Numbers see http www iana org numbers html BootP Bootstrap Protocol 951 1542 CCP Compression Control Protocol used by PPP 1692 CHAP Challen
312. t cannot access the MIB See Also SNMP init Example See SNMP init Freescale MQX RTCS User s Guide Rev 10 222 Freescale Semiconductor Function Reference 7 1 107 MIB_find_objectname Find object in table Synopsis boolean MIB find objectname uint 32 op pointer index pointer PTR instance Parameters op in index in Pointer to a structure that contains the table index instance out Description For each variable object that is in a table you must provide MIB find objectname where objectname is the name of the variable object The function gets an instance pointer Return Value e SNMP ERROR noError success e SNMP ERROR wrongValue SNMP ERROR inconsistentValue SNMP ERROR wrongLength SNMP ERROR resourceUnavailable SNMP ERROR genErr See Also SNMP init e MIB1213 init Example Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 223 Function Reference 7 1 108 MIB_set_objectname Set name for writable object in table Synopsis uint 32 MIB set objectname pointer instance uchar ptr value ptr uint 32 value len Parameters instance in value ptr out Pointer to the value to which to set objectname value len out Length in bytes of the value Description For each writable variable object you must provide MIB set objectname where objectname is the name of the variable object See Also SNMP init e MIB
313. table If Function returns More than eight aliases are encountered or the Immediately alias names the loop Name does not exist in the public name space Name error Name is an alias Canonical name and its IP address Query is successful Name and its IP address Query times out and no response is received Timeout error Description This function provides information on server name where name is a domain name or IP address For a full description of the requirements for formatting name see RFCs 1034 and 1035 If name is terminated by a period the name is an absolute domain name NULL follows the period and NULL is the default name for the root server of any domain tree If the string is not terminated by a period the name is a relative domain name For more information on setting up and using DNS Resolver see Section 5 4 DNS Resolver If the function is successful a static HOSTENT STRUCT is overwritten every time that the function is called The following fields in the HOSTENT STRUCT always have the following values Field Value h addrtype AF INET h length sizeof struct in addr Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 149 Function Reference See Also DNS init gethostbyaddr e HOSTENT STRUCT Example HOSTENT STRUCT char char ptr char ptr char ptr uint 32 ip addr strcpy string sparky com
314. te configuration options for a PPP link connection A logical binding between two endpoints For PPP the term is link connection based mode A transport protocol that has three distinct phases Establishment two or more users are bound to a connection Data transfer data is exchanged between the users Release the binding is terminated connectionless mode A transport protocol that has a single phase involving control mechanisms such as addressing in addition to data transfer CRC Cyclic redundancy check a type of checksum A small integer computed from a sequence of bits that is used to detect errors following the transmission of the bits See also CC TT 16 and CCITT 32 CSMA CD Carrier sense multiple access with collision detection The type of bus that ethernet uses to access a LAN With CSMA CD before an interface sends data to another interface on the network it listens for carrier wave to determine whether any interface is using the network The ability of all interfaces to listen for carrier wave is called carrier sense If no carrier wave is detected the data 1s sent Cyclic Redundancy Check See CRC Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 411 D datagram The unit of transmission in the network layer such as UDP or IP A datagram can be mapped to one or more packets that are passed to the data link layer Sometimes called a message data link layer That
315. tem Freescale MQX RTCS User s Guide Rev 10 76 Freescale Semiconductor RTCS Applications const HTTPD ROOT DIR STRUCT root dir ua tfs E usb Worm 0 O 5 9 4 Dynamic Content CGI Like Pages An application may register so called CGI Common Gateway Interface callback functions with the HTTP server The function is called back from the HTTP server when the client requests the assigned CGI file to be retrieved for example your server com cginame cgi Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 77 RTCS Applications The following declaration shows an example of CGI assingment map const HTTPD CGI LINK STRUCT cgi Ink tbl ipstat cgi ipstat icmpstat cgi icmpstat udpstat cgi udpstat tcpstat cgi tcpstat rtcdata cgi rtc data 0 0 Er The CGI callback functions and their assigned pages are registered by calling HTTPD SET PARAM CGI _TBL server HTTPD CGI LINK STRUCT cgi lnk tbl any time after the HTTP server is initialized and before it is run 5 9 5 Dynamic Content ASP Like Page Callbacks Special ASP Active Server Pages tags s x s gt may be embedded in the HTML files to provide a customized content without the need for generating the full server response as in the case of CGI handler The client application may register a callback function which is called anytime such an ASP tag is
316. ter 4 Point to Point Drivers Freescale MQX RTCS User s Guide Rev 10 24 Freescale Semiconductor Setting Up the RTCS 2 10 Adding Device Interfaces to RTCS After an application has initialized device interfaces it adds each interface to RTCS by calling RTCS if add with the device handle 2 10 1 Removing Device Interfaces from RTCS To remove a device interface from RTCS call RTCS if remove with the device handle 2 11 Binding IP Addresses to Device Interfaces After an application has added device interfaces to RTCS it binds one or more IP addresses to each An application can bind IP addresses to device interfaces in a number of ways To do this Call Bind an IP address that the application specifies RTCS if bind Bind an IP address that is obtained by using BootP RTCS if bind BOOTP DHCP RTCS if bind DHCP IPCP the only method that can be used for PPP RTCS if bind IPCP 2 11 14 Unbinding IP Addresses from Device Interfaces To unbind an IP address from a device interface call RTCS if unbind 2 12 Adding Gateways RTCS uses gateways to communicate with remote subnets Although an application usually adds gateways when it sets up the RTCS it can do so anytime To add a gateway call RTCS gate add with the IP address of the gateway and a network mask 2 12 1 Adding Default Gateways To add a default gateway call RTCS gate add ip address O 0 2 1
317. terface handle from PPP initialize Description Function iopcb open opens the I O PCB driver for PPP using handle ioppp returned by _iopcb_ppphdlc init or iopcb pppoe client init and saves PPP lowerup PPP lowerdown and PPP handle e When the frame driver is ready to send and receive frames it calls PPP lowerup with PPP handle e When the frame driver can no longer send or receive frames it calls PPP lowerdown with PPP handle Under some circumstances the frame driver calls PPP lowerup multiple times For example if it needs to dial a modem the frame driver calls PPP owerup every time a connection is established and PPP lowerdown every time carrier is lost Return Value None See Also e jopcb ppphdlc init e jopcb pppoe client init PPP initialize Example See Section 2 15 6 Example Setting Up RTCS Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 97 AN Function Reference 7 1 3 _iopcb_ppphdic_init Initializes the driver for the HDLC like framing device and gets a handle to the device Synopsis iopcb handle _iopcb ppphdlc init FILE PTR device Parameters device in Asynchronous serial device handle Description Function iopcb ppphdlce init uses the asynchronous serial device handle returned by fopen to initialize the driver for the HDLC like framing device and returns a handle to the device Return Value O PCB handle success
318. text Transfer Protocol See HTTP Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 415 I O Input output Refers to the transfer of commands or data across an interface ICMP Internet Control Message Protocol IGMP Internet Group Management Protocol indirect routing The process of sending an IP datagram to a router which forwards the datagram to its destination See also direct routing interface One of API software interface Demarcation between hardware and software hardware interface interface layer The layer in the internet suite of protocols that is responsible for transmission on a single physical network Internet Control Message Protocol See ICMP Internet Group Management Protocol See IGMP Internet Protocol See JP Internet Protocol Control Protocol See JPCP interoperate In RTCS the ability to communicate with a host that uses another protocol or another version of a protocol for example with RTCS an application can communicate fully with hosts that support RIPv2 and interoperate with hosts that support RIPv1 IP Internet Protocol The network protocol that offers a connectionless mode network protocol IP address See address IPCP Internet Protocol Control Protocol For RTCS it is the network control protocol for IP ISO International Organization for Standardization an international organization that sets standards for network protocols such as
319. ther Point to Point Protocol See PPP port See port number Portmapper The RPC program that maps remote programs to the port numbers to which they were bound port number A 16 bit number that identifies an application entity to a transport protocol Sometimes called a port POSIX Portable Operating System Interface produced by IEEE and standardized by ANSI and ISO PPP Point to Point Protocol A link layer protocol for sending multi protocol datagrams over point to point links PPP Driver The RTCS component that manages PPP devices PPP over Ethernet PPPoE A protocol that specifies how to build PPP sessions and encapsulate PPP packets over ethernet PPPoE has two distinct stages a Discovery stage and a PPP Session stage When a host wants to initiate a PPPoE session it must first perform Discovery to identify the ethernet MAC address of the peer and establish a PPPoE session ID While PPP defines a peer to peer relationship Discovery is inherently a client server relationship In the Discovery stage a host the client discovers an access concentrator the server Based on the network topology there might be more than one access concentrator with which the host can communicate The Discovery stage allows the host to discover all access concentrators and then select one When Discovery completes successfully both the host and the selected access concentrator have the information they will use to build their point to po
320. ting Up the RTCS 2 3 1 Protocol Stack Architecture Figure 2 2 shows the architecture ofthe RTCS stack and how the RTCS communicates with layers below and above it Application Figure 2 2 Protocol Stack Architecture Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 21 Setting Up the RTCS 2 4 Setting Up the RTCS An application follows a set of general steps to set up the RTCS The steps are summarized in Figure 2 3 and described in subsequent sections Define protocols Change creation parameters Create RTCS Initialize device interfaces Add device interfaces Bind IP addresses to device interfaces Add gateways Download and run boot file Enable RTCS event logging Figure 2 3 Steps to Set Up the RTCS 2 5 Defining RTCS Protocols When an application creates RTCS it uses a protocol table to determine which protocols to start and in which order to start them Refer to Section 8 3 32 RTCS protocol table in Chapter 8 Data Types for the list of available protocols You can add or remove protocols using the instructions provided there or provide your own table Freescale MQX RTCS User s Guide Rev 10 22 Freescale Semiconductor Setting Up the RTCS 2 6 Changing RTCS Creation Parameters RTCS uses some global variables when an application creates it All the variables have default values most of which you need never change If you want to ch
321. ting Up the RTCS printf AinFailed to initialize PPP Driver x error return _iopcb open pio PPP lowerup PPP lowerdown phandle error RTCS if add phandle RTCS IF PPP amp ihandle if error printf AnFailed to add interface for PPP error x error return _lwsem create amp ppp sem 0 mem zero amp ipcp data sizeof ipcp data ipcp data IP UP PPP linkup ipcp data IP DOWN NULL ipcp data IP PARAM amp ppp sem ipcp data ACCEPT LOCAL ADDR FALSE ipcp data ACCEPT REMOTE ADDR FALSE ipcp data LOCAL ADDR PPP LOCADDR ipcp data REMOTE ADDR PPP PEERADDR ipcp data DEFAULT NETMASK TRUE ipcp data DEFAULT ROUTE TRUE error RTCS if bind IPCP ihandle amp ipcp data if error printf AinFailed to bind interface for PPP rror x rror return _lwsem wait amp ppp_ sem printf AnPPP device s bound to X PPP DEVICE ipcp data LOCAL ADDR Install a default gateway RTCS gate add GATE ADDR INADDR ANY INADDR ANY 2 16 Compile Time Options RTCS is built with certain features that you can include or exclude by changing the value of compile time configuration options If you change a value you must rebuild RTCS For information about rebuilding RTCS see Chapter 6 Rebuilding Similarly as the PSP BSP or other system libraries included in the
322. tion If the socket is to be shut down with an abort operation the following actions occur e RTCS immediately discards the socket and the socket s internal send and receive buffers e The remote endpoint frees its socket immediately after it sends all the data that is in its send buffer Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 51 Using Sockets Table 3 2 Summary Socket Functions accept Accepts the next incoming stream connection and clones the socket to create a new socket which services the connection bind Identifies the local application endpoint by providing a port number connect Establishes a stream connection with an application endpoint or sets a remote endpoint for a datagram socket getpeername Determines the peer address port number endpoint of a connected socket getsockname Determines the local address port number endpoint of a bound socket getsockopt Gets the value of a socket option listen Allows incoming stream connections to be received on the port number that is identified by a socket recv Receives data on a stream or datagram socket recvfrom Receives data on a datagram socket RTCS_attachsock Gets access to a socket that is owned by another task RTCS_detachsock Relinquishes ownership of a socket RTCS_geterror Gets the reason why an RTCS function returned an error for the socket RTCS_select
323. tions Request a three minute lease DHCP option int32 amp optptr amp optlen DHCPOPT LEASE 180 Request a TFTP Server FILENAME and Finger Server DHCP option variable amp optptr amp optlen DHCPOPT PARAMLIST parm options 3 error inet aton 192 168 1 100 amp rebind address error inet aton 255 255 255 0 amp rebind mask error inet aton 192 168 1 2 amp rebind server Freescale MQX RTCS User s Guide Rev 10 262 Freescale Semiconductor Function Reference if error printf nFailed to convert IP addresses from dotted decimal error x error return error RTCS if rebind DHCP ihandle rebind address rebind mask lease rebind server amp params option array optptr option array if error printf AnDHCP boot failed error x error return Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 263 Function Reference 7 1 135 RTCS_if_remove Removes the device interface from RTCS Synopsis uint 32 RTCS if remove _rtcs if handle rtcs_if handle Parameters rtcs if handle in RTCS interface handle Description Function RTCS if remove removes the device interface associated with rtcs_if handle returned by RTCS if add from RTCS Return Value e RTCS OK success Error code failure See Also e RTCS if add e RTCS if rebind DHCP Freescale MQX RTCS User s Guide R
324. tlen 3 routers 3 jw x x x x SSE SC Ss Ge o CS I x ll BOB oo gog Serve addresses 192 168 0 129 to 192 168 0 135 inclusive DHCPSRV ippool add 0xC0A80081 7 amp dhcpsrv data dhcpsrv options optptr dhcpsrv options Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 129 Function Reference 7 1 28 DHCPSRV ippool add Gives DHCP Server the block of IP addresses to serve Synopsis uint 32 DHCPSRV ippool add ip address ipstart uint 32 ipnum DHCPSRV DATA STRUCT PTR jparams ptr uchar ptr optptr uint 32 optlen Parameters ipstart in First IP address to give ipnum in Number of IP addresses to give params ptr in Pointer to the configuration information that is associated with the IP addresses optptr in Pointer to the optional configuration information that is associated with the IP addresses optlen in Number of bytes that optptr points to Description Function DHCPSRV ippool add gives the DHCP server the block of IP addresses it serves The DHCP Server task must be created by calling DHCPSRV init before you call this function Return Value e RTCS OK success Error code failure See Also DHCPCLNT find option DHCP option addr DHCP option addrlist e DHCP option int8 DHCP option int16 DHCP option int32 DHCP option string e DHCP option variable e DHCPSRV_init e DHC
325. to this structure is an input parameter to DHCPSRV ippool add typedef struct dhcpsrv data struct ip address SERVERID uint 32 LEASE ip address MASK _ip address SADDR uchar SNAME 64 uchar FILE 128 DHCPSRV DATA STRUCT _PTR_ DHCPSRV DATA STRUCT PTR SERVERID IP address of the server LEASE Maximum allowable lease length MASK Subnet mask SADDR SADDR field in the DHCP packet header SNAME SNAME field in the DHCP packet header FILE FILE field in the DHCP packet header Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 337 Data Types 8 3 6 ENET_STATS A pointer to this structure is returned by ENET get stats typedef struct uint 32 ST RX TOTAL uint 32 ST RX MISSED uint 32 ST RX DISCARDED uint 32 ST RX ERRORS uint 32 ST TX TOTAL uint 32 ST TX MISSED uint 32 ST TX DISCARDED uint 32 ST TX ERRORS uint 32 ST TX COLLHIST 16 uint 32 ST RX ALIGN uint 32 ST RX FCS uint 32 ST RX RUNT uint 32 ST RX GIANT uint 32 ST RX LATECOLL uint 32 ST RX OVERRUN uint 32 ST TX SOE uint 32 ST TX DEFERRED uint 32 ST TX LATECOLL uint 32 ST TX EXCESSCOLL uint 32 ST TX CARRIER uint 32 ST TX UNDERRUN ENET STATS _PTR_ ENET STATS PTR ST RX TOTAL Received total ST RX MISSED Received missed packets ST RX DISCARDED Received discarded due to unrecognized protocol ST RX ERRORS Received discarded due t
326. ts ai socktype SOCK STREAM hints ai flags AI NUMERICHOST AI CANONNAME getaddrinfo FE80 260 4cFF FE68 234322 7007 amp hints amp foreign addrv6 res Socket tcp socket AF INET6 SOCK STREAM 0 error bind socket tcp struct sockaddr local addrv6 res ai addr sizeof struct sockaddr in6 error connect socket tcp struct sockaddr foreign addrv6 res gt ai addr sizeof struct sockaddr in6 Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 117 Function Reference 7 1 17 DHCP_find_option Searches a DHCP message for a specific option type Synopsis uchar ptr DHCP find option uchar ptr msgptr uint 32 msglen uchar option Parameters msgptr in out Pointer to the DHCP message msglen in out Pointer to the number of bytes in the message option in out Option type to search for see RFC 2131 Description The msgptr pointer points to an option in the DHCP message which is formatted according to RFCs 2131 and 2132 The application is responsible for parsing options and reading the values The returned pointer must be passed to one of the ntohl or ntohs macros to extract the value of the option The macros can convert the value into host byte order Return Value Pointer to the specified option in the DHCP message in network byte order success e NULL no option of the specified type exists See Also DHCPCLNT find option Exam
327. turns zero if HTTP task or all tasks were started successfully otherwise it returns non zero number If the return value is positive it reports how many session tasks could not be created If the return value is negative the single HTTP server task failed to start See Also e httpd server init Example define HTTPD SEPARATE TASK 0 select how to run the HTTP server HTTPD ROOT DIR STRUCT root dir wn bes Ps 0 O table termination record uH HTTPD STRUCT server server httpd server init root dir Alindex html if HTTPD SEPARATE TASK HTTPDCFG POLL MODE httpd server run server code continues here else while 1 httpd server poll server 1 user stuff come here only non blocking calls fendif Freescale MQX RTCS User s Guide Rev 10 160 Freescale Semiconductor Function Reference 7 1 52 httpd server poll Single step the HTTP server handling Synopsis void httpd server poll HTTPD STRUCT server int to Parameters server in pointer to main server structure HTTPD STRUCT returned by httpd init or httpd server init to in timeout for blocking functions during the poll processing for example socket functions Description If the HTTP server runs in polled mode HTTPDCFG POLL MODE set non zero in user config h an application can handle server processing by calling httpd server poll periodically
328. twork address The address is converted to a struct in6 addr and copied to dst which must be sizeof struct in6_ addr 16 bytes 128 bits long The allowed formats for IPv6 addresses follow these rules The format is x x x x x x x x This form consists of eight hexadecimal numbers each of which expresses a 16 bit value i e each x can be up to 4 hex digits A series of contiguous zero values in the preferred format can be abbreviated to Only one instance of can occur in an address For example the loopback address 0 0 0 0 0 0 0 1 can be abbreviated as 1 The wildcard address consisting of all zeroes can be written as Return Value RTCS_OK success RTCS ERROR failure Example a IPv4 protocol uint 32 temp Freescale MQX RTCS User s Guide Rev 10 168 Freescale Semiconductor Function Reference inet pton AF INET prn addr amp temp sizeof temp b IPv6 protocol in6 addr addr6 inet pton AF INET6 abcd ef12 3456 789a bcde 012 192 168 24 252 amp addr6 Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 169 Function Reference 7 1 60 inet ntop Converts an address src from network format usually a struct eiter in_addr or in6addr in network byte order to presentation format suitable for external display purposes Synopsis char inet ntop int 32 af const void src char dst socklen t size Parameters af in Family name
329. unction Reference Server address 142 123 203 66 0x8E7BCB42 Poll interval every 100 seconds UU error SNTP init SNTP client 7 1000 0x8E7BCB42 100 if error return error printf The SNTP client task is running return 0 Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 915 Function Reference 7 1 165 SNTP_oneshot Sets the time in UTC time using the SNTP protocol Synopsis uint_32 SNTP_oneshot _ip address destination uint_32 timeout Parameters destination in Where SNTP time requests are sent One of IP address of the time server unicast mode alocal broadcast address or multicast group anycast mode timeout in Amount of time in milliseconds to continue trying to obtain the time using SNTP Description This function sends an SNTP packet and waits for a reply If a reply is received before timeout elapses the time is set If no reply is received within the specified time RTCSERR TIMEOUT is returned The local time is set in UTC coordinated universal time The SNTP Client task works in unicast or anycast mode Return Value RTCS OK success RTCSERR INVALID PARAMETER failure resulting from destination not being specified RTCSERR TIMEOUT failure due to expiry of timeout value before SNTP could successfully receive the time Error code failure See Also SNTP init Freescale MQX RTCS User s Guide Rev 10
330. unction Reference This function tries to bind the device to network using BOOT protocol It also gathers information about TFTP server and file to download It is blocking function i e doesn t return until the process is finished or error occurs Any failure during bind leaves the network interface in unbound state Return Value e IPCFG OK success RTCSERR IPCFG BUSY RTCSERR IPCFG DEVICE NUMBER RTCSERR IPCFG INIT RTCSERR IPCFG BIND See Also ipcfg unbind Example define ENET IPADDR define ENET IPMASK define ENE IPADDR 192 1 T IPGATEWAY uint 32 setup network void uint 32 error enet address 68 1 4 IPADDR 255 255 255 0 IPADDR 192 168 1 1 enet address net address error RTCS create if error return error ENET get mac address BSP DEFAULT ENE EVICE ENET IPADDR e error ipcfg init device BSP DEFAULT ENET DEVICE enet address if error return error error ipcfg bind boot BSP DEFAULT E _ DEVICE if error return error TFTTIP ipcfg get tftp serveraddress BSP DEFAULT ENET DEVICE TFTPserver ipcfg get tftp servername BSP DEFAULT ENET DEVIC Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 177 Function Reference TFTPfile ipcfg get boot filename BSP DEFAULT ENET DEVICE
331. v 10 Freescale Semiconductor 343 Data Types 8 3 10 HTTPD PARAMS STRUCT typedef struct httpd params struct unsigned short port unsigned int max uri unsigned int max auth if HTTPDCFG POLL MODE unsigned int max ses unsigned int max line tendif HTTPD ROOT DIR STRUCT root dir char index page callback functions HTTPD CGI LINK STRUCT cgi Ink tbl HTTPD FN LINK STRUCT fn lnk tbl HTTPD AUTH CALLBACK auth fn char page401 char page403 char page404 HTTPD PARAMS STRUCT port HTTP Server listening port max uri maximal URI string length max auth maximal auth string length max ses maximal count of sessions max line maximal evaluated line length root dir pointer to root dir structure index page pointer to index page full path and name cgi Ink tbl cgi function callback table See HTTPD CGI LINK STRUCT fn Ink tbl Freescale MQX RTCS User s Guide Rev 10 344 Freescale Semiconductor A Data Types function callback table dynamic web pages See HTTPD FN LINK STRUCT auth fn callback for authentification function Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 345 Data Types 8 3 11 HTTPD_ROOT_DIR_STRUCT typedef struct httpd root dir struct char alias char path HTTPD ROOT DIR STRUCT alias symbolic name alias for path path absolut path Freescale MQX RTCS User s Guide Rev 10 346 Freescale Semicon
332. very packet If you set the field to zero _iopcb_pppoe_client_init sets it to the default value 3000 which is three seconds RTX MAX TIMEOUT Maximum time to wait before retransmitting a discovery packet If you set the field to zero _iopcb_ pppoe client init sets it to the default value 10000 which is ten seconds RTX MAX RETRY Number of requests to make before the connection request fails If you set the field to zero jopcb pppoe client init sets it to the default value ten SEND PADI FOR EVER If you set the field to TRUE PADI packets are sent until a reply is received from the access concentrator If you set the field to FALSE PADI packets are no longer sent if a reply is not received from the access concentrator CONNECTION TIME OUT Callback function that can inform the application of the PADI timeout The iopcb handle is passed to the callback function If the SEND PADI FOR EVER field is TRUE the function is not called If you set the field to NULL it is ignored SEND PADI TAGS EXTRA Callback function that can send extra tags for example vendor specific tags with PADI packets The uchar ptr parameter should be returned to the driver If you set the field to NULL it is ignored SEND PADR TAGS EXTRA Callback function that can send extra tags with PADR packets The parameter oftype uchar_ptr should be returned to the driver If you set the field to NULL it is ignored PARSE PADO TAGS EXTRA Callback fu
333. w Commands init lt mac gt Initialize Ethernet device once task start lt priority gt lt period gt stop Manage link status checking task dns add lt ipv4 gt del lt ipv4 gt ip ip mask lt gateway gt dhcp lt ipv4 gt mask lt gateway gt autoip lt ipv4 gt mask lt gateway gt Manage DNS IP list Support IPv4 only Bind with ip for IPv4 For IPv6 you should put ipv6 address only like ip lt ipv6 gt to bind IPv6 address manually Bind with dhcp use ip amp mask in case dhcp fails Support IPv4 only Obsolete use ip instead boot Bind with boot protocol unbind lt ipv6 gt Unbind network interface Using unbind without parameter will unbind IPv4 address from interface In case IPv6 you should use ipv6 address like parameter to unbind it from interface Parameters device Ethernet device number mac Ethernet MAC address priority Link status task MQX priority period Link status task check period ms ip IP address to use both families lt ipv4 gt IPv4 address to use Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 405 Internet Protocol Configuration lt ipv6 gt IPv6 address to use lt mask gt Network mask to use lt gateway gt Network gateway to use Example shell ipconf ig 0 off 3 03 UNBO
334. wd TPd rmdir LL hy BCL NEF Pd_unimplemented Pd_unimplemented Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 143 Function Reference y FTPd userfile userfile Start FTP Server error FTPd_init FTP server 7 if error return error printf AnFTP Server is running return 0 Freescale MQX RTCS User s Guide Rev 10 2000 144 Freescale Semiconductor Function Reference 7 1 40 FTP open Starts an FTP session Synopsis int 32 FTP open pointer PTR handle ptr ip address server addr FILE PTR ctrl fd Parameters handle ptr in FTP session handle server addr in IP address of the FTP server ctrl fd in Device to write control connection responses to Description This function establishes a connection to the specified FTP server If successful the functions FTP_command and FTP command data can be called to issue commands to the FTP Server Return Value An FTP response code success e l failure See Also e FTP close Example include lt mgx h gt finclude lt bsp h gt finclude lt rtcs h gt void main task uint 32 dummy Body pointer ftphandle int 32 response response FTP open amp ftphandle SERVER ADDRESS stdout if response 1 printf Couldn t open FTP session An return Endif response FTP command ftphandle USER anon
335. x Description This function may be used to retrieve all DNS addresses registerred manually of by DHCP binding process with the given Ethernet device Return Value DNS IP address Zero if n th address is not available See Also e ipcfg add dns ip e ipcfg del dns ip Freescale MQX RTCS User s Guide Rev 10 192 Freescale Semiconductor A Function Reference 7 1 78 ipcfg add dns ip Registers the DNS IP address with the Etherent device Synopsis boolean ipcfg add dns ip uint 32 device ip address address Parameters device in device identification address in DNS IP address to add Description This function adds the DNS IP address to the list assigned to given Ethernet device and starts the DNS machine if not running already Return Value TRUE if successful FALSE otherwise See Also ipcfg get dns ip e ipcfg del dns ip Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 193 AS Function Reference 7 1 79 ipcfg del dns ip Unregisters the DNS IP address Synopsis boolean ipcfg del dns ip uint 32 device ip address address Parameters device in device identification address in DNS IP address to be removed Description This function removes the DNS IP address from the list assigned to given Ethernet device Return Value TRUE if successful FALSE otherwise See Also e ipcfg get dns ip e ipcfg add dns ip Freescale MQX RTC
336. y application level gateway can interact with NAT to set up or use state information and modify application specific payload add protocol specific information to the NAT session entry Any application that carries or uses an IP address inside the application will not work with NAT unless the NAT is configured to do the appropriate translation See also NAT ARP Address Resolution Protocol which resolves a logical IP address to a physical ethernet address Freescale MQX RTCS User s Guide Rev 10 408 Freescale Semiconductor ARP cache The cache that ARP uses to maintain a list of IP to ethernet address pairs Assigned Numbers RFC 1700 Asynchronous Control Character Map See ACCM authentication Host authentication a process whereby PPP determines whether a host can use a link PPP lets the host use the link only if authentication passes See also CHAP and PAP e Message authentication the process whereby SNMPv3 associates a message with a particular originating entity during a session authentication protocol Used for host authentication only See also AP B big endian The endian format in which the most significant byte is the first byte in the word This endian format is also the network byte order See also byte swap host byte order and little endian BIN Binary code One format of a boot file See also COFF and SREC binary code See BIN bind verb The action of completing a socket s lo
337. ymous NrNn stdout response 3xx means Password Required if response gt 300 amp amp response lt 400 Freescale MQX RTCS User s Guide Rev 10 Freescale Semiconductor 145 Function Reference response FTP command ftphandle PASS password r n stdout Endif response 2xx means Logged In if response gt 200 amp amp response lt 300 response FTP command data ftphandle LIST r n stdout stdout FTPMODE_PORT FTPDIR_RECV Endif FTP close ftphandle stdout Endbody Freescale MQX RTCS User s Guide Rev 10 146 Freescale Semiconductor Function Reference 7 1 44 FTPSRV init Starts the FTP Server Synopsis uint 32 FTPSRV init char ptr name uint 32 priority uint 32 stacksize Parameters name in Name of the server s task priority in Priority of the server s task stacksize in Stack size for the server s task Description Function FTPSRV init starts the FTP Server with task priority priority we recommend that you make the priority lower than the priority of the RTCS task that is make it a higher number It also creates FTPSRV task Return Value e RTCS OK success Error code failure Example uint 32 error Start FTP Server error FTPSRV init FTP server 7 1000 if error return error printf NnFTP Server is running return 0 Freescale MQX
338. you remove an ALG from the table RTCS does not link the associated code with your application By default the table is defined as follows NAT ALG NAT alg table NAT ALG TFTP NAT ALG FTP NAT ALG ENDLIST a n To disable TFTP FTP and NAT payload monitoring and alterations redefine the table as follows at compile time NAT ALG NAT alg table NAT ALG ENDLIST uH 2 15 4 Getting NAT Statistics Statistics are supplied through a NAT STATS structure which is defined in nat h To get NAT statistics the application calls NAT stats 2 15 5 Supported Protocols The Freescale MQX implementation of NAT supports communications using the following protocols TCP and UDP sessions that do not contain port or address information in their data e ICMP HTTP Telnet e RPC and Portmapper e Echo e Quote of the day TFTP and FTP NAT has no effect on packets that are passed between hosts inside the private network regardless of the protocol that is being used to transfer the packet For more information about NAT see Section Appendix A Protocols and Policies Freescale MQX RTCS User s Guide Rev 10 28 Freescale Semiconductor 2 15 5 1 Setting Up the RTCS Limitations The Freescale MQX implementation of NAT does not support IGMP and IP multicast modes fragmented TCP and UDP packets IKE and IPsec SNMP public DNS queries of private hosts H 323 peer to peer co

Download Pdf Manuals

image

Related Search

Related Contents

MA35M Moisture Analyzer  Wolflite Rechargeable Safety Handlamp H-251A  Carte de fidélité saison 2013-2014  Hoja de Características CE-T1  「遠隔操作」運用ガイド  Right Arm 3 User Manual  

Copyright © All rights reserved.
Failed to retrieve file