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

Internal Functions

10.3ICMP routines

The ICMP routines are located in various files in the inet directory and are as follows:

icmprcv() on page 10-14

icmp_destun() on page 10-15

icmpEcho() on page 10-16.

10.3.1icmprcv()

The icmprcv() routine is the ICMP received packet upcall handler.

Syntax

int icmprcv(PACKET p);

where:

p

Is the received packet.

Usage

Call this routine with p->nb_prot and p->nb_plen pointing to the start of the ICMP header, and with p->fhost filled in.

Returned values

Returns one of the following values:

0

If the packet was processed successfully.

ENP_NOT_MINE If the packet was not for this destination.

ENP_ code

If an error occurred (see ENP_ error codes on page A-2).

Location

The icmprcv() routine is found in the following file:

inet\icmp.c

10-14

Copyright © 1998-2001 ARM Limited. All rights reserved.

ARM DUI 0144B

Internal Functions

10.3.2icmp_destun()

The icmp_destun() routine sends an ICMP destination-unreachable packet.

Syntax

void icmp_destun(ip_addr host, struct ip *ip,

 

 

unsigned type, NET net);

where:

 

 

host

Is the destination IP host.

*ip

Is the IP header of the packet which triggered the

 

destination-unreachable packet.

type

Is one of the ICMP destination-unreachable message types. It must be

 

one of the following defined constants:

 

DSTNET

 

DSTHOST

 

DSTPROT

 

DSTPORT

 

DSTFRAG

 

DSTSRC.

net

Is the interface that the packet came in on.

Returned values

None.

Location

The icmp_destun() routine is found in the following file:

inet\icmp.c

ARM DUI 0144B

Copyright © 1998-2001 ARM Limited. All rights reserved.

10-15

Internal Functions

10.3.3icmpEcho()

The icmpEcho() routine sends an ICMP echo request.

Syntax

int icmpEcho(ip_addr host, char *data, unsigned length, unshort pingseq);

where:

host

Is the host to ping (32-bit, local-endian).

*data Is the ping data. This is set to NULL in a don’t care case.

length Is the total desired length of the packet on media.

pingseq Is the ping sequence number.

Usage

This routine is callable from applications. It sends a single ping (ICMP echo request) to the specified host. The application must provide an appropriate pingDemux() routine if ping replies are to be checked.

Return values

Returns one of the following values:

0

If the transmission was successful.

ENP_ code

If an error occurred (see ENP_ error codes on page A-2).

Location

The icmp_destun() routine is found in the following file:

inet\ping.c

10-16

Copyright © 1998-2001 ARM Limited. All rights reserved.

ARM DUI 0144B

Appendix A

Error Codes

This appendix contains a list of both the standard ENP_ error codes you might encounter while porting (see Chapter 3 TCP/IP API Functions and Chapter 6 Low-overhead UDP Functions) and the socket error codes (see Chapter 5 Sockets). It contains the following sections:

ENP_ error codes on page A-2

Socket error codes on page A-4.

ARM DUI 0144B

Copyright © 1998-2001 ARM Limited. All rights reserved.

A-1