Esempio n. 1
0
netsnmp_variable_list *
tcpTable_next_entry( void **loop_context,
                     void **data_context,
                     netsnmp_variable_list *index,
                     netsnmp_iterator_info *data)
{
    TCPTABLE_ENTRY_TYPE	 *entry = (TCPTABLE_ENTRY_TYPE *)*loop_context;
    netsnmp_variable_list *idx;
    long addr, port;

    if (!entry)
        return NULL;

    /*
     * Set up the indexing for the specified row...
     */
    idx = index;
#if defined(osf5) && defined(IN6_EXTRACT_V4ADDR)
    addr = ntohl(IN6_EXTRACT_V4ADDR(&entry->pcb.inp_laddr));
#else
    addr = ntohl(entry->TCPTABLE_LOCALADDRESS);
#endif
    snmp_set_var_value(idx, (u_char *)&addr, sizeof(addr));

    port = TCP_PORT_TO_HOST_ORDER(entry->TCPTABLE_LOCALPORT);
    idx = idx->next_variable;
    snmp_set_var_value(idx, (u_char*)&port, sizeof(port));

    idx = idx->next_variable;
#if defined(osf5) && defined(IN6_EXTRACT_V4ADDR)
    addr = ntohl(IN6_EXTRACT_V4ADDR(&entry->pcb.inp_faddr));
#else
    addr = ntohl(entry->TCPTABLE_REMOTEADDRESS);
#endif
    snmp_set_var_value(idx, (u_char *)&addr, sizeof(addr));

    port = TCP_PORT_TO_HOST_ORDER(entry->TCPTABLE_REMOTEPORT);
    idx = idx->next_variable;
    snmp_set_var_value(idx, (u_char*)&port, sizeof(port));

    /*
     * ... return the data structure for this row,
     * and update the loop context ready for the next one.
     */
    *data_context = (void*)entry;
    *loop_context = (void*)entry->INP_NEXT_SYMBOL;
    return index;
}
Esempio n. 2
0
netsnmp_variable_list *
udpTable_next_entry( void **loop_context,
                     void **data_context,
                     netsnmp_variable_list *index,
                     netsnmp_iterator_info *data)
{
    UDPTABLE_ENTRY_TYPE	 *entry = (UDPTABLE_ENTRY_TYPE *)*loop_context;
    long port;
    in_addr_t addr;

    if (!entry)
        return NULL;

    /*
     * Set up the indexing for the specified row...
     */
#if defined(osf5) && defined(IN6_EXTRACT_V4ADDR)
                snmp_set_var_value(index,
                              (u_char*)&IN6_EXTRACT_V4ADDR(&entry->pcb.inp_laddr),
                                 sizeof(IN6_EXTRACT_V4ADDR(&entry->pcb.inp_laddr)));
#else
    addr = UDP_ADDRESS_TO_NETWORK_ORDER((in_addr_t)entry->UDPTABLE_LOCALADDRESS);
    snmp_set_var_value(index, (u_char *)&addr,
                                 sizeof(entry->UDPTABLE_LOCALADDRESS));
#endif
    port = UDP_PORT_TO_HOST_ORDER(entry->UDPTABLE_LOCALPORT);
    snmp_set_var_value(index->next_variable,
                               (u_char*)&port, sizeof(port));

    /*
     * ... return the data structure for this row,
     * and update the loop context ready for the next one.
     */
    *data_context = (void*)entry;
    *loop_context = (void*)entry->INP_NEXT_SYMBOL;
    return index;
}
Esempio n. 3
0
int
udpTable_handler(netsnmp_mib_handler          *handler,
                 netsnmp_handler_registration *reginfo,
                 netsnmp_agent_request_info   *reqinfo,
                 netsnmp_request_info         *requests)
{
    netsnmp_request_info  *request;
    netsnmp_variable_list *requestvb;
    netsnmp_table_request_info *table_info;
    UDPTABLE_ENTRY_TYPE	  *entry;
    oid      subid;
    long     port,addr;

    DEBUGMSGTL(("mibII/udpTable", "Handler - mode %s\n",
                se_find_label_in_slist("agent_mode", reqinfo->mode)));
    switch (reqinfo->mode) {
    case MODE_GET:
        for (request=requests; request; request=request->next) {
            requestvb = request->requestvb;
            DEBUGMSGTL(( "mibII/udpTable", "oid: "));
            DEBUGMSGOID(("mibII/udpTable", requestvb->name,
                         requestvb->name_length));
            DEBUGMSG((   "mibII/udpTable", "\n"));

            entry = (UDPTABLE_ENTRY_TYPE *)netsnmp_extract_iterator_context(request);
            if (!entry)
                continue;
            table_info = netsnmp_extract_table_info(request);
            subid      = table_info->colnum;

            switch (subid) {
            case UDPLOCALADDRESS:
#if defined(osf5) && defined(IN6_EXTRACT_V4ADDR)
                addr = ntohl(IN6_EXTRACT_V4ADDR(&entry->pcb.inp_laddr));
                snmp_set_var_typed_value(requestvb, ASN_IPADDRESS,
                                         (u_char*)&addr,
                                         sizeof(addr));
#else
                addr = UDP_ADDRESS_TO_HOST_ORDER(entry->UDPTABLE_LOCALADDRESS);
                snmp_set_var_typed_value(requestvb, ASN_IPADDRESS,
                                         (u_char *)&addr,
                                         sizeof(addr));
#endif
                break;
            case UDPLOCALPORT:
                port = UDP_PORT_TO_HOST_ORDER((u_short)entry->UDPTABLE_LOCALPORT);
                snmp_set_var_typed_value(requestvb, ASN_INTEGER,
                                         (u_char *)&port, sizeof(port));
                break;
            }
        }
        break;

    case MODE_GETNEXT:
    case MODE_GETBULK:
    case MODE_SET_RESERVE1:
    case MODE_SET_RESERVE2:
    case MODE_SET_ACTION:
    case MODE_SET_COMMIT:
    case MODE_SET_FREE:
    case MODE_SET_UNDO:
        snmp_log(LOG_WARNING, "mibII/udpTable: Unsupported mode (%d)\n",
                 reqinfo->mode);
        break;
    default:
        snmp_log(LOG_WARNING, "mibII/udpTable: Unrecognised mode (%d)\n",
                 reqinfo->mode);
        break;
    }

    return SNMP_ERR_NOERROR;
}