/*
 *
 *     Module Name: natcpipheap.h
 *         Version: 2.00
 *   Original Date: 11/24/04
 *          Author: Contact NetSilicon technical support if you have questions on this file.
 *        Language: Ansi C
 * Compile Options:
 * Compile defines:
 *       Libraries:
 *    Link Options:
 *
 *    Entry Points:
 *
 *  Copyright (c) 1996-2004 Digi International Inc., All Rights Reserved
 *
 *  This software contains proprietary and confidential information of Digi
 *  International Inc.  By accepting transfer of this copy, Recipient agrees
 *  to retain this software in confidence, to prevent disclosure to others,
 *  and to make no use of this software other than that for which it was
 *  delivered.  This is an unpublished copyrighted work of Digi International
 *  Inc.  Except as permitted by federal law, 17 USC 117, copying is strictly
 *  prohibited.
 *
 *  Restricted Rights Legend
 *
 *  Use, duplication, or disclosure by the Government is subject to
 *  restrictions set forth in sub-paragraph (c)(1)(ii) of The Rights in
 *  Technical Data and Computer Software clause at DFARS 252.227-7031 or
 *  subparagraphs (c)(1) and (2) of the Commercial Computer Software -
 *  Restricted Rights at 48 CFR 52.227-19, as applicable.
 *
 *  Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
 *
 * natcpipheap.h This file defines constants and API function prototypes for the 
 * NET+OS TCP/IP heap.
 *
 */

#ifndef _NATCPIPHEAP_
#define _NATCPIPHEAP_

#ifdef __cplusplus
extern "C"
{
#endif

/* Block sizes in bytes */
#define NA_TCPIP_BLOCK_SIZE_16		16
#define NA_TCPIP_BLOCK_SIZE_32		32
#define NA_TCPIP_BLOCK_SIZE_64		64
#define NA_TCPIP_BLOCK_SIZE_128		128
#define NA_TCPIP_BLOCK_SIZE_256		256
#define NA_TCPIP_BLOCK_SIZE_540		540
#define NA_TCPIP_BLOCK_SIZE_LARGE  2048


/* 
   Maximum number of block pools.
 */
#define NA_TCPIP_MAX_HEAP_BLOCK_SIZES   7

/* 
    Type for a structure to hold the statistics for allocations from a block pool.
    The same structureis used for the byte pool statistics.
*/
typedef struct 
{
    int          size;              /* block size in bytes; 0 for byte pool  */   
    unsigned int max_allocated_cnt; /* maximum of allocated blocks at a time */     
    unsigned int allocated_cnt;     /* number of allocated blocks at present */
    unsigned int no_memory_cnt;     /* number of failed allocations from this pool */

} NATcpipHeapStatsType;

/* 
   Type for an array to hold TCP/IP heap statistics.
 */
typedef NATcpipHeapStatsType NATcpipHeapStatsArray[NA_TCPIP_MAX_HEAP_BLOCK_SIZES + 1];


/*
    Returns total number of bytes in a byte pool. 
 */
unsigned long NATcpipGetBytePoolSize(void);

/* 
    Returns the low memory threshold. TCP/IP stack attempts memory recovery, when 
    the number of free heap bytes falls below the low memory threshold.

 */
unsigned long NATcpipGetLowMemoryLimit(void);

/* 
    Changes a low memory threshold. TCP/IP stack attempts memory recovery, when 
    the number of free heap bytes falls below the low memory threshold.
 */
void NATcpipSetLowMemoryLimit(unsigned long limit);

/* 
 * Returns the number of failed allocations from the TCP/IP heap 
 */
unsigned long NATcpipGetNoMemoryCount(void);

/* 
    Coppies the TCP/IP heap statistics to the stats array.

    param  stats  Array to be filled with heap statisticks.
    return        Number of valid entries in stats array.
                  The last valid entry represents byte pool statisticks.
 */
int  NATcpipGetHeapStats(NATcpipHeapStatsArray stats);

#ifdef __cplusplus
}
#endif
#endif

