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

Internal Functions

10.2.8pk_alloc()

The pk_alloc() routine allocates a netbuf structure and associated packet buffer that the caller can use to store data to be transmitted or data that has been received.

This routine is used internally by the stack to pass data between the various protocol layers.

Syntax

PACKET pk_alloc(unsigned int len);

where:

len

Is the length in bytes of the packet data to be stored in the buffer.

Usage

You must lock the FREEQ_RESID before calling pk_alloc(), and unlock it after pk_alloc() returns.

Return values

Returns one of the following values:

pointer If the allocation was successful, a pointer to the allocated netbuf structure is returned.

NULL

If allocation was unsuccessful.

Location

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

inet\pktalloc.c

10-12

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

ARM DUI 0144B

Internal Functions

10.2.9pk_free()

The pk_free() routine returns a previously allocated netbuf structure to the pool of such structures that is maintained by the stack.

Syntax

void pk_free(PACKET pkt); where:

pkt

Is a pointer to the netbuf structure previously allocated by

 

pk_alloc().

Usage

Include a call to pk_free() in your network interface code in order to return a netbuf structure and its associated packet buffer to the free pool, after the packet has been transmitted by the network device. For a description of how this is performed, see the description of pkt_send() on page 3-22.

You must lock the FREEQ_RESID before calling pk_alloc(), and unlock it after pk_alloc() returns.

Return values

None

Location

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

inet\pktalloc.c

ARM DUI 0144B

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

10-13