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

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 _row_api_h_included__
  21. #define _row_api_h_included__
  22. /*
  23.  * control tables API section 
  24.  */
  25. typedef enum {
  26.     RMON1_ENTRY_VALID = 1,
  27.     RMON1_ENTRY_CREATE_REQUEST,
  28.     RMON1_ENTRY_UNDER_CREATION,
  29.     RMON1_ENTRY_INVALID,
  30. } RMON1_ENTRY_STATUS_T;
  31. #define MAX_OWNERSTRING 128
  32. /*
  33.  * structure for entry of all 'control' tables 
  34.  */
  35. typedef struct tagEntry {
  36.     /*
  37.      * begin of the header 
  38.      */
  39.     struct tagEntry *next;
  40.     void           *table_ptr;  /* do casting to (TABLE_DEFINTION_T*) */
  41.     RMON1_ENTRY_STATUS_T status;
  42.     RMON1_ENTRY_STATUS_T new_status;
  43.     u_long          ctrl_index;
  44.     u_long          timer_id;
  45.     char           *owner;
  46.     char           *new_owner;
  47.     u_char          only_just_created;
  48.     /*
  49.      * end of the header 
  50.      */
  51.     void           *body;
  52.     void           *tmp;
  53. } RMON_ENTRY_T;
  54. typedef int     (ENTRY_CALLBACK_T) (RMON_ENTRY_T *);
  55. typedef struct {
  56.     char           *name;
  57.     RMON_ENTRY_T   *first;
  58.     u_long          max_number_of_entries;      /* '<0' means without limit */
  59.     u_long          current_number_of_entries;
  60.     ENTRY_CALLBACK_T *ClbkCreate;
  61.     ENTRY_CALLBACK_T *ClbkClone;
  62.     ENTRY_CALLBACK_T *ClbkValidate;
  63.     ENTRY_CALLBACK_T *ClbkActivate;
  64.     ENTRY_CALLBACK_T *ClbkDeactivate;
  65.     ENTRY_CALLBACK_T *ClbkDelete;
  66.     ENTRY_CALLBACK_T *ClbkCopy;
  67. } TABLE_DEFINTION_T;
  68. /*
  69.  * Api prototypes 
  70.  */
  71. void            ROWAPI_init_table(TABLE_DEFINTION_T * table_ptr,
  72.                                   char *name,
  73.                                   u_long max_number_of_entries,
  74.                                   ENTRY_CALLBACK_T * ClbkCreate,
  75.                                   ENTRY_CALLBACK_T * ClbkClone,
  76.                                   ENTRY_CALLBACK_T * ClbkDelete,
  77.                                   ENTRY_CALLBACK_T * ClbkValidate,
  78.                                   ENTRY_CALLBACK_T * ClbkActivate,
  79.                                   ENTRY_CALLBACK_T * ClbkDeactivate,
  80.                                   ENTRY_CALLBACK_T * ClbkCopy);
  81. int             ROWAPI_new(TABLE_DEFINTION_T * table_ptr,
  82.                            u_long ctrl_index);
  83. RMON_ENTRY_T   *ROWAPI_get_clone(TABLE_DEFINTION_T * table_ptr,
  84.                                  u_long ctrl_index, size_t body_size);
  85. void            ROWAPI_delete_clone(TABLE_DEFINTION_T * table_ptr,
  86.                                     u_long ctrl_index);
  87. RMON_ENTRY_T   *ROWAPI_first(TABLE_DEFINTION_T * table_ptr);
  88. RMON_ENTRY_T   *ROWAPI_next(TABLE_DEFINTION_T * table_ptr,
  89.                             u_long prev_index);
  90. RMON_ENTRY_T   *ROWAPI_find(TABLE_DEFINTION_T * table_ptr,
  91.                             u_long ctrl_index);
  92. int             ROWAPI_action_check(TABLE_DEFINTION_T * table_ptr,
  93.                                     u_long ctrl_index);
  94. int             ROWAPI_commit(TABLE_DEFINTION_T * table_ptr,
  95.                               u_long ctrl_index);
  96. RMON_ENTRY_T   *ROWAPI_header_ControlEntry(struct variable *vp, oid * name,
  97.                                            size_t * length, int exact,
  98.                                            size_t * var_len,
  99.                                            TABLE_DEFINTION_T * table_ptr,
  100.                                            void *entry_ptr,
  101.                                            size_t entry_size);
  102. int             ROWAPI_do_another_action(oid * name,
  103.                                          int tbl_first_index_begin,
  104.                                          int action, int *prev_action,
  105.                                          TABLE_DEFINTION_T * table_ptr,
  106.                                          size_t entry_size);
  107. /*
  108.  * data tables API section 
  109.  */
  110. typedef int     (SCROLLER_ENTRY_DESCRUCTOR_T) (void *);
  111. typedef struct nexted_void_t {
  112.     struct nexted_void_t *next;
  113.     u_long          data_index;
  114. } NEXTED_PTR_T;
  115. typedef struct data_scroller {
  116.     u_long          max_number_of_entries;
  117.     u_long          data_requested;
  118.     u_long          data_granted;
  119.     u_long          data_created;       /* number of allocated data entries */
  120.     u_long          data_stored;        /* number of data, currently stored */
  121.     u_long          data_total_number;  /* number of data entries, stored after validation */
  122.     /*
  123.      * these 3 pointers make casting to private (DATA_ENTRY_T*) 
  124.      */
  125.     void           *first_data_ptr;
  126.     NEXTED_PTR_T   *last_data_ptr;
  127.     void           *current_data_ptr;
  128.     size_t          data_size;
  129.     int             (*data_destructor) (struct data_scroller *, void *);
  130. } SCROLLER_T;
  131. int             ROWDATAAPI_init(SCROLLER_T * scrlr,
  132.                                 u_long max_number_of_entries,
  133.                                 u_long data_requested,
  134.                                 size_t data_size,
  135.                                 int (*data_destructor) (struct
  136.                                                         data_scroller *,
  137.                                                         void *));
  138. void
  139.                 ROWDATAAPI_set_size(SCROLLER_T * scrlr,
  140.                                     u_long data_requested,
  141.                                     u_char do_allocation);
  142. void            ROWDATAAPI_descructor(SCROLLER_T * scrlr);
  143. void           *ROWDATAAPI_locate_new_data(SCROLLER_T * scrlr);
  144. u_long          ROWDATAAPI_get_total_number(SCROLLER_T * scrlr);
  145. RMON_ENTRY_T   *ROWDATAAPI_header_DataEntry(struct variable *vp,
  146.                                             oid * name, size_t * length,
  147.                                             int exact, size_t * var_len,
  148.                                             TABLE_DEFINTION_T * table_ptr,
  149.                                             SCROLLER_T *
  150.                                             (*extract_scroller) (void
  151.                                                                  *body),
  152.                                             size_t data_size,
  153.                                             void *entry_ptr);
  154. #endif                          /* _row_api_h_included__ */