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

TCP/IP API Functions

4.3.7raw_send()

This function transmits the data on the device corresponding to the nets[ ] entry passed to it. Any MAC header required is placed at the head of the buffer passed by the calling function. This function should not return until it has finished processing the data in the passed buffer, because the buffer may be reused (corrupting the data) immediately upon return.

Note

The pkt_send() function (pkt_send() on page 4-24) should be used instead of this function if there is an EOT interrupt available on the hardware. This function is designed for old packet driver type drivers that do not support EOT and should not be needed otherwise. The function you are not using (either pkt_send() or raw_send()) should be set to NULL in the nets[ ] structure.

Syntax

int raw_send(NET net, char *data, unsigned data_bytes)

where:

 

net

is the net structure on which to send it.

data

is a pointer to the data buffer to send.

data_bytes

is the number of bytes to send (length of data).

Return value

Returns one of the following:

0

if successful.

ENP_Code if not successful (see ENP_ error codes on page A-2).

Usage

Slow devices (such as serial links) and hardware that DMAs data directly out of predefined memory areas can copy the passed buffer into driver managed memory buffers and return immediately. However, these devices should be prepared to be called with more data before transmission is complete.

ARM DUI 0079B

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

4-27

TCP/IP API Functions

Interface transmit functions should also maintain system statistics about packet transmissions. These are kept in the n_mib structure attached to each nets[ ] entry. Exact definitions of all these counters are available in RFC 1213.

At a minimum, you should maintain packet byte and error counts, because these can aid greatly with debugging your product during development and isolating configuration problems in the field. It is recommended that you perform statistics keeping at EOT time, but can be approximated in this call. Example 4-4 is a generic example.

Example 4-4

/* compile statistics about completed transmit */

eth = (struct ethhdr *)data;

/* get ether header */

if(send_status == SUCCESSFUL)

/* send_status read from hardware */

{

 

if(eth->e_dst[0] & 0x01)

/* see if multicast bit is on */

net->n_mib->ifOutNUcastPkts++;

 

else

 

net->n_mib->ifOutUcastPkts++;

 

net_>n_mib->ifOutOctets +=databytes;

 

}

 

else

/* error sending packet*/

{

 

net->n_mib->ifOutErrors++;

 

}

 

 

 

4-28

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

ARM DUI 0079B