Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
(ARM).Porting TCP-IP programmer's guide.Ver 1.4.pdf
Скачиваний:
31
Добавлен:
23.08.2013
Размер:
2.79 Mб
Скачать

Chapter 4

TCP/IP API Functions

This chapter describes the functions the user must provide to port the ARM TCP/IP stack. Refer to the code provided with the software for examples.

This chapter contains the following sections:

Overview of user-provided TCP/IP functions on page 4-2

User-provided TCP and IP functions on page 4-3

Network interfaces on page 4-15.

ARM DUI 0079B

Copyright © 1998 and 1999 ARM Limited. All rights reserved.

4-1

TCP/IP API Functions

4.1Overview of user-provided TCP/IP functions

You must provide the functions described in this chapter as part of porting the ARM TCP/IP stack.

In the sample package, these functions are either mapped directly to system calls by way of macros in ipport.h or they are implemented in ipport.c or in files in the \armthumb and \pid7tdm directories. Many of these implementations will map directly onto the system to which you are porting. Others will need extensive modification or complete rewrites.

Refer to Chapter 2 TCP/IP Porting for the complete TCP/IP porting procedure.

4-2

Copyright © 1998 and 1999 ARM Limited. All rights reserved.

ARM DUI 0079B

TCP/IP API Functions

4.2User-provided TCP and IP functions

This section describes the TCP and IP functions that you must implement. A description of how to use the function is given in each case. The functions are as follows:

cksum() on page 4-4

dprintf() and initmsg() on page 4-5

dtrap() on page 4-6

ENTER_CRIT_SECTION() and EXIT_CRIT_SECTION() on page 4-7

LOCK_NET_RESOURCE() and UNLOCK_NET_RESOURCE() on page 4-8

npalloc() on page 4-9

npfree() on page 4-10

panic() on page 4-11

prep_ifaces() on page 4-12

tcp_sleep() on page 4-13

tcp_wakeup() on page 4-14.

ARM DUI 0079B

Copyright © 1998 and 1999 ARM Limited. All rights reserved.

4-3

TCP/IP API Functions

4.2.1cksum()

This function returns a 16-bit Internet checksum of the buffer.

The algorithm for this is described in RFC 1071.

Syntax

unsigned short cksum(unsigned short *buffer, unsigned

word_count)

where:

buffer is the pointer to the buffer to checksum.

word_count

is the number of 16-bit words in the buffer.

Return value

The cksum function returns the 16-bit checksum.

Usage

Both C language and ARM and Thumb assembly language versions of this function are provided with the sample package. The C version is in \inet\ccksum.c and the assembler version is in \armthumb\cksum.s. You should include only one of these files in your project.

The C version is included to provide an insight into what is going on in the assembler versions. A significant amount of TCP/IP stack processor time is spent in the cksum() function, so the optimized assembler versions should be used.

4-4

Copyright © 1998 and 1999 ARM Limited. All rights reserved.

ARM DUI 0079B