openserSIPMethodSupportedTable.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include "../../sr_module.h"
00042 #include "../../mem/mem.h"
00043
00044 #include <net-snmp/net-snmp-config.h>
00045 #include <net-snmp/net-snmp-includes.h>
00046 #include <net-snmp/agent/net-snmp-agent-includes.h>
00047
00048 #include <net-snmp/library/snmp_assert.h>
00049
00050 #include "openserSIPMethodSupportedTable.h"
00051
00052 static netsnmp_handler_registration *my_handler = NULL;
00053 static netsnmp_table_array_callbacks cb;
00054
00055 oid openserSIPMethodSupportedTable_oid[] =
00056 { openserSIPMethodSupportedTable_TABLE_OID };
00057
00058 size_t openserSIPMethodSupportedTable_oid_len =
00059 OID_LENGTH(openserSIPMethodSupportedTable_oid);
00060
00061
00062
00063
00064
00065 void createRow(int index, char *stringToRegister) {
00066
00067 openserSIPMethodSupportedTable_context *theRow;
00068
00069 oid *OIDIndex;
00070 char *copiedString;
00071 int stringLength;
00072
00073 theRow = SNMP_MALLOC_TYPEDEF(openserSIPMethodSupportedTable_context);
00074
00075 if (theRow == NULL) {
00076 LM_ERR("failed to create a row for openserSIPMethodSupportedTable\n");
00077 return;
00078 }
00079
00080 OIDIndex = pkg_malloc(sizeof(oid));
00081
00082 if (OIDIndex == NULL) {
00083 free(theRow);
00084 LM_ERR("failed to create a row for openserSIPMethodSupportedTable\n");
00085 return;
00086 }
00087
00088 stringLength = strlen(stringToRegister);
00089
00090 copiedString = pkg_malloc((stringLength + 1) * sizeof(char));
00091
00092 if (copiedString == NULL) {
00093 LM_ERR("failed to create a row for openserSIPMethodSupportedTable\n");
00094 return;
00095 }
00096
00097 strcpy(copiedString, stringToRegister);
00098
00099 OIDIndex[0] = index;
00100
00101 theRow->index.len = 1;
00102 theRow->index.oids = OIDIndex;
00103 theRow->openserSIPMethodSupportedIndex = index;
00104
00105 theRow->openserSIPMethodName = (unsigned char*) copiedString;
00106 theRow->openserSIPMethodName_len = stringLength;
00107
00108 CONTAINER_INSERT(cb.container, theRow);
00109 }
00110
00111
00112
00113
00114 void init_openserSIPMethodSupportedTable(void)
00115 {
00116 initialize_table_openserSIPMethodSupportedTable();
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142 if (module_loaded("sl")) {
00143 createRow(1, "METHOD_INVITE");
00144 createRow(2, "METHOD_CANCEL");
00145 createRow(3, "METHOD_ACK");
00146 }
00147
00148 if (module_loaded("tm")) {
00149 createRow(4, "METHOD_BYE");
00150 }
00151
00152 if (module_loaded("options")) {
00153 createRow(6, "METHOD_OPTIONS");
00154 }
00155
00156 if (module_loaded("dialog")) {
00157 createRow(7, "METHOD_UPDATE");
00158 }
00159
00160 if (module_loaded("registrar")) {
00161 createRow(8, "METHOD_REGISTER");
00162 createRow(10, "METHOD_SUBSCRIBE");
00163 createRow(11, "METHOD_NOTIFY");
00164 }
00165
00166 createRow(5, "METHOD_INFO");
00167 createRow(9, "METHOD_MESSAGE");
00168
00169
00170
00171 createRow(12, "METHOD_PRACK");
00172 createRow(13, "METHOD_REFER");
00173 createRow(14, "METHOD_PUBLISH");
00174 }
00175
00176
00177
00178
00179 void initialize_table_openserSIPMethodSupportedTable(void)
00180 {
00181 netsnmp_table_registration_info *table_info;
00182
00183 if(my_handler) {
00184 snmp_log(LOG_ERR, "initialize_table_openserSIPMethodSupported"
00185 "Table_handler called again\n");
00186 return;
00187 }
00188
00189 memset(&cb, 0x00, sizeof(cb));
00190
00191
00192 table_info = SNMP_MALLOC_TYPEDEF(netsnmp_table_registration_info);
00193
00194 my_handler =
00195 netsnmp_create_handler_registration(
00196 "openserSIPMethodSupportedTable",
00197 netsnmp_table_array_helper_handler,
00198 openserSIPMethodSupportedTable_oid,
00199 openserSIPMethodSupportedTable_oid_len,
00200 HANDLER_CAN_RONLY);
00201
00202 if (!my_handler || !table_info) {
00203 snmp_log(LOG_ERR, "malloc failed in initialize_table_openser"
00204 "SIPMethodSupportedTable_handler\n");
00205 return;
00206 }
00207
00208 netsnmp_table_helper_add_index(table_info, ASN_UNSIGNED);
00209
00210 table_info->min_column = openserSIPMethodSupportedTable_COL_MIN;
00211 table_info->max_column = openserSIPMethodSupportedTable_COL_MAX;
00212
00213
00214
00215
00216 cb.get_value = openserSIPMethodSupportedTable_get_value;
00217 cb.container =
00218 netsnmp_container_find("openserSIPMethodSupportedTable_primary:"
00219 "openserSIPMethodSupportedTable:" "table_container");
00220
00221 DEBUGMSGTL(("initialize_table_openserSIPMethodSupportedTable",
00222 "Registering table openserSIPMethodSupportedTable"
00223 "as a table array\n"));
00224
00225 netsnmp_table_container_register(my_handler, table_info, &cb,
00226 cb.container, 1);
00227
00228 }
00229
00230
00231
00232
00233
00234
00235 int openserSIPMethodSupportedTable_get_value(
00236 netsnmp_request_info *request,
00237 netsnmp_index *item,
00238 netsnmp_table_request_info *table_info )
00239 {
00240 netsnmp_variable_list *var = request->requestvb;
00241
00242 openserSIPMethodSupportedTable_context *context =
00243 (openserSIPMethodSupportedTable_context *)item;
00244
00245 switch(table_info->colnum)
00246 {
00247 case COLUMN_OPENSERSIPMETHODNAME:
00248
00249
00250 snmp_set_var_typed_value(var, ASN_OCTET_STR,
00251 (unsigned char*)
00252 context->openserSIPMethodName,
00253 context->openserSIPMethodName_len );
00254 break;
00255
00256 default:
00257 snmp_log(LOG_ERR, "unknown column in openserSIPMethod"
00258 "SupportedTable_get_value\n");
00259 return SNMP_ERR_GENERR;
00260 }
00261
00262 return SNMP_ERR_NOERROR;
00263 }
00264
00265
00266
00267
00268 const openserSIPMethodSupportedTable_context *
00269 openserSIPMethodSupportedTable_get_by_idx(netsnmp_index * hdr)
00270 {
00271 return (const openserSIPMethodSupportedTable_context *)
00272 CONTAINER_FIND(cb.container, hdr );
00273 }
00274
00275