
- •Preface
- •About this book
- •Intended audience
- •Using this book
- •Typographical conventions
- •Further reading
- •Feedback
- •Feedback on ARM TCP/IP
- •Feedback on this book
- •Introduction
- •1.1 A typical embedded networking stack
- •1.2 What is PPP?
- •1.3 ARM TCP/IP requirements
- •1.3.1 Memory requirements
- •1.3.2 CPU requirements
- •1.3.3 Operating system requirements
- •1.4 ARM PPP requirements
- •1.4.1 Line management functions
- •1.4.2 Static memory
- •1.4.3 Dynamic memory
- •1.4.4 Periodic clock tick
- •1.5 Example package directories
- •1.6 Sample programs
- •TCP/IP Porting
- •2.1 Porting procedure
- •2.2 Portable and nonportable files
- •2.2.1 Portable files
- •2.2.2 Nonportable files
- •2.3 Creating the IP port file
- •2.3.1 Standard macros and definitions
- •2.3.2 CPU architecture
- •2.3.4 Debugging aids
- •2.3.5 Timers and multitasking
- •2.3.6 Stack features and options
- •2.4 Coding the glue layer
- •2.4.1 Task control
- •2.5 Specifying IP addresses
- •2.5.1 Porting programmer IP issues
- •2.5.2 End user IP issues
- •2.6 Testing the TCP/IP port
- •PPP Porting
- •3.1 Porting procedure
- •3.2 Porting PPP
- •3.2.1 Source files
- •3.2.2 Compiling PPP
- •3.2.3 Entry points and support calls
- •3.3 Testing PPP
- •3.3.1 Loopback
- •3.3.2 Client connection
- •3.3.3 Server connection
- •3.3.4 Abrupt disconnect
- •3.3.5 Multilink test
- •TCP/IP API Functions
- •4.2.1 cksum()
- •4.2.2 dprintf() and initmsg()
- •4.2.3 dtrap()
- •4.2.4 ENTER_CRIT_SECTION() and EXIT_CRIT_SECTION()
- •4.2.5 LOCK_NET_RESOURCE() and UNLOCK_NET_RESOURCE()
- •4.2.6 npalloc()
- •4.2.7 npfree()
- •4.2.8 panic()
- •4.2.9 prep_ifaces()
- •4.2.10 tcp_sleep()
- •4.2.11 tcp_wakeup()
- •4.3 Network interfaces
- •4.3.1 The NET structure
- •4.3.2 n_close()
- •4.3.3 n_init()
- •4.3.4 n_reg_type()
- •4.3.5 n_stats()
- •4.3.6 pkt_send()
- •4.3.7 raw_send()
- •PPP API Functions
- •5.2.1 _ALLOC() functions
- •5.2.2 ConPrintf()
- •5.2.3 _FREE() functions
- •5.2.4 get_secret()
- •5.2.5 ppp_port_init()
- •5.3 Serial line drivers
- •5.3.1 ln_connect()
- •5.3.2 ln_getc()
- •5.3.3 ln_hangup()
- •5.3.4 ln_putc()
- •5.3.5 ln_speed()
- •5.3.6 ln_state()
- •5.3.7 ln_write()
- •5.4 PPP entry points
- •5.4.1 lcp_lowerdown()
- •5.4.2 lcp_lowerup()
- •5.4.3 ppp_input()
- •5.4.4 ppp_timeisup()
- •5.4.5 prep_ppp()
- •Modem Functions
- •6.1 dialer.c
- •6.1.1 dial()
- •6.1.2 dial_check()
- •6.1.3 dialer_status()
- •6.1.4 modem_cmd()
- •6.1.5 modem_connect()
- •6.1.6 modem_getc()
- •6.1.7 modem_gets()
- •6.1.8 modem_hangup()
- •6.1.9 modem_init()
- •6.1.10 modem_lstate()
- •6.1.11 modem_putc()
- •6.1.12 modem_reset()
- •6.1.13 modem_speed()
- •6.1.14 modem_state()
- •6.1.15 modem_write()
- •6.2 login.c
- •6.2.1 do_script()
- •6.2.2 login()
- •6.2.3 log_input()
- •6.2.4 log_output()
- •6.2.5 logserver()
- •6.3 mdmport.c
- •6.3.1 dial_delay()
- •6.3.2 hangup()
- •6.3.3 modem_clr_dtr() and modem_set_dtr()
- •6.3.4 modem_DCD()
- •6.3.5 modem_portstat()
- •DHCP Client Functions
- •7.1 DHCP client functions
- •7.1.1 dhc_init()
- •7.1.2 dhc_discover()
- •7.1.3 dhc_set_callback()
- •7.1.4 dhc_halt()
- •7.1.5 dhc_second()
- •Low-overhead UDP Functions
- •8.1 UDP functions
- •8.1.1 udp_alloc()
- •8.1.2 udp_close()
- •8.1.3 udp_open()
- •8.1.4 udp_send()
- •8.1.5 udp_socket()
- •Sockets
- •9.1 ARM implementation of sockets
- •9.2 Socket API reference
- •9.2.1 t_accept()
- •9.2.2 t_bind()
- •9.2.3 t_connect()
- •9.2.4 t_errno()
- •9.2.5 t_getpeername()
- •9.2.6 t_getsockname()
- •9.2.7 t_getsockopt()
- •9.2.8 t_listen()
- •9.2.9 t_recv() and t_recvfrom()
- •9.2.10 t_select()
- •9.2.11 t_send() and t_sendto()
- •9.2.12 t_setsockopt()
- •9.2.13 t_shutdown()
- •9.2.14 t_socket()
- •9.2.15 t_socketclose()
- •ARM-specific Functions
- •10.1 ARM directories
- •10.1.1 armthumb
- •10.2 cksum.s
- •10.3 clock.c
- •10.3.1 clock_init()
- •10.3.2 clock_c()
- •10.4 delay.s
- •10.5 dtrap.s
- •10.6 except.s
- •10.7.1 ENTER_CRIT_SECTION() and EXIT_CRIT_SECTION()
- •10.7.2 irqDispatch()
- •10.7.3 irq_Enable() and irq_Disable()
- •10.7.4 irqInit()
- •10.8 lswap.s
- •10.10 olicom.c
- •10.11 pcmcia.c
- •10.12 stack.s
- •10.13 uart.c description
- •10.14 uart.c ring buffer management functions
- •10.14.1 ring_add()
- •10.14.2 ring_avail()
- •10.14.3 ring_new()
- •10.14.4 ring_remove()
- •10.14.5 ring_space()
- •10.15 uart.c interface functions
- •10.15.1 uart_getc()
- •10.15.2 uart_DCD()
- •10.15.3 uart_delay()
- •10.15.4 uart_do_irq()
- •10.15.5 uart_init()
- •10.15.6 uart_irq()
- •10.15.7 uart_putc()
- •10.15.8 uart_ready()
- •10.15.9 uart_reset()
- •10.15.10 uart_setup()
- •10.15.11 uart_stats()
- •10.16 uart.c debug TTY interface functions
- •10.16.1 dputchar()
- •10.16.2 getch()
- •10.16.3 kbhit()
- •Miscellaneous Library Functions
- •11.1 app_ping.c
- •11.2 in_utils.c
- •11.2.1 con_page()
- •11.2.2 hexdump()
- •11.2.3 nextarg()
- •11.2.4 ns_printf()
- •11.2.5 panic()
- •11.2.6 print_eth()
- •11.2.7 print_ipad()
- •11.2.8 print_uptime()
- •11.2.11 sysuptime()
- •11.2.12 uslash()
- •11.3 memman.c
- •11.4 menus.c, menulib.c, and nrmenus.c
- •11.5 nextcarg.c
- •11.5.1 nextcarg()
- •11.6 nvfsio.c
- •11.6.1 Overview
- •11.6.2 nv_fclose()
- •11.6.3 nv_fgets()
- •11.6.4 nv_fopen()
- •11.6.5 nv_fprintf()
- •11.6.6 nv_fwrite()
- •11.6.7 nv_initialize()
- •11.6.8 nv_writeflash()
- •11.7 nvparms.c
- •11.8 parseip.c
- •11.8.1 parseip()
- •11.9 reshost.c
- •11.9.1 in_reshost()
- •11.10 strilib.c
- •11.11 strlib.c
- •11.12 tcp_echo.c
- •11.13 ttyio.c
- •11.14 udp_echo.c
- •11.15 userpass.c
- •11.15.1 add_user()
- •11.15.2 check_permit()
- •Example Applications
- •12.1 Overview of the examples
- •12.1.1 Requirements
- •12.1.2 Building projects
- •12.1.3 Running the examples
- •12.2 Example descriptions
- •12.2.1 chargen
- •12.2.2 loopback
- •12.2.3 maildemo
- •12.2.4 menus
- •Error Codes
- •A.1 ENP_ error codes
- •A.2 Socket error codes

Introduction
1.4ARM PPP requirements
The ARM PPP software requires the following support from the host system:
•line management functions
•static memory
•dynamic memory ( malloc() and free())
•periodic clock tick.
These requirements are explained in the following sections.
1.4.1Line management functions
PPPmust send and receive characters on the line hardware of the target system. It may also need to initiate a connection (for example, dial the phone number) or disconnect. You must provide a set of low-level functions to do this. If more than one type of line is to be used, such as ISDN and Dialup, a set of functions must be provided for each line type.
PPP defines a structure that contains a set of pointers to these functions. You must ensure that all these pointers are set to appropriate functions at system initialization time, even if the function does nothing other than return. Providing these functions is generally the bulk of the work required to implement PPP on a new target system.
The PPP code comes with two sets of line management functions:
•a Universal Asynchronous Receiver/Transmitter (UART) serial line with modem dialer
•a loopback driver.
If your target hardware is an embedded system and you intend to use an 8250/16450/16550 (or similar) UART and a Hayes-compatible modem, you can use the (UART) line drivers exactly as provided.
The loopback drivers are for testing purposes only and are not expected to be the primary line drivers of a real product.
The line driver calls are described in detail in Serial line drivers on page 5-10.
1-12 |
Copyright © 1998 and 1999 ARM Limited. All rights reserved. |
ARM DUI 0079B |

Introduction
1.4.2Static memory
As with all embedded system code, the PPP code takes up some code and data space. On embedded systems, the code is usually stored in ROM and can be moved to RAM at boot time. The exact amount of code space required varies depending on:
•the PPP optional features you enable
•your processor
•your compiler.
Table 1-3 on page 1-14 and Table 1-4 on page 1-14 provide sample sizes of the major modules in the sample program compilation.
These statistics were obtained under the following conditions:
•compiled with space optimization enabled
•APCS 3 32-bit, no software stack check, no frame pointer
•Linker configured to remove unused sections.
Note
Because the code is subject to continuous development, these values may change with subsequent releases.
Total static memory for a configuration will be the amounts shown in the following tables plus about three kilobytes of data space multiplied by the maximum number of connections (_NPPP).
ARM DUI 0079B |
Copyright © 1998 and 1999 ARM Limited. All rights reserved. |
1-13 |

Introduction
Table 1-3 PPP code size—CHAP, MS-CHAP, VJ compression, UPAP, and DHCP client enabled (values shown in bytes)
|
ARM |
Thumb |
|
|
|
|
|
|
code and |
code and |
Read- |
Zero-init |
ARM |
Thumb |
RAM |
|
read-only |
read-only |
write data |
data |
ROM |
ROM |
|
|
|
||||||
|
data |
data |
|
|
|
|
|
|
|
|
|
|
|
|
|
PPP |
12272 |
9372 |
708 |
500 |
12980 |
10080 |
1208 |
|
|
|
|
|
|
|
|
IPCP |
5648 |
4076 |
64 |
192 |
5712 |
4140 |
256 |
|
|
|
|
|
|
|
|
LCP |
5852 |
3980 |
64 |
144 |
5916 |
4044 |
208 |
|
|
|
|
|
|
|
|
CHAP |
7940 |
5924 |
64 |
164 |
8004 |
5988 |
228 |
|
|
|
|
|
|
|
|
MS-CHAP |
3320 |
2148 |
64 |
0 |
3384 |
2212 |
64 |
|
|
|
|
|
|
|
|
FSM |
3980 |
2564 |
4 |
0 |
3984 |
2568 |
4 |
|
|
|
|
|
|
|
|
Van |
2208 |
1500 |
0 |
0 |
2208 |
1500 |
0 |
Jacobson |
|
|
|
|
|
|
|
Compression |
|
|
|
|
|
|
|
(VJC) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(U)PAP |
2120 |
1508 |
0 |
48 |
2120 |
1508 |
48 |
|
|
|
|
|
|
|
|
Totals |
43340 |
31072 |
968 |
1048 |
44308 |
32040 |
2016 |
|
|
|
|
|
|||
|
|
Table 1-4 PPP code size—all optional features disabled (values shown in bytes) |
|||||
|
|
|
|
|
|
|
|
|
ARM |
Thumb |
|
|
|
|
|
|
code and |
code and |
Read- |
Zero-init |
ARM |
Thumb |
RAM |
|
read-only |
read-only |
write data |
data |
ROM |
ROM |
|
|
|
||||||
|
data |
data |
|
|
|
|
|
|
|
|
|
|
|
|
|
PPP |
8772 |
6540 |
708 |
500 |
9480 |
7248 |
1208 |
|
|
|
|
|
|
|
|
IPCP |
5628 |
4048 |
64 |
192 |
5692 |
4112 |
256 |
|
|
|
|
|
|
|
|
LCP |
5720 |
3892 |
64 |
144 |
5784 |
3956 |
208 |
|
|
|
|
|
|
|
|
FSM |
3980 |
2556 |
4 |
0 |
3984 |
2560 |
4 |
|
|
|
|
|
|
|
|
Totals |
24100 |
17036 |
840 |
836 |
24940 |
17876 |
1676 |
|
|
|
|
|
|
|
|
1-14 |
Copyright © 1998 and 1999 ARM Limited. All rights reserved. |
ARM DUI 0079B |

Introduction
1.4.3Dynamic memory
PPPhas no real dynamic memory requirements. However, due to the way some compilers allocate memory, some of the uninitialized static data areas are allocated at initialization time rather than statically. PPP allocates these areas by calling functions that have the same syntax as a standard C library malloc() call. These calls differ from malloc() in two ways:
•they expect the returned buffer to be initialized to zeros (like calloc())
•each macro is used for one kind of buffer or structure only, so a reasonable expected maximum size can be defined at compile time.
If your C compiler and development environment support calloc(), you can map the allocation macros directly to calloc() using the default macro definitions in the sample source code.
If your system does not support calloc() or if you do not want to use it for performance reasons, you can reserve arrays of static buffers of the sizes required and return pointers to them from the allocation macros. The exact sizes required vary with the environment (for example, CPU type and compiler packing options), so you should use sizeof() operators in your static declaration statements.
The number of buffers of each type vary with the number of lines (units) you can open at once.
1.4.4Periodic clock tick
The PPP code includes a function that must be called by the system once per second. This function drives retransmissions and timeouts.
In addition, the PPP code expects the system to maintain a 32-bit clock tick counter variable, cticks, that increments TPS times a second. The macro TPS must be defined in your ipport.h file or one of its nested includes (see Timers and multitasking on page 2-8).
ARM DUI 0079B |
Copyright © 1998 and 1999 ARM Limited. All rights reserved. |
1-15 |