Roxen.git / server / etc / modules / SNMP.pmod

version» Context lines:

Roxen.git/server/etc/modules/SNMP.pmod:1:   //   // SNMP helper stuff.   // - // $Id: SNMP.pmod,v 1.1 2007/09/10 11:07:42 grubba Exp $ + // $Id: SNMP.pmod,v 1.2 2007/09/10 15:15:36 grubba Exp $   //   // 2007-08-29 Henrik Grubbström   //      // Some OIDs      //! iso.organizations.dod.internet   constant INTERNET_OID = ({ 1, 3, 6, 1 });      //! iso.organizations.dod.internet.private.enterprises.roxenis   constant RIS_OID = INTERNET_OID + ({ 4, 1, 8614 });      //! iso.organizations.dod.internet.private.enterprises.roxenis.app.webserver   constant RIS_OID_WEBSERVER = RIS_OID + ({ 1, 1 });      class Documentation(string name,    string doc)   {   }    -  + class Updateable(function(:mixed) fun) + { +  void update_value() +  { +  if (fun) { +  this_object()->value = fun(); +  } +  } + } +    // ASN1 datatypes.      class app_integer   {    inherit Standards.ASN1.Types.asn1_integer : integer;    inherit Documentation : doc; -  +  inherit Updateable : update;    constant cls = 1;    constant type_name = "APPLICATION INTEGER";    constant tag = 0; -  static void create(int val, string|void name, string|void doc_string) +  static void create(int|function(:int) val, string|void name, string|void doc_string)    { -  +  if (intp(val)) { +  update::create(UNDEFINED);    integer::create(val); -  +  } else { +  update::create(val); +  integer::create(val()); +  }    doc::create(name, doc_string);    }   }      class app_octet_string   {    inherit Standards.ASN1.Types.asn1_octet_string : octet_string;    inherit Documentation : doc; -  +  inherit Updateable : update;    constant cls = 1;    constant type_name = "APPLICATION OCTET_STRING";    constant tag = 0; -  static void create(string val, string|void name, string|void doc_string) +  static void create(string|function(:string) val, string|void name, string|void doc_string)    { -  +  if (stringp(val)) { +  update::create(UNDEFINED);    octet_string::create(val); -  +  } else { +  update::create(val); +  octet_string::create(val()); +  }    doc::create(name, doc_string);    }   }      class OID   {    inherit Standards.ASN1.Types.asn1_identifier : identifier;    inherit Documentation : doc;    constant type_name = "OID";    static void create(array(int) oid, string|void name, string|void doc_string)    {    identifier::create(@oid);    doc::create(name, doc_string);    }   }      class Integer   {    inherit Standards.ASN1.Types.asn1_integer : integer;    inherit Documentation : doc; -  +  inherit Updateable : update;    constant type_name = "INTEGER"; -  static void create(int val, string|void name, string|void doc_string) +  static void create(int|function(:int) val, string|void name, string|void doc_string)    { -  +  if (intp(val)) { +  update::create(UNDEFINED);    integer::create(val); -  +  } else { +  update::create(val); +  integer::create(val()); +  }    doc::create(name, doc_string);    }   }      class String   {    inherit Standards.ASN1.Types.asn1_octet_string : octet_string;    inherit Documentation : doc; -  +  inherit Updateable : update;    constant type_name = "STRING"; -  static void create(string val, string|void name, string|void doc_string) +  static void create(string|function(:string) val, string|void name, string|void doc_string)    { -  +  if (stringp(val)) { +  update::create(UNDEFINED);    octet_string::create(val); -  +  } else { +  update::create(val); +  octet_string::create(val()); +  }    doc::create(name, doc_string);    }   }      class Counter   {    inherit app_integer;    constant tag = 1;    constant type_name = "COUNTER";   }