int dot3StatsTable_container_load(netsnmp_container * container) { dot3StatsTable_rowreq_ctx *rowreq_ctx; size_t count = 0; DEBUGMSGTL(("verbose:dot3StatsTable:dot3StatsTable_container_load", "called\n")); /* * TODO:352:M: | |-> set indexes in new dot3StatsTable rowreq context. * data context will be set from the param (unless NULL, * in which case a new data context will be allocated) */ /* * temporary storage for index values */ /* * dot3StatsIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/A/w/e/R/d/H */ long dot3StatsIndex; int fd; int rc = 0, retval = 0; #if defined(linux) struct ifname *list_head = NULL, *p = NULL; #endif /* * create socket for ioctls */ fd = socket(AF_INET, SOCK_DGRAM, 0); if(fd < 0) { snmp_log(LOG_ERR, "could not create socket\n"); return -2; } /* * get the interface names of the devices present in the system, in case of failure retval suggests the reson for failure * and list_head contains null */ #if defined(linux) #if 0 list_head = dot3stats_interface_name_list_get (list_head, &retval); if (!list_head) { snmp_log (LOG_ERR, "access:dot3StatsTable, error getting the interface names present in the system\n"); DEBUGMSGTL(("access:dot3StatsTable", "error getting the interface names present in the system")); return MFD_ERROR; } printf("has enter dot3stats_interface_name_list_get, defined(linux)!\n"); /* * Walk over the list of interface names present in the system and retreive the statistics */ #endif int num = 0; ETH_SLOT_LIST head,*sp; memset(&head,0,sizeof(ETH_SLOT_LIST)); ETH_PORT_LIST *pp; int ret=show_ethport_list(&head,&num); sp=head.next; int num1 = 0; if(sp!=NULL) { while(sp!=NULL) { printf("num1=%d\n",num1); pp=sp->port.next; printf("pp=%x\n",pp); while(pp!=NULL) { u_int flags; num1 ++; printf("num1=%d\n",num1); flags = 0; /* * get index via ioctl. */ dot3StatsIndex = dot3stats_set_index_by_slot_port((unsigned char)sp->slot_no, (unsigned char)pp->port_no); /* * get the dot3stats contents populated, if the device is not an ethernet device * the operation will not be supported and an error message will be logged */ rowreq_ctx = dot3StatsTable_allocate_rowreq_ctx(NULL); if (NULL == rowreq_ctx) { snmp_log(LOG_ERR, "memory allocation for dot3StatsTable failed\n"); close(fd); return MFD_RESOURCE_UNAVAILABLE; } if (MFD_SUCCESS != dot3StatsTable_indexes_set(rowreq_ctx, dot3StatsIndex)) { snmp_log(LOG_ERR, "error setting index while loading " "dot3StatsTable data.\n"); dot3StatsTable_release_rowreq_ctx(rowreq_ctx); continue; } /* * TODO:352:r: | |-> populate dot3StatsTable data context. * Populate data context here. (optionally, delay until row prep) */ /* * non-TRANSIENT data: no need to copy. set pointer to data */ /*add by tsq for dianxin*/ //printf("has solved dot3StatsTable_index_to_set_data before!!\n"); dot3StatsTable_set_data_by_dbus(&rowreq_ctx->data, dot3StatsIndex); #if 0 memset (&rowreq_ctx->data, 0, sizeof (rowreq_ctx->data)); rc = interface_ioctl_dot3stats_get (rowreq_ctx, fd, p->name); if (rc < 0) { DEBUGMSGTL(("access:dot3StatsTable", "error getting the statistics for interface |%s| " "dot3StatsTable data, operation might not be supported\n", p->name)); dot3StatsTable_release_rowreq_ctx(rowreq_ctx); continue; } //rc = interface_ioctl_dot3stats_duplex_get(rowreq_ctx, fd, p->name); if (rc < 0) { DEBUGMSGTL(("access:dot3StatsTable", "error getting the duplex status for |%s| " "dot3StatsTable data, operation might not be supported\n", p->name)); dot3StatsTable_release_rowreq_ctx(rowreq_ctx); continue; } #endif /* * insert into table container */ CONTAINER_INSERT(container, rowreq_ctx); ++count; pp=pp->next; //break; } sp=sp->next; } } if((ret==0)&&(num>0)) { Free_ethslot_head(&head); } close(fd); /* * free the interface names list */ #if 0 if ( (dot3stats_interface_name_list_free(list_head)) < 0) { snmp_log(LOG_ERR, "access:dot3StatsTable, error freeing the interface name list \n"); DEBUGMSGTL(("access:dot3StatsTable", "error freeing the interface name list\n")); return MFD_ERROR; } DEBUGMSGT(("verbose:dot3StatsTable:dot3StatsTable_container_load", "inserted %d records\n", count)); #endif #endif return MFD_SUCCESS; } /* dot3StatsTable_container_load */
int dot3StatsTable_container_load(netsnmp_container * container) { dot3StatsTable_rowreq_ctx *rowreq_ctx; size_t count = 0; int fd; #if defined(linux) long dot3StatsIndex; int rc = 0, retval = 0; struct ifname *list_head = NULL, *p = NULL; #endif DEBUGMSGTL(("verbose:dot3StatsTable:dot3StatsTable_container_load", "called\n")); /* * TODO:352:M: | |-> set indexes in new dot3StatsTable rowreq context. * data context will be set from the param (unless NULL, * in which case a new data context will be allocated) */ /* * temporary storage for index values */ /* * dot3StatsIndex(1)/InterfaceIndex/ASN_INTEGER/long(long)//l/A/w/e/R/d/H */ /* * create socket for ioctls */ fd = socket(AF_INET, SOCK_DGRAM, 0); if(fd < 0) { snmp_log(LOG_ERR, "could not create socket\n"); return -2; } /* * get the interface names of the devices present in the system, in case of failure retval suggests the reson for failure * and list_head contains null */ #if defined(linux) list_head = dot3stats_interface_name_list_get (list_head, &retval); if (!list_head) { snmp_log (LOG_ERR, "access:dot3StatsTable, error getting the interface names present in the system\n"); DEBUGMSGTL(("access:dot3StatsTable", "error getting the interface names present in the system")); close(fd); return MFD_ERROR; } /* * Walk over the list of interface names present in the system and retreive the statistics */ for (p = list_head; p; p = p->ifn_next) { DEBUGMSGTL(("access:dot3StatsTable", "processing '%s'\n", p->name)); /* * get index via ioctl. */ dot3StatsIndex = (long) dot3stats_interface_ioctl_ifindex_get(-1, p->name); /* * get the dot3stats contents populated, if the device is not an ethernet device * the operation will not be supported and an error message will be logged */ rowreq_ctx = dot3StatsTable_allocate_rowreq_ctx(NULL); if (NULL == rowreq_ctx) { snmp_log(LOG_ERR, "memory allocation for dot3StatsTable failed\n"); close(fd); return MFD_RESOURCE_UNAVAILABLE; } if (MFD_SUCCESS != dot3StatsTable_indexes_set(rowreq_ctx, dot3StatsIndex)) { snmp_log(LOG_ERR, "error setting index while loading " "dot3StatsTable data.\n"); dot3StatsTable_release_rowreq_ctx(rowreq_ctx); continue; } /* * TODO:352:r: | |-> populate dot3StatsTable data context. * Populate data context here. (optionally, delay until row prep) */ /* * non-TRANSIENT data: no need to copy. set pointer to data */ memset (&rowreq_ctx->data, 0, sizeof (rowreq_ctx->data)); interface_sysclassnet_dot3stats_get(rowreq_ctx, p->name); interface_dot3stats_get_errorcounters(rowreq_ctx, p->name); rc = interface_ioctl_dot3stats_get (rowreq_ctx, fd, p->name); if (rc < 0) { DEBUGMSGTL(("access:dot3StatsTable", "error getting the statistics for interface |%s| " "dot3StatsTable data, operation might not be supported\n", p->name)); dot3StatsTable_release_rowreq_ctx(rowreq_ctx); continue; } rc = interface_ioctl_dot3stats_duplex_get(rowreq_ctx, fd, p->name); if (rc < 0) { DEBUGMSGTL(("access:dot3StatsTable", "error getting the duplex status for |%s| " "dot3StatsTable data, operation might not be supported\n", p->name)); dot3StatsTable_release_rowreq_ctx(rowreq_ctx); continue; } /* * insert into table container */ rc = CONTAINER_INSERT(container, rowreq_ctx); if (rc < 0) { DEBUGMSGTL(("access:dot3StatsTable", "error inserting |%s|", p->name)); dot3StatsTable_release_rowreq_ctx(rowreq_ctx); continue; } ++count; } close(fd); /* * free the interface names list */ if ( (dot3stats_interface_name_list_free(list_head)) < 0) { snmp_log(LOG_ERR, "access:dot3StatsTable, error freeing the interface name list \n"); DEBUGMSGTL(("access:dot3StatsTable", "error freeing the interface name list\n")); return MFD_ERROR; } #endif DEBUGMSGT(("verbose:dot3StatsTable:dot3StatsTable_container_load", "inserted %" NETSNMP_PRIz "d records\n", count)); return MFD_SUCCESS; } /* dot3StatsTable_container_load */