tfIpScatteredSend

Jump to: navigation, search

Table of Contents >> Programmer's Reference


#include <trsocket.h>


int tfIpScatteredSend (
ttUserInterface interfaceHandle,
ttUserBlockPtr userBlockPtr,
int userBlockCount,
ttUserFreeFuncPtr userFreeFuncPtr
);


Function Description

This function allows the user to send an IP datagram directly to the stack without using a socket interface, without the Treck stack changing any IP header field (except if IP fragmentation is needed), and directly from user owned scattered data buffers. Even the IP header itself could be scattered among several data buffers. The user passes a pointer to an array of user block data of type ttUserBlock and the number of elements in the array. Each ttUserBlock element contains a pointer to a user buffer, a pointer to the beginning of the user data in the user buffer, and the user data length in the user buffer. Upon return from this routine, the user can reuse the ttUserBlock array, but the Treck stack owns the user buffers that were pointed to by the ttUserBlock elements. The userFreeFunction will be called by the Treck stack for each user buffer, when the data has been sent out on the network and the device driver no longer needs to access the data in the user buffer. An example of tfIpScatteredSend() usage is shown in the loopback test module txscatlp.c.


Note Note: If the user uses a preemptive kernel, i.e. TM_TRECK_PREEMPTIVE_KERNEL is defined in <trsystem.h>, it is the user's responsibility to ensure that the user free function is re-entrant, as it could potentially be called from different threads.


Parameters

  • interfaceHandle
    If the user knows the interface the packet is to be sent out to, then this field is non-null.
  • userBlockPtr
    Pointer to the first element (data type ttUserBlock) of the user array that contains information about the user scattered data. See below.
  • userBlockCount
    Number of elements in the above array.
  • userFreeFuncPtr
    The user supplied call back function for freeing the user supplied buffer. See below.


ttUserBlock

#define trsocket.h
 
/*
 * Data type to convey information about scattered send user buffers,
 * in the tfSocketScatteredSendTo() API, and tfIpScatteredSend() API.
 */
typedef struct tsUserBlock
{
/* Pointer to buffer (passed to the free routine) */
    char TM_FAR * userBufferPtr;
/* Pointer to beginning of data */
    char TM_FAR * userDataPtr;
/* Data length */
    int           userDataLength;
} ttUserBlock;
typedef ttUserBlock TM_FAR * ttUserBlockPtr;


userFreeFuncPtr

int userFreeFunc (char TM_FAR * bufferPtr);


Returns

  • TM_ENOERROR
    Success.
  • TM_EINVAL
    One of the parameters is invalid.
  • TM_ENOBUFS
    Could not allocate Treck headers to send the data or could not allocate an ARP entry.
  • TM_EFAULT
    Bad packet. The IP header length is bigger than the total data length in the user scattered buffers or IP header size is bigger than the maximum allowed by the RFC (60) or it less than the minimum (20).
  • TM_EMSGSIZE
    Data length of the IP datagram is bigger than the IP MTU and fragmentation is not allowed.
  • TM_EHOSTUNREACH
    No route to host.
  • TM_EDESTADDRREQ
    Destination IP address in the IP header is zero.
  • TM_ENOENT
    No interface could be found to send the packet out (only if destination IP address is limited broadcast).
  • TM_ENXIO
    Outgoing interface is closed.
  • TM_EIO
    Interface transmit queue if full (only if interface transmit queue is used).
  • (Other)
    Returned by device driver send function.


Table of Contents >> Programmer's Reference