agutil_api.h
上传用户:wxp200602
上传日期:2007-10-30
资源大小:4028k
文件大小:4k
源码类别:

SNMP编程

开发平台:

Unix_Linux

  1. /**************************************************************
  2.  * Copyright (C) 2001 Alex Rozin, Optical Access 
  3.  *
  4.  *                     All Rights Reserved
  5.  *
  6.  * Permission to use, copy, modify and distribute this software and its
  7.  * documentation for any purpose and without fee is hereby granted,
  8.  * provided that the above copyright notice appear in all copies and that
  9.  * both that copyright notice and this permission notice appear in
  10.  * supporting documentation.
  11.  * 
  12.  * ALEX ROZIN DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  13.  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  14.  * ALEX ROZIN BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  15.  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  16.  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  17.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  18.  * SOFTWARE.
  19.  ******************************************************************/
  20. #ifndef _agutil_api_h_included__
  21. #define _agutil_api_h_included__
  22. #include <string.h>
  23. #if 0                           /* for debug */
  24. #warning MEMORY DEBUG VERSION
  25. void           *dbg_f_AGMALLOC(size_t size);
  26. void            dbg_f_AGFREE(void *ptr);
  27. char           *dbg_f_AGSTRDUP(const char *s);
  28. void            dbg_f_AG_MEM_REPORT(void);
  29. #  define AGMALLOC(X) dbg_f_AGMALLOC(X)
  30. #  define AGFREE(X)       { dbg_f_AGFREE(X); X = NULL; }
  31. #  define AGSTRDUP(X)     dbg_f_AGSTRDUP(X)
  32. #else
  33. #  define AGMALLOC(X) malloc(X)
  34. #  define AGFREE(X) { free(X); X = NULL; }
  35. #  define AGSTRDUP(X) strdup(X)
  36. #endif
  37. typedef struct {
  38.     size_t          length;
  39.     oid             objid[MAX_OID_LEN];
  40. } VAR_OID_T;
  41. void            ag_trace(const char *format, ...);
  42. int             AGUTIL_advance_index_name(struct variable *vp, oid * name,
  43.                                           size_t * length, int exact);
  44. int             AGUTIL_get_int_value(u_char * var_val, u_char var_val_type,
  45.                                      size_t var_val_len, long min_value,
  46.                                      long max_value, long *long_tmp);
  47. int             AGUTIL_get_string_value(u_char * var_val,
  48.                                         u_char var_val_type,
  49.                                         size_t var_val_len,
  50.                                         size_t buffer_max_size,
  51.                                         u_char should_zero_limited,
  52.                                         size_t * buffer_actual_size,
  53.                                         char *buffer);
  54. int             AGUTIL_get_oid_value(u_char * var_val, u_char var_val_type,
  55.                                      size_t var_val_len,
  56.                                      VAR_OID_T * data_source_ptr);
  57. u_long          AGUTIL_sys_up_time(void);
  58. #if OPTICALL_ACESS
  59. #define ETH_STATS_T UID_PORT_STATISTICS_T
  60. #else
  61. typedef struct {
  62.     u_int           ifIndex;
  63.     u_long          octets;
  64.     u_long          packets;
  65.     u_long          bcast_pkts;
  66.     u_long          mcast_pkts;
  67.     u_long          crc_align;
  68.     u_long          undersize;
  69.     u_long          oversize;
  70.     u_long          fragments;
  71.     u_long          jabbers;
  72.     u_long          collisions;
  73.     u_long          pkts_64;
  74.     u_long          pkts_65_127;
  75.     u_long          pkts_128_255;
  76.     u_long          pkts_256_511;
  77.     u_long          pkts_512_1023;
  78.     u_long          pkts_1024_1518;
  79. } ETH_STATS_T;
  80. #endif
  81. void            SYSTEM_get_eth_statistics(VAR_OID_T * data_source,
  82.                                           ETH_STATS_T * where);
  83. #endif                          /* _agutil_api_h_included__ */