pike.git / lib / modules / Protocols.pmod / SNMP.pmod / protocol.pike

version» Context lines:

pike.git/lib/modules/Protocols.pmod/SNMP.pmod/protocol.pike:4:   //:   //: RFC:   //: implemented (yet):   //: 1155-7 : v1   //: 1901-4 : v2/community (Bulk ops aren't implemented!)   //: planned:   // 2742 : agentX   //: 2570 : v3 description   //:    - // $Id: protocol.pike,v 1.2 2001/05/09 13:52:03 hop Exp $ + // $Id: protocol.pike,v 1.3 2001/09/11 13:39:19 hop Exp $         #include "snmp_globals.h"   #include "snmp_errors.h"      #if 1   // --- ASN.1 hack   class asn1_application_octet_string   {    inherit Standards.ASN1.Types.asn1_octet_string;
pike.git/lib/modules/Protocols.pmod/SNMP.pmod/protocol.pike:156:   inherit Stdio.UDP : snmp;      //:   //: public vars   //:         //:   //: private variables   //: - int port = SNMP_DEFAULT_PORT; + int port; // = SNMP_DEFAULT_PORT;   string local_host = SNMP_DEFAULT_HOST;   string remote_host;   int request_id = 1;   int next_id = 1;   int snmp_version = SNMP_DEFAULT_VERSION;   string snmp_community = SNMP_DEFAULT_COMMUNITY;   int snmp_errno = SNMP_SUCCESS;   int ok;      //:
pike.git/lib/modules/Protocols.pmod/SNMP.pmod/protocol.pike:328:   //:   int get_request(array(string) varlist, string|void rem_addr,    int|void rem_port) {    //: GetRequest-PDU low call    object pdu;    int id = get_req_id(), flg;    array vararr = ({});       foreach(varlist, string varname)    vararr += ({Standards.ASN1.Types.asn1_sequence( -  ({Standards.ASN1.Types.asn1_identifier(@Array.map(varname/".", lambda(string el){ return((int)el);})), +  ({Standards.ASN1.Types.asn1_identifier( +  @Array.map(varname/".", lambda(string el){ return((int)el);})),    Standards.ASN1.Types.asn1_integer(1)}) //doesn't sense but req    )});       pdu = Protocols.LDAP.ldap_privates.asn1_context_sequence(0,    ({Standards.ASN1.Types.asn1_integer(id), // request-id    Standards.ASN1.Types.asn1_integer(0), // error-status    Standards.ASN1.Types.asn1_integer(0), // error-index    Standards.ASN1.Types.asn1_sequence(vararr)})    );       // now we have PDU ... -  flg = writemsg(rem_addr||remote_host, rem_port || port, pdu); +  flg = writemsg(rem_addr||remote_host, rem_port || port || SNMP_DEFAULT_PORT, pdu);       return id;      }      object mk_asn1_val(string type, int|string val) {   // returns appropriate ASN.1 value       object rv;   
pike.git/lib/modules/Protocols.pmod/SNMP.pmod/protocol.pike:422:    }       pdu = Protocols.LDAP.ldap_privates.asn1_context_sequence(2,    ({Standards.ASN1.Types.asn1_integer(id), // request-id    Standards.ASN1.Types.asn1_integer(errcode), // error-status    Standards.ASN1.Types.asn1_integer(erridx), // error-index    Standards.ASN1.Types.asn1_sequence(vararr)})    );       // now we have PDU ... -  flg = writemsg(origdata[id]->ip||remote_host, origdata[id]->port||port, pdu); +  flg = writemsg(origdata[id]->ip||remote_host, origdata[id]->port || port || SNMP_DEFAULT_PORT, pdu);       return id;      }         //:   //: get_nextrequest   //:   int get_nextrequest(array(string) varlist, string|void rem_addr,    int|void rem_port) {    //: GetNextRequest-PDU low call    object pdu;    int id = get_req_id(), flg;    array vararr = ({});       foreach(varlist, string varname)    vararr += ({Standards.ASN1.Types.asn1_sequence( -  ({Standards.ASN1.Types.asn1_identifier(@Array.map(varname/".", lambda(string el){ return((int)el);})), +  ({Standards.ASN1.Types.asn1_identifier( +  @Array.map(varname/".", lambda(string el){ return((int)el);})),    Standards.ASN1.Types.asn1_integer(1)}) //doesn't sense but req    )});       pdu = Protocols.LDAP.ldap_privates.asn1_context_sequence(1,    ({Standards.ASN1.Types.asn1_integer(id), // request-id    Standards.ASN1.Types.asn1_integer(0), // error-status    Standards.ASN1.Types.asn1_integer(0), // error-index    Standards.ASN1.Types.asn1_sequence(vararr)})    );       // now we have PDU ... -  flg = writemsg(rem_addr||remote_host, rem_port || port, pdu); +  flg = writemsg(rem_addr||remote_host, rem_port || port || SNMP_DEFAULT_PORT, pdu);       return id;      }      //:   //: set_request   //:   int set_request(mapping varlist, string|void rem_addr,    int|void rem_port) {
pike.git/lib/modules/Protocols.pmod/SNMP.pmod/protocol.pike:484:    )});       pdu = Protocols.LDAP.ldap_privates.asn1_context_sequence(3,    ({Standards.ASN1.Types.asn1_integer(id), // request-id    Standards.ASN1.Types.asn1_integer(0), // error-status    Standards.ASN1.Types.asn1_integer(0), // error-index    Standards.ASN1.Types.asn1_sequence(vararr)})    );       // now we have PDU ... -  flg = writemsg(rem_addr||remote_host, rem_port || port, pdu); +  flg = writemsg(rem_addr||remote_host, rem_port || port || SNMP_DEFAULT_PORT, pdu);       return id;   }      //:   //: trap   //: - int trap(mapping varlist, string|void rem_addr, -  int|void rem_port) { + int trap(mapping varlist, string oid, int type, int spectype, int ticks, +  string|void locip, string|void remaddr, int|void remport) {    //: Trap-PDU low call    object pdu;    int id = get_req_id(), flg;    array vararr = ({}); -  +  string lip = "1234";    -  + // DWRITE(sprintf("protocols.trap: varlist: %O, oid: %O, type: %O, spectype: %O," + // " ticks: %O, locip: %O, remaddr: %O, remport: %O\n", + // varlist, oid, type, spectype, ticks, locip, remaddr, remport)); +  locip = locip || "0.0.0.0"; +  if (sizeof(locip/".") != 4) +  locip = "0.0.0.0"; //FIXME: what for hell I want to do with such ugly value? +  //sscanf(locip, "%d.%d.%d.%d", @lip); +  sscanf(locip, "%d.%d.%d.%d", lip[0], lip[1], lip[2], lip[3]); +     foreach(indices(varlist), string varname)    vararr += ({Standards.ASN1.Types.asn1_sequence(    ({Standards.ASN1.Types.asn1_identifier(    @Array.map(varname/".", lambda(string el){ return((int)el);})),    mk_asn1_val(varlist[varname][0], varlist[varname][1])})    )}); -  +     pdu = Protocols.LDAP.ldap_privates.asn1_context_sequence(4, -  ({Standards.ASN1.Types.asn1_integer(id), // request-id -  Standards.ASN1.Types.asn1_integer(0), // error-status -  Standards.ASN1.Types.asn1_integer(0), // error-index -  Standards.ASN1.Types.asn1_sequence(vararr)}) +  ({ +  mk_asn1_val("oid", oid), // enterprise OID +  mk_asn1_val("ipaddr", lip), // ip address (UGLY!) +  mk_asn1_val("int", type), // type (0 = coldstart, ...) +  mk_asn1_val("int", spectype), // enterprise type +  mk_asn1_val("tick", ticks), // uptime +  Standards.ASN1.Types.asn1_sequence(vararr) // optional vars +  }) +     );       // now we have PDU ... -  flg = writemsg(rem_addr||remote_host, rem_port || port, pdu); +  flg = writemsg(remaddr||remote_host, remport || port || SNMP_DEFAULT_TRAPPORT, pdu);       return id;   }