Jump to: navigation, search

Table of Contents >> Programmer's Reference

#include <trsocket.h>

char * tfGetCacheSafeDrvBuf (
ttUserInterface interfaceHandle,
ttUserBufferPtr userBufferPtr,
int length,
int alignment,
int flag

Function Description

This function allocates a "cache safe" (i.e., invalidated) packet buffer to be used by a device driver. The returned data pointer will be aligned according to the alignment parameter. If possible, the data pointer will also be automatically adjusted to allow the IP header to start on a 4-byte-aligned memory address. This function will only work correctly on interfaces which have a "cache invalidate" callback registered via tfUseInterfaceCacheInvalFunc().


  • interfaceHandle
    Handle to the interface to use this callback on.
  • userBufferPtr
    Pointer to a ttUserBuffer structure. The function will store a buffer handle in this variable. The buffer handle must later be provided back to the stack in the driver's receive function.
  • length
    Requested buffer length
  • alignment
    Requested buffer alignment. It is common for network hardware that supports DMA to require pre-allocated receive buffers to be memory-aligned. Such alignment requirements can be specified here, and used by the stack when setting the start of the data buffer.
  • flags
    Must be set to TM_DEV_CALLED_FROM_APP if called from the application. If called from a device driver function, this parameter should be set to 0.


  • 0
    Error: unable to allocate a new buffer.
  • Valid Pointer
    Pointer to the new data buffer.

Table of Contents >> Programmer's Reference