summaryrefslogtreecommitdiff
path: root/ASNMP/asnmp
diff options
context:
space:
mode:
Diffstat (limited to 'ASNMP/asnmp')
-rw-r--r--ASNMP/asnmp/ChangeLog161
-rw-r--r--ASNMP/asnmp/Makefile744
-rw-r--r--ASNMP/asnmp/TODO25
-rw-r--r--ASNMP/asnmp/address.cpp2686
-rw-r--r--ASNMP/asnmp/address.h812
-rw-r--r--ASNMP/asnmp/asn1.cpp1728
-rw-r--r--ASNMP/asnmp/asn1.h342
-rw-r--r--ASNMP/asnmp/counter.cpp106
-rw-r--r--ASNMP/asnmp/counter.h79
-rw-r--r--ASNMP/asnmp/ctr64.cpp211
-rw-r--r--ASNMP/asnmp/ctr64.h110
-rw-r--r--ASNMP/asnmp/enttraps.h118
-rw-r--r--ASNMP/asnmp/gauge.cpp113
-rw-r--r--ASNMP/asnmp/gauge.h80
-rw-r--r--ASNMP/asnmp/integer.cpp227
-rw-r--r--ASNMP/asnmp/integer.h140
-rw-r--r--ASNMP/asnmp/octet.cpp594
-rw-r--r--ASNMP/asnmp/octet.h150
-rw-r--r--ASNMP/asnmp/oid.cpp800
-rw-r--r--ASNMP/asnmp/oid.h170
-rw-r--r--ASNMP/asnmp/oid_def.h87
-rw-r--r--ASNMP/asnmp/pdu.cpp496
-rw-r--r--ASNMP/asnmp/pdu.h213
-rw-r--r--ASNMP/asnmp/sagent.cpp97
-rw-r--r--ASNMP/asnmp/sagent.h83
-rw-r--r--ASNMP/asnmp/smi.h153
-rw-r--r--ASNMP/asnmp/smival.h104
-rw-r--r--ASNMP/asnmp/snmp.cpp283
-rw-r--r--ASNMP/asnmp/snmp.h134
-rw-r--r--ASNMP/asnmp/snmperrs.h214
-rw-r--r--ASNMP/asnmp/target.cpp324
-rw-r--r--ASNMP/asnmp/target.h252
-rw-r--r--ASNMP/asnmp/timetick.cpp142
-rw-r--r--ASNMP/asnmp/timetick.h85
-rw-r--r--ASNMP/asnmp/transaction.cpp202
-rw-r--r--ASNMP/asnmp/transaction.h80
-rw-r--r--ASNMP/asnmp/transaction_result.h29
-rw-r--r--ASNMP/asnmp/vb.cpp396
-rw-r--r--ASNMP/asnmp/vb.h204
-rw-r--r--ASNMP/asnmp/wpdu.cpp520
-rw-r--r--ASNMP/asnmp/wpdu.h85
41 files changed, 0 insertions, 13579 deletions
diff --git a/ASNMP/asnmp/ChangeLog b/ASNMP/asnmp/ChangeLog
deleted file mode 100644
index af4c2469745..00000000000
--- a/ASNMP/asnmp/ChangeLog
+++ /dev/null
@@ -1,161 +0,0 @@
-Tue Mar 16 16:28:14 1999 David L. Levine <levine@cs.wustl.edu>
-
- * address.cpp, address.h, asn1.cpp, asn1.h, counter.cpp, ctr64.cpp,
- gauge.cpp, integer.cpp, octet.cpp, oid.cpp, pdu.cpp, sagent.cpp,
- snmp.cpp, target.cpp, timetick.cpp, transaction.cpp, vb.cpp,
- wpdu.cpp:
- replaced TRUE with 1, and FALSE and NULL with 0. Thanks to
- Achint Sandhu <sandhu@nortelnetworks.com> for reporting that
- TRUE and FALSE weren't define on his Linux platform.
-
- * wpdu.cpp (set_trap_info): wrapped condition with () to
- avoid g++ warning about using result of an assignment as
- the condition.
-
- * ctr64.cpp: made MAX64 unsigned, to avoid warning about it
- being to big to be signed.
-
-Wed Jul 15 20:27:23 1998 Mike MacFaden <mrm@tango.cs.wustl.edu>
- * asn1.cpp - Hien Nguyen <hnguyen@apexgrp.com> fixed these bugs:
-
- Problem: The V1 trap agent-addr field tag value is OCTET STRING
- instead of IPADDRESS, and the time stamp field tag value is INTEGER
- instead of TIME TICKS.
-
- Fix: Change cmu_snmp::build() to pass in the correct type for agent-addr
- and time stamp.
-
- 2. Problem: The V1 trap enterprise OID is corrupted after is was set in
- wpdu constructor.
-
- Fix: In wpdu::set_trap_info(), the raw_pdu enterprise OID pointer was
- assigned to the raw data of an enterprise Oid object on the stack.
- Changed to perform an ACE_NEW_RETURN on the raw_pdu->enterprise and
- perform a memcpy to copy the OID. The allocated memory is freed in
- cmu_snmp::free_pdu() as currently implemented.
-
- 3. The V1 trap agent-addr field is currently initialized to "0.0.0.0".
- I changed wpdu::set_trap_info to initialize it to the local host IP
- Address.
-
- 4. I noticed that the memory allocation for OID in asn1.cpp using
- ACE_NEW consistently use (OID length * size(oid)) as the size.
- Shouldn't it be simply OID length ? Since there are numerous instances
- of this usage in asn1.cpp, I have not fixed those. If you can double
- check and fix these, I appreciate it.
-
-
-Wed Aug 20 15:11:23 1997 Mike MacFaden <mrm@tango.cs.wustl.edu>
-
- * rebuilt Makefile using g++dep
-
- * pdu.h pdu.cpp initialization errors fixed
-
- * address.h address.cpp IpAddress::to_octet() added
-
-Fri Aug 1 19:23:52 1997 Mike MacFaden (mrm@mrm-ss20)
-
- * NOTES: This first version only tested on Solaris 2.5
-
- * review classes for thread safety. Current thread design only
- allows for one thread to safely access any ASNMP object created.
-
- * run purify test of get routine no -memory leaks.
-
- * verify both shared archive/static archive types work with
- example programs
-
- * << Globals Changes >>
-
- * tested only archiver library version
-
- * reformat code to use one brace style.
-
- * changed all manifest constants defined as _XX to XX_ to stay out
- of compiler namespace
-
- * change all OS calls to use ACE_OS:: portability layer, #include
- <ace/OS.h>
-
- * reformat code to use one consistent brace layout and redo
- header using ACE
-
- * remove semicolons on member functions foo{}; - not necessary
-
- * make get() methods const member functions
-
- * removed unnecessary casts that looked like this: and revamped
- all memory allocations via ACE_NEW macro
-
- new_oid = (SmiLPUINT32) new unsigned long [ smival.value.oid.len
-
- To
-
- ACE_NEW(new_oid, SmiUINT32[ smival.value.oid.len])
-
- * Collapsed default constructors with constructors to constructors
- with default arguments.
-
- * removed unused #include <iostream.h>
-
- * Added ACE_TRACE() to classes
-
- * change get_printable() to to_string() - there will be more java
- programmers in the future so this should be the first step...
-
- * removed ASYNC interface till it can be rebuilt using ACE patterns
-
- * Attempt to make interface more type strict but leaving generic
- interfaces as escape hatch. Example: CTarget becomes UdpTarget
- for UDP/IP based agents.
-
- * << Class Specific Changes >>
-
- * Oid class:
- - remove char * routines, simplify class
- - added suboid method and removed get_printable() overloads
-
- * CTarget class:
- - renamed to UdpTarget. Stay out of Microsoft Namespace per MSJ
- Article by Allen Hollub.
-
- * Varbind class:
- - remove generic set_value for char,int, etc. Too easy to get
- this wrong. Allow just types defined.
- - added overload for equality operator (==)
- - added new constructor to allow setting full vb state oid,value, exception
- - add to_string()
-
- * Address class:
- - change manifest constants to enums for address lengths, add IP V6 lens
-
- - add a netbios name class, still pretty worthless since I don't have spec
- in front of me yet...
-
- - rewrite resolver calls to be thread safe and cleaner by moving to two
- class (static) member functions:
-
- // thread safe routine to lookup ip address given hostname
- // return <> 0 on error
- static int resolve_to_addr(const char *hostname, in_addr& quad_addr);
-
- // thread safe routine to lookup name given ip address
- // return <> 0 on error
- static int resolve_to_hostname(const in_addr& quad_addr, char *hostname)
-
- * added some interrogation routines to class IpAddress:
- is_loopback() const;
-
- * Ctr64 class:
- - added constructor using long long datatype (needs to be made
- portable to NT
-
- * Pdu class: add to_string()
-
- * Classes added wpdu class:
- - a new adpater class between CMU and HP pdu, varbind data structures
-
- * transaction class:
- - implement get/getnext timeout and retry logic using ACE
- Reactor class, ACE_Time_Value
-
diff --git a/ASNMP/asnmp/Makefile b/ASNMP/asnmp/Makefile
deleted file mode 100644
index e95cd7d2e32..00000000000
--- a/ASNMP/asnmp/Makefile
+++ /dev/null
@@ -1,744 +0,0 @@
-#----------------------------------------------------------------------------
-# $Id$
-#
-# Makefile for the SNMP+ACE Release
-#----------------------------------------------------------------------------
-
-MAKEFILE = Makefile
-LIB = libasnmp.a
-SHLIB = libasnmp.$(SOEXT)
-
-FILES = address \
- asn1 \
- counter \
- ctr64 \
- gauge \
- integer \
- octet \
- oid \
- pdu \
- snmp \
- target \
- timetick \
- transaction \
- vb \
- wpdu \
- sagent
-
-TEMPLATE_FILES =
-
-DEFS = $(addsuffix .h,$(FILES))
-DEFS += $(addsuffix .i,$(FILES))
-LSRC = $(addsuffix .cpp,$(FILES))
-#LSRC2 = $(addsuffix .cpp,$(TEMPLATE_FILES))
-
-#### Build the SNMP++ shared library _before_ the static library.
-#### This works around an apparent problem with template
-#### instantiation with Sun C++ 4.1 and 4.2 (the symptom is link
-#### error due to ACE_TimeValue::normalize () not being found).
-BUILD = $(VSHLIB) $(SHLIBA) $(VLIB)
-
-# For make depend:
-SRC = -I..
-
-#----------------------------------------------------------------------------
-# Include macros and targets
-#----------------------------------------------------------------------------
-
-include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU
-include $(ACE_ROOT)/include/makeinclude/macros.GNU
-include $(ACE_ROOT)/include/makeinclude/rules.common.GNU
-include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU
-include $(ACE_ROOT)/include/makeinclude/rules.lib.GNU
-include $(ACE_ROOT)/include/makeinclude/rules.local.GNU
-
-#----------------------------------------------------------------------------
-# Local targets
-#----------------------------------------------------------------------------
-
-CCFLAGS += -I$(ACE_ROOT)/ASNMP/
-
-#----------------------------------------------------------------------------
-# Dependencies
-#----------------------------------------------------------------------------
-# DO NOT DELETE THIS LINE -- g++dep uses it.
-# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY.
-
-.obj/address.o .obj/address.so .shobj/address.o .shobj/address.so: address.cpp ../asnmp/address.h \
- $(ACE_ROOT)/ace/OS.h \
- $(ACE_ROOT)/ace/inc_user_config.h \
- $(ACE_ROOT)/ace/config.h \
- $(ACE_ROOT)/ace/config-sunos5.6.h \
- $(ACE_ROOT)/ace/config-sunos5.5.h \
- $(ACE_ROOT)/ace/config-g++-common.h \
- $(ACE_ROOT)/ace/streams.h \
- $(ACE_ROOT)/ace/Basic_Types.h \
- $(ACE_ROOT)/ace/Basic_Types.i \
- $(ACE_ROOT)/ace/OS.i \
- $(ACE_ROOT)/ace/Trace.h \
- $(ACE_ROOT)/ace/Log_Msg.h \
- $(ACE_ROOT)/ace/Log_Record.h \
- $(ACE_ROOT)/ace/ACE.h \
- $(ACE_ROOT)/ace/ACE.i \
- $(ACE_ROOT)/ace/Log_Priority.h \
- $(ACE_ROOT)/ace/Log_Record.i ../asnmp/smival.h \
- ../asnmp/smi.h ../asnmp/octet.h
-.obj/asn1.o .obj/asn1.so .shobj/asn1.o .shobj/asn1.so: asn1.cpp ../asnmp/asn1.h \
- $(ACE_ROOT)/ace/OS.h \
- $(ACE_ROOT)/ace/inc_user_config.h \
- $(ACE_ROOT)/ace/config.h \
- $(ACE_ROOT)/ace/config-sunos5.6.h \
- $(ACE_ROOT)/ace/config-sunos5.5.h \
- $(ACE_ROOT)/ace/config-g++-common.h \
- $(ACE_ROOT)/ace/streams.h \
- $(ACE_ROOT)/ace/Basic_Types.h \
- $(ACE_ROOT)/ace/Basic_Types.i \
- $(ACE_ROOT)/ace/OS.i \
- $(ACE_ROOT)/ace/Trace.h \
- $(ACE_ROOT)/ace/Log_Msg.h \
- $(ACE_ROOT)/ace/Log_Record.h \
- $(ACE_ROOT)/ace/ACE.h \
- $(ACE_ROOT)/ace/ACE.i \
- $(ACE_ROOT)/ace/Log_Priority.h \
- $(ACE_ROOT)/ace/Log_Record.i ../asnmp/snmp.h \
- $(ACE_ROOT)/ace/Reactor.h \
- $(ACE_ROOT)/ace/Handle_Set.h \
- $(ACE_ROOT)/ace/Handle_Set.i \
- $(ACE_ROOT)/ace/Timer_Queue.h \
- $(ACE_ROOT)/ace/Synch.h \
- $(ACE_ROOT)/ace/SV_Semaphore_Complex.h \
- $(ACE_ROOT)/ace/SV_Semaphore_Simple.h \
- $(ACE_ROOT)/ace/SV_Semaphore_Simple.i \
- $(ACE_ROOT)/ace/SV_Semaphore_Complex.i \
- $(ACE_ROOT)/ace/Synch.i \
- $(ACE_ROOT)/ace/Synch_T.h \
- $(ACE_ROOT)/ace/Event_Handler.h \
- $(ACE_ROOT)/ace/Event_Handler.i \
- $(ACE_ROOT)/ace/Synch_T.i \
- $(ACE_ROOT)/ace/Thread.h \
- $(ACE_ROOT)/ace/Thread.i \
- $(ACE_ROOT)/ace/Atomic_Op.i \
- $(ACE_ROOT)/ace/Synch_T.cpp \
- $(ACE_ROOT)/ace/Timer_Queue_T.h \
- $(ACE_ROOT)/ace/Free_List.h \
- $(ACE_ROOT)/ace/Free_List.i \
- $(ACE_ROOT)/ace/Free_List.cpp \
- $(ACE_ROOT)/ace/Timer_Queue_T.i \
- $(ACE_ROOT)/ace/Timer_Queue_T.cpp \
- $(ACE_ROOT)/ace/Signal.h \
- $(ACE_ROOT)/ace/Containers.h \
- $(ACE_ROOT)/ace/Containers.i \
- $(ACE_ROOT)/ace/Containers_T.h \
- $(ACE_ROOT)/ace/Containers_T.i \
- $(ACE_ROOT)/ace/Containers_T.cpp \
- $(ACE_ROOT)/ace/Malloc.h \
- $(ACE_ROOT)/ace/Malloc_Base.h \
- $(ACE_ROOT)/ace/Malloc.i \
- $(ACE_ROOT)/ace/Malloc_T.h \
- $(ACE_ROOT)/ace/Malloc_T.i \
- $(ACE_ROOT)/ace/Malloc_T.cpp \
- $(ACE_ROOT)/ace/Memory_Pool.h \
- $(ACE_ROOT)/ace/Mem_Map.h \
- $(ACE_ROOT)/ace/Mem_Map.i \
- $(ACE_ROOT)/ace/Memory_Pool.i \
- $(ACE_ROOT)/ace/Signal.i \
- $(ACE_ROOT)/ace/Object_Manager.h \
- $(ACE_ROOT)/ace/Object_Manager.i \
- $(ACE_ROOT)/ace/Managed_Object.h \
- $(ACE_ROOT)/ace/Managed_Object.i \
- $(ACE_ROOT)/ace/Managed_Object.cpp \
- $(ACE_ROOT)/ace/Reactor.i \
- $(ACE_ROOT)/ace/Reactor_Impl.h \
- $(ACE_ROOT)/ace/SOCK_Dgram.h \
- $(ACE_ROOT)/ace/SOCK.h \
- $(ACE_ROOT)/ace/Addr.h \
- $(ACE_ROOT)/ace/Addr.i \
- $(ACE_ROOT)/ace/IPC_SAP.h \
- $(ACE_ROOT)/ace/IPC_SAP.i \
- $(ACE_ROOT)/ace/SOCK.i \
- $(ACE_ROOT)/ace/SOCK_Dgram.i ../asnmp/oid.h \
- ../asnmp/smival.h ../asnmp/smi.h ../asnmp/vb.h ../asnmp/snmperrs.h \
- ../asnmp/timetick.h ../asnmp/integer.h ../asnmp/counter.h \
- ../asnmp/gauge.h ../asnmp/ctr64.h ../asnmp/octet.h ../asnmp/address.h \
- ../asnmp/target.h $(ACE_ROOT)/ace/INET_Addr.h \
- $(ACE_ROOT)/ace/INET_Addr.i ../asnmp/pdu.h \
- ../asnmp/transaction_result.h
-.obj/counter.o .obj/counter.so .shobj/counter.o .shobj/counter.so: counter.cpp ../asnmp/counter.h ../asnmp/smival.h \
- ../asnmp/smi.h $(ACE_ROOT)/ace/OS.h \
- $(ACE_ROOT)/ace/inc_user_config.h \
- $(ACE_ROOT)/ace/config.h \
- $(ACE_ROOT)/ace/config-sunos5.6.h \
- $(ACE_ROOT)/ace/config-sunos5.5.h \
- $(ACE_ROOT)/ace/config-g++-common.h \
- $(ACE_ROOT)/ace/streams.h \
- $(ACE_ROOT)/ace/Basic_Types.h \
- $(ACE_ROOT)/ace/Basic_Types.i \
- $(ACE_ROOT)/ace/OS.i \
- $(ACE_ROOT)/ace/Trace.h \
- $(ACE_ROOT)/ace/Log_Msg.h \
- $(ACE_ROOT)/ace/Log_Record.h \
- $(ACE_ROOT)/ace/ACE.h \
- $(ACE_ROOT)/ace/ACE.i \
- $(ACE_ROOT)/ace/Log_Priority.h \
- $(ACE_ROOT)/ace/Log_Record.i \
- ../asnmp/integer.h
-.obj/ctr64.o .obj/ctr64.so .shobj/ctr64.o .shobj/ctr64.so: ctr64.cpp ../asnmp/ctr64.h ../asnmp/smival.h ../asnmp/smi.h \
- $(ACE_ROOT)/ace/OS.h \
- $(ACE_ROOT)/ace/inc_user_config.h \
- $(ACE_ROOT)/ace/config.h \
- $(ACE_ROOT)/ace/config-sunos5.6.h \
- $(ACE_ROOT)/ace/config-sunos5.5.h \
- $(ACE_ROOT)/ace/config-g++-common.h \
- $(ACE_ROOT)/ace/streams.h \
- $(ACE_ROOT)/ace/Basic_Types.h \
- $(ACE_ROOT)/ace/Basic_Types.i \
- $(ACE_ROOT)/ace/OS.i \
- $(ACE_ROOT)/ace/Trace.h \
- $(ACE_ROOT)/ace/Log_Msg.h \
- $(ACE_ROOT)/ace/Log_Record.h \
- $(ACE_ROOT)/ace/ACE.h \
- $(ACE_ROOT)/ace/ACE.i \
- $(ACE_ROOT)/ace/Log_Priority.h \
- $(ACE_ROOT)/ace/Log_Record.i
-.obj/gauge.o .obj/gauge.so .shobj/gauge.o .shobj/gauge.so: gauge.cpp ../asnmp/gauge.h ../asnmp/integer.h \
- ../asnmp/smival.h ../asnmp/smi.h \
- $(ACE_ROOT)/ace/OS.h \
- $(ACE_ROOT)/ace/inc_user_config.h \
- $(ACE_ROOT)/ace/config.h \
- $(ACE_ROOT)/ace/config-sunos5.6.h \
- $(ACE_ROOT)/ace/config-sunos5.5.h \
- $(ACE_ROOT)/ace/config-g++-common.h \
- $(ACE_ROOT)/ace/streams.h \
- $(ACE_ROOT)/ace/Basic_Types.h \
- $(ACE_ROOT)/ace/Basic_Types.i \
- $(ACE_ROOT)/ace/OS.i \
- $(ACE_ROOT)/ace/Trace.h \
- $(ACE_ROOT)/ace/Log_Msg.h \
- $(ACE_ROOT)/ace/Log_Record.h \
- $(ACE_ROOT)/ace/ACE.h \
- $(ACE_ROOT)/ace/ACE.i \
- $(ACE_ROOT)/ace/Log_Priority.h \
- $(ACE_ROOT)/ace/Log_Record.i
-.obj/integer.o .obj/integer.so .shobj/integer.o .shobj/integer.so: integer.cpp ../asnmp/integer.h ../asnmp/smival.h \
- ../asnmp/smi.h $(ACE_ROOT)/ace/OS.h \
- $(ACE_ROOT)/ace/inc_user_config.h \
- $(ACE_ROOT)/ace/config.h \
- $(ACE_ROOT)/ace/config-sunos5.6.h \
- $(ACE_ROOT)/ace/config-sunos5.5.h \
- $(ACE_ROOT)/ace/config-g++-common.h \
- $(ACE_ROOT)/ace/streams.h \
- $(ACE_ROOT)/ace/Basic_Types.h \
- $(ACE_ROOT)/ace/Basic_Types.i \
- $(ACE_ROOT)/ace/OS.i \
- $(ACE_ROOT)/ace/Trace.h \
- $(ACE_ROOT)/ace/Log_Msg.h \
- $(ACE_ROOT)/ace/Log_Record.h \
- $(ACE_ROOT)/ace/ACE.h \
- $(ACE_ROOT)/ace/ACE.i \
- $(ACE_ROOT)/ace/Log_Priority.h \
- $(ACE_ROOT)/ace/Log_Record.i
-.obj/octet.o .obj/octet.so .shobj/octet.o .shobj/octet.so: octet.cpp $(ACE_ROOT)/ace/OS.h \
- $(ACE_ROOT)/ace/inc_user_config.h \
- $(ACE_ROOT)/ace/config.h \
- $(ACE_ROOT)/ace/config-sunos5.6.h \
- $(ACE_ROOT)/ace/config-sunos5.5.h \
- $(ACE_ROOT)/ace/config-g++-common.h \
- $(ACE_ROOT)/ace/streams.h \
- $(ACE_ROOT)/ace/Basic_Types.h \
- $(ACE_ROOT)/ace/Basic_Types.i \
- $(ACE_ROOT)/ace/OS.i \
- $(ACE_ROOT)/ace/Trace.h \
- $(ACE_ROOT)/ace/Log_Msg.h \
- $(ACE_ROOT)/ace/Log_Record.h \
- $(ACE_ROOT)/ace/ACE.h \
- $(ACE_ROOT)/ace/ACE.i \
- $(ACE_ROOT)/ace/Log_Priority.h \
- $(ACE_ROOT)/ace/Log_Record.i ../asnmp/octet.h \
- ../asnmp/smival.h ../asnmp/smi.h
-.obj/oid.o .obj/oid.so .shobj/oid.o .shobj/oid.so: oid.cpp ../asnmp/oid.h \
- $(ACE_ROOT)/ace/OS.h \
- $(ACE_ROOT)/ace/inc_user_config.h \
- $(ACE_ROOT)/ace/config.h \
- $(ACE_ROOT)/ace/config-sunos5.6.h \
- $(ACE_ROOT)/ace/config-sunos5.5.h \
- $(ACE_ROOT)/ace/config-g++-common.h \
- $(ACE_ROOT)/ace/streams.h \
- $(ACE_ROOT)/ace/Basic_Types.h \
- $(ACE_ROOT)/ace/Basic_Types.i \
- $(ACE_ROOT)/ace/OS.i \
- $(ACE_ROOT)/ace/Trace.h \
- $(ACE_ROOT)/ace/Log_Msg.h \
- $(ACE_ROOT)/ace/Log_Record.h \
- $(ACE_ROOT)/ace/ACE.h \
- $(ACE_ROOT)/ace/ACE.i \
- $(ACE_ROOT)/ace/Log_Priority.h \
- $(ACE_ROOT)/ace/Log_Record.i ../asnmp/smival.h \
- ../asnmp/smi.h
-.obj/pdu.o .obj/pdu.so .shobj/pdu.o .shobj/pdu.so: pdu.cpp ../asnmp/snmp.h \
- $(ACE_ROOT)/ace/Reactor.h \
- $(ACE_ROOT)/ace/Handle_Set.h \
- $(ACE_ROOT)/ace/ACE.h \
- $(ACE_ROOT)/ace/OS.h \
- $(ACE_ROOT)/ace/inc_user_config.h \
- $(ACE_ROOT)/ace/config.h \
- $(ACE_ROOT)/ace/config-sunos5.6.h \
- $(ACE_ROOT)/ace/config-sunos5.5.h \
- $(ACE_ROOT)/ace/config-g++-common.h \
- $(ACE_ROOT)/ace/streams.h \
- $(ACE_ROOT)/ace/Basic_Types.h \
- $(ACE_ROOT)/ace/Basic_Types.i \
- $(ACE_ROOT)/ace/OS.i \
- $(ACE_ROOT)/ace/Trace.h \
- $(ACE_ROOT)/ace/Log_Msg.h \
- $(ACE_ROOT)/ace/Log_Record.h \
- $(ACE_ROOT)/ace/ACE.i \
- $(ACE_ROOT)/ace/Log_Priority.h \
- $(ACE_ROOT)/ace/Log_Record.i \
- $(ACE_ROOT)/ace/Handle_Set.i \
- $(ACE_ROOT)/ace/Timer_Queue.h \
- $(ACE_ROOT)/ace/Synch.h \
- $(ACE_ROOT)/ace/SV_Semaphore_Complex.h \
- $(ACE_ROOT)/ace/SV_Semaphore_Simple.h \
- $(ACE_ROOT)/ace/SV_Semaphore_Simple.i \
- $(ACE_ROOT)/ace/SV_Semaphore_Complex.i \
- $(ACE_ROOT)/ace/Synch.i \
- $(ACE_ROOT)/ace/Synch_T.h \
- $(ACE_ROOT)/ace/Event_Handler.h \
- $(ACE_ROOT)/ace/Event_Handler.i \
- $(ACE_ROOT)/ace/Synch_T.i \
- $(ACE_ROOT)/ace/Thread.h \
- $(ACE_ROOT)/ace/Thread.i \
- $(ACE_ROOT)/ace/Atomic_Op.i \
- $(ACE_ROOT)/ace/Synch_T.cpp \
- $(ACE_ROOT)/ace/Timer_Queue_T.h \
- $(ACE_ROOT)/ace/Free_List.h \
- $(ACE_ROOT)/ace/Free_List.i \
- $(ACE_ROOT)/ace/Free_List.cpp \
- $(ACE_ROOT)/ace/Timer_Queue_T.i \
- $(ACE_ROOT)/ace/Timer_Queue_T.cpp \
- $(ACE_ROOT)/ace/Signal.h \
- $(ACE_ROOT)/ace/Containers.h \
- $(ACE_ROOT)/ace/Containers.i \
- $(ACE_ROOT)/ace/Containers_T.h \
- $(ACE_ROOT)/ace/Containers_T.i \
- $(ACE_ROOT)/ace/Containers_T.cpp \
- $(ACE_ROOT)/ace/Malloc.h \
- $(ACE_ROOT)/ace/Malloc_Base.h \
- $(ACE_ROOT)/ace/Malloc.i \
- $(ACE_ROOT)/ace/Malloc_T.h \
- $(ACE_ROOT)/ace/Malloc_T.i \
- $(ACE_ROOT)/ace/Malloc_T.cpp \
- $(ACE_ROOT)/ace/Memory_Pool.h \
- $(ACE_ROOT)/ace/Mem_Map.h \
- $(ACE_ROOT)/ace/Mem_Map.i \
- $(ACE_ROOT)/ace/Memory_Pool.i \
- $(ACE_ROOT)/ace/Signal.i \
- $(ACE_ROOT)/ace/Object_Manager.h \
- $(ACE_ROOT)/ace/Object_Manager.i \
- $(ACE_ROOT)/ace/Managed_Object.h \
- $(ACE_ROOT)/ace/Managed_Object.i \
- $(ACE_ROOT)/ace/Managed_Object.cpp \
- $(ACE_ROOT)/ace/Reactor.i \
- $(ACE_ROOT)/ace/Reactor_Impl.h \
- $(ACE_ROOT)/ace/SOCK_Dgram.h \
- $(ACE_ROOT)/ace/SOCK.h \
- $(ACE_ROOT)/ace/Addr.h \
- $(ACE_ROOT)/ace/Addr.i \
- $(ACE_ROOT)/ace/IPC_SAP.h \
- $(ACE_ROOT)/ace/IPC_SAP.i \
- $(ACE_ROOT)/ace/SOCK.i \
- $(ACE_ROOT)/ace/SOCK_Dgram.i ../asnmp/oid.h \
- ../asnmp/smival.h ../asnmp/smi.h ../asnmp/vb.h ../asnmp/snmperrs.h \
- ../asnmp/timetick.h ../asnmp/integer.h ../asnmp/counter.h \
- ../asnmp/gauge.h ../asnmp/ctr64.h ../asnmp/octet.h ../asnmp/address.h \
- ../asnmp/target.h $(ACE_ROOT)/ace/INET_Addr.h \
- $(ACE_ROOT)/ace/INET_Addr.i ../asnmp/pdu.h \
- ../asnmp/transaction_result.h
-.obj/snmp.o .obj/snmp.so .shobj/snmp.o .shobj/snmp.so: snmp.cpp ../asnmp/snmp.h \
- $(ACE_ROOT)/ace/Reactor.h \
- $(ACE_ROOT)/ace/Handle_Set.h \
- $(ACE_ROOT)/ace/ACE.h \
- $(ACE_ROOT)/ace/OS.h \
- $(ACE_ROOT)/ace/inc_user_config.h \
- $(ACE_ROOT)/ace/config.h \
- $(ACE_ROOT)/ace/config-sunos5.6.h \
- $(ACE_ROOT)/ace/config-sunos5.5.h \
- $(ACE_ROOT)/ace/config-g++-common.h \
- $(ACE_ROOT)/ace/streams.h \
- $(ACE_ROOT)/ace/Basic_Types.h \
- $(ACE_ROOT)/ace/Basic_Types.i \
- $(ACE_ROOT)/ace/OS.i \
- $(ACE_ROOT)/ace/Trace.h \
- $(ACE_ROOT)/ace/Log_Msg.h \
- $(ACE_ROOT)/ace/Log_Record.h \
- $(ACE_ROOT)/ace/ACE.i \
- $(ACE_ROOT)/ace/Log_Priority.h \
- $(ACE_ROOT)/ace/Log_Record.i \
- $(ACE_ROOT)/ace/Handle_Set.i \
- $(ACE_ROOT)/ace/Timer_Queue.h \
- $(ACE_ROOT)/ace/Synch.h \
- $(ACE_ROOT)/ace/SV_Semaphore_Complex.h \
- $(ACE_ROOT)/ace/SV_Semaphore_Simple.h \
- $(ACE_ROOT)/ace/SV_Semaphore_Simple.i \
- $(ACE_ROOT)/ace/SV_Semaphore_Complex.i \
- $(ACE_ROOT)/ace/Synch.i \
- $(ACE_ROOT)/ace/Synch_T.h \
- $(ACE_ROOT)/ace/Event_Handler.h \
- $(ACE_ROOT)/ace/Event_Handler.i \
- $(ACE_ROOT)/ace/Synch_T.i \
- $(ACE_ROOT)/ace/Thread.h \
- $(ACE_ROOT)/ace/Thread.i \
- $(ACE_ROOT)/ace/Atomic_Op.i \
- $(ACE_ROOT)/ace/Synch_T.cpp \
- $(ACE_ROOT)/ace/Timer_Queue_T.h \
- $(ACE_ROOT)/ace/Free_List.h \
- $(ACE_ROOT)/ace/Free_List.i \
- $(ACE_ROOT)/ace/Free_List.cpp \
- $(ACE_ROOT)/ace/Timer_Queue_T.i \
- $(ACE_ROOT)/ace/Timer_Queue_T.cpp \
- $(ACE_ROOT)/ace/Signal.h \
- $(ACE_ROOT)/ace/Containers.h \
- $(ACE_ROOT)/ace/Containers.i \
- $(ACE_ROOT)/ace/Containers_T.h \
- $(ACE_ROOT)/ace/Containers_T.i \
- $(ACE_ROOT)/ace/Containers_T.cpp \
- $(ACE_ROOT)/ace/Malloc.h \
- $(ACE_ROOT)/ace/Malloc_Base.h \
- $(ACE_ROOT)/ace/Malloc.i \
- $(ACE_ROOT)/ace/Malloc_T.h \
- $(ACE_ROOT)/ace/Malloc_T.i \
- $(ACE_ROOT)/ace/Malloc_T.cpp \
- $(ACE_ROOT)/ace/Memory_Pool.h \
- $(ACE_ROOT)/ace/Mem_Map.h \
- $(ACE_ROOT)/ace/Mem_Map.i \
- $(ACE_ROOT)/ace/Memory_Pool.i \
- $(ACE_ROOT)/ace/Signal.i \
- $(ACE_ROOT)/ace/Object_Manager.h \
- $(ACE_ROOT)/ace/Object_Manager.i \
- $(ACE_ROOT)/ace/Managed_Object.h \
- $(ACE_ROOT)/ace/Managed_Object.i \
- $(ACE_ROOT)/ace/Managed_Object.cpp \
- $(ACE_ROOT)/ace/Reactor.i \
- $(ACE_ROOT)/ace/Reactor_Impl.h \
- $(ACE_ROOT)/ace/SOCK_Dgram.h \
- $(ACE_ROOT)/ace/SOCK.h \
- $(ACE_ROOT)/ace/Addr.h \
- $(ACE_ROOT)/ace/Addr.i \
- $(ACE_ROOT)/ace/IPC_SAP.h \
- $(ACE_ROOT)/ace/IPC_SAP.i \
- $(ACE_ROOT)/ace/SOCK.i \
- $(ACE_ROOT)/ace/SOCK_Dgram.i ../asnmp/oid.h \
- ../asnmp/smival.h ../asnmp/smi.h ../asnmp/vb.h ../asnmp/snmperrs.h \
- ../asnmp/timetick.h ../asnmp/integer.h ../asnmp/counter.h \
- ../asnmp/gauge.h ../asnmp/ctr64.h ../asnmp/octet.h ../asnmp/address.h \
- ../asnmp/target.h $(ACE_ROOT)/ace/INET_Addr.h \
- $(ACE_ROOT)/ace/INET_Addr.i ../asnmp/pdu.h \
- ../asnmp/transaction_result.h ../asnmp/enttraps.h ../asnmp/asn1.h \
- ../asnmp/wpdu.h ../asnmp/transaction.h
-.obj/target.o .obj/target.so .shobj/target.o .shobj/target.so: target.cpp ../asnmp/target.h \
- $(ACE_ROOT)/ace/INET_Addr.h \
- $(ACE_ROOT)/ace/ACE.h \
- $(ACE_ROOT)/ace/OS.h \
- $(ACE_ROOT)/ace/inc_user_config.h \
- $(ACE_ROOT)/ace/config.h \
- $(ACE_ROOT)/ace/config-sunos5.6.h \
- $(ACE_ROOT)/ace/config-sunos5.5.h \
- $(ACE_ROOT)/ace/config-g++-common.h \
- $(ACE_ROOT)/ace/streams.h \
- $(ACE_ROOT)/ace/Basic_Types.h \
- $(ACE_ROOT)/ace/Basic_Types.i \
- $(ACE_ROOT)/ace/OS.i \
- $(ACE_ROOT)/ace/Trace.h \
- $(ACE_ROOT)/ace/Log_Msg.h \
- $(ACE_ROOT)/ace/Log_Record.h \
- $(ACE_ROOT)/ace/ACE.i \
- $(ACE_ROOT)/ace/Log_Priority.h \
- $(ACE_ROOT)/ace/Log_Record.i \
- $(ACE_ROOT)/ace/Addr.h \
- $(ACE_ROOT)/ace/Addr.i \
- $(ACE_ROOT)/ace/INET_Addr.i ../asnmp/address.h \
- ../asnmp/smival.h ../asnmp/smi.h ../asnmp/octet.h ../asnmp/oid.h
-.obj/timetick.o .obj/timetick.so .shobj/timetick.o .shobj/timetick.so: timetick.cpp ../asnmp/timetick.h ../asnmp/integer.h \
- ../asnmp/smival.h ../asnmp/smi.h \
- $(ACE_ROOT)/ace/OS.h \
- $(ACE_ROOT)/ace/inc_user_config.h \
- $(ACE_ROOT)/ace/config.h \
- $(ACE_ROOT)/ace/config-sunos5.6.h \
- $(ACE_ROOT)/ace/config-sunos5.5.h \
- $(ACE_ROOT)/ace/config-g++-common.h \
- $(ACE_ROOT)/ace/streams.h \
- $(ACE_ROOT)/ace/Basic_Types.h \
- $(ACE_ROOT)/ace/Basic_Types.i \
- $(ACE_ROOT)/ace/OS.i \
- $(ACE_ROOT)/ace/Trace.h \
- $(ACE_ROOT)/ace/Log_Msg.h \
- $(ACE_ROOT)/ace/Log_Record.h \
- $(ACE_ROOT)/ace/ACE.h \
- $(ACE_ROOT)/ace/ACE.i \
- $(ACE_ROOT)/ace/Log_Priority.h \
- $(ACE_ROOT)/ace/Log_Record.i
-.obj/transaction.o .obj/transaction.so .shobj/transaction.o .shobj/transaction.so: transaction.cpp \
- $(ACE_ROOT)/ace/Reactor.h \
- $(ACE_ROOT)/ace/Handle_Set.h \
- $(ACE_ROOT)/ace/ACE.h \
- $(ACE_ROOT)/ace/OS.h \
- $(ACE_ROOT)/ace/inc_user_config.h \
- $(ACE_ROOT)/ace/config.h \
- $(ACE_ROOT)/ace/config-sunos5.6.h \
- $(ACE_ROOT)/ace/config-sunos5.5.h \
- $(ACE_ROOT)/ace/config-g++-common.h \
- $(ACE_ROOT)/ace/streams.h \
- $(ACE_ROOT)/ace/Basic_Types.h \
- $(ACE_ROOT)/ace/Basic_Types.i \
- $(ACE_ROOT)/ace/OS.i \
- $(ACE_ROOT)/ace/Trace.h \
- $(ACE_ROOT)/ace/Log_Msg.h \
- $(ACE_ROOT)/ace/Log_Record.h \
- $(ACE_ROOT)/ace/ACE.i \
- $(ACE_ROOT)/ace/Log_Priority.h \
- $(ACE_ROOT)/ace/Log_Record.i \
- $(ACE_ROOT)/ace/Handle_Set.i \
- $(ACE_ROOT)/ace/Timer_Queue.h \
- $(ACE_ROOT)/ace/Synch.h \
- $(ACE_ROOT)/ace/SV_Semaphore_Complex.h \
- $(ACE_ROOT)/ace/SV_Semaphore_Simple.h \
- $(ACE_ROOT)/ace/SV_Semaphore_Simple.i \
- $(ACE_ROOT)/ace/SV_Semaphore_Complex.i \
- $(ACE_ROOT)/ace/Synch.i \
- $(ACE_ROOT)/ace/Synch_T.h \
- $(ACE_ROOT)/ace/Event_Handler.h \
- $(ACE_ROOT)/ace/Event_Handler.i \
- $(ACE_ROOT)/ace/Synch_T.i \
- $(ACE_ROOT)/ace/Thread.h \
- $(ACE_ROOT)/ace/Thread.i \
- $(ACE_ROOT)/ace/Atomic_Op.i \
- $(ACE_ROOT)/ace/Synch_T.cpp \
- $(ACE_ROOT)/ace/Timer_Queue_T.h \
- $(ACE_ROOT)/ace/Free_List.h \
- $(ACE_ROOT)/ace/Free_List.i \
- $(ACE_ROOT)/ace/Free_List.cpp \
- $(ACE_ROOT)/ace/Timer_Queue_T.i \
- $(ACE_ROOT)/ace/Timer_Queue_T.cpp \
- $(ACE_ROOT)/ace/Signal.h \
- $(ACE_ROOT)/ace/Containers.h \
- $(ACE_ROOT)/ace/Containers.i \
- $(ACE_ROOT)/ace/Containers_T.h \
- $(ACE_ROOT)/ace/Containers_T.i \
- $(ACE_ROOT)/ace/Containers_T.cpp \
- $(ACE_ROOT)/ace/Malloc.h \
- $(ACE_ROOT)/ace/Malloc_Base.h \
- $(ACE_ROOT)/ace/Malloc.i \
- $(ACE_ROOT)/ace/Malloc_T.h \
- $(ACE_ROOT)/ace/Malloc_T.i \
- $(ACE_ROOT)/ace/Malloc_T.cpp \
- $(ACE_ROOT)/ace/Memory_Pool.h \
- $(ACE_ROOT)/ace/Mem_Map.h \
- $(ACE_ROOT)/ace/Mem_Map.i \
- $(ACE_ROOT)/ace/Memory_Pool.i \
- $(ACE_ROOT)/ace/Signal.i \
- $(ACE_ROOT)/ace/Object_Manager.h \
- $(ACE_ROOT)/ace/Object_Manager.i \
- $(ACE_ROOT)/ace/Managed_Object.h \
- $(ACE_ROOT)/ace/Managed_Object.i \
- $(ACE_ROOT)/ace/Managed_Object.cpp \
- $(ACE_ROOT)/ace/Reactor.i \
- $(ACE_ROOT)/ace/Reactor_Impl.h \
- ../asnmp/transaction.h ../asnmp/target.h \
- $(ACE_ROOT)/ace/INET_Addr.h \
- $(ACE_ROOT)/ace/Addr.h \
- $(ACE_ROOT)/ace/Addr.i \
- $(ACE_ROOT)/ace/INET_Addr.i ../asnmp/address.h \
- ../asnmp/smival.h ../asnmp/smi.h ../asnmp/octet.h ../asnmp/oid.h \
- ../asnmp/pdu.h ../asnmp/vb.h ../asnmp/snmperrs.h ../asnmp/timetick.h \
- ../asnmp/integer.h ../asnmp/counter.h ../asnmp/gauge.h \
- ../asnmp/ctr64.h ../asnmp/transaction_result.h ../asnmp/wpdu.h \
- ../asnmp/asn1.h ../asnmp/snmp.h \
- $(ACE_ROOT)/ace/SOCK_Dgram.h \
- $(ACE_ROOT)/ace/SOCK.h \
- $(ACE_ROOT)/ace/IPC_SAP.h \
- $(ACE_ROOT)/ace/IPC_SAP.i \
- $(ACE_ROOT)/ace/SOCK.i \
- $(ACE_ROOT)/ace/SOCK_Dgram.i
-.obj/vb.o .obj/vb.so .shobj/vb.o .shobj/vb.so: vb.cpp ../asnmp/oid.h \
- $(ACE_ROOT)/ace/OS.h \
- $(ACE_ROOT)/ace/inc_user_config.h \
- $(ACE_ROOT)/ace/config.h \
- $(ACE_ROOT)/ace/config-sunos5.6.h \
- $(ACE_ROOT)/ace/config-sunos5.5.h \
- $(ACE_ROOT)/ace/config-g++-common.h \
- $(ACE_ROOT)/ace/streams.h \
- $(ACE_ROOT)/ace/Basic_Types.h \
- $(ACE_ROOT)/ace/Basic_Types.i \
- $(ACE_ROOT)/ace/OS.i \
- $(ACE_ROOT)/ace/Trace.h \
- $(ACE_ROOT)/ace/Log_Msg.h \
- $(ACE_ROOT)/ace/Log_Record.h \
- $(ACE_ROOT)/ace/ACE.h \
- $(ACE_ROOT)/ace/ACE.i \
- $(ACE_ROOT)/ace/Log_Priority.h \
- $(ACE_ROOT)/ace/Log_Record.i ../asnmp/smival.h \
- ../asnmp/smi.h ../asnmp/vb.h ../asnmp/snmperrs.h ../asnmp/timetick.h \
- ../asnmp/integer.h ../asnmp/counter.h ../asnmp/gauge.h \
- ../asnmp/ctr64.h ../asnmp/octet.h ../asnmp/address.h
-.obj/wpdu.o .obj/wpdu.so .shobj/wpdu.o .shobj/wpdu.so: wpdu.cpp ../asnmp/wpdu.h \
- $(ACE_ROOT)/ace/OS.h \
- $(ACE_ROOT)/ace/inc_user_config.h \
- $(ACE_ROOT)/ace/config.h \
- $(ACE_ROOT)/ace/config-sunos5.6.h \
- $(ACE_ROOT)/ace/config-sunos5.5.h \
- $(ACE_ROOT)/ace/config-g++-common.h \
- $(ACE_ROOT)/ace/streams.h \
- $(ACE_ROOT)/ace/Basic_Types.h \
- $(ACE_ROOT)/ace/Basic_Types.i \
- $(ACE_ROOT)/ace/OS.i \
- $(ACE_ROOT)/ace/Trace.h \
- $(ACE_ROOT)/ace/Log_Msg.h \
- $(ACE_ROOT)/ace/Log_Record.h \
- $(ACE_ROOT)/ace/ACE.h \
- $(ACE_ROOT)/ace/ACE.i \
- $(ACE_ROOT)/ace/Log_Priority.h \
- $(ACE_ROOT)/ace/Log_Record.i ../asnmp/asn1.h \
- ../asnmp/snmp.h $(ACE_ROOT)/ace/Reactor.h \
- $(ACE_ROOT)/ace/Handle_Set.h \
- $(ACE_ROOT)/ace/Handle_Set.i \
- $(ACE_ROOT)/ace/Timer_Queue.h \
- $(ACE_ROOT)/ace/Synch.h \
- $(ACE_ROOT)/ace/SV_Semaphore_Complex.h \
- $(ACE_ROOT)/ace/SV_Semaphore_Simple.h \
- $(ACE_ROOT)/ace/SV_Semaphore_Simple.i \
- $(ACE_ROOT)/ace/SV_Semaphore_Complex.i \
- $(ACE_ROOT)/ace/Synch.i \
- $(ACE_ROOT)/ace/Synch_T.h \
- $(ACE_ROOT)/ace/Event_Handler.h \
- $(ACE_ROOT)/ace/Event_Handler.i \
- $(ACE_ROOT)/ace/Synch_T.i \
- $(ACE_ROOT)/ace/Thread.h \
- $(ACE_ROOT)/ace/Thread.i \
- $(ACE_ROOT)/ace/Atomic_Op.i \
- $(ACE_ROOT)/ace/Synch_T.cpp \
- $(ACE_ROOT)/ace/Timer_Queue_T.h \
- $(ACE_ROOT)/ace/Free_List.h \
- $(ACE_ROOT)/ace/Free_List.i \
- $(ACE_ROOT)/ace/Free_List.cpp \
- $(ACE_ROOT)/ace/Timer_Queue_T.i \
- $(ACE_ROOT)/ace/Timer_Queue_T.cpp \
- $(ACE_ROOT)/ace/Signal.h \
- $(ACE_ROOT)/ace/Containers.h \
- $(ACE_ROOT)/ace/Containers.i \
- $(ACE_ROOT)/ace/Containers_T.h \
- $(ACE_ROOT)/ace/Containers_T.i \
- $(ACE_ROOT)/ace/Containers_T.cpp \
- $(ACE_ROOT)/ace/Malloc.h \
- $(ACE_ROOT)/ace/Malloc_Base.h \
- $(ACE_ROOT)/ace/Malloc.i \
- $(ACE_ROOT)/ace/Malloc_T.h \
- $(ACE_ROOT)/ace/Malloc_T.i \
- $(ACE_ROOT)/ace/Malloc_T.cpp \
- $(ACE_ROOT)/ace/Memory_Pool.h \
- $(ACE_ROOT)/ace/Mem_Map.h \
- $(ACE_ROOT)/ace/Mem_Map.i \
- $(ACE_ROOT)/ace/Memory_Pool.i \
- $(ACE_ROOT)/ace/Signal.i \
- $(ACE_ROOT)/ace/Object_Manager.h \
- $(ACE_ROOT)/ace/Object_Manager.i \
- $(ACE_ROOT)/ace/Managed_Object.h \
- $(ACE_ROOT)/ace/Managed_Object.i \
- $(ACE_ROOT)/ace/Managed_Object.cpp \
- $(ACE_ROOT)/ace/Reactor.i \
- $(ACE_ROOT)/ace/Reactor_Impl.h \
- $(ACE_ROOT)/ace/SOCK_Dgram.h \
- $(ACE_ROOT)/ace/SOCK.h \
- $(ACE_ROOT)/ace/Addr.h \
- $(ACE_ROOT)/ace/Addr.i \
- $(ACE_ROOT)/ace/IPC_SAP.h \
- $(ACE_ROOT)/ace/IPC_SAP.i \
- $(ACE_ROOT)/ace/SOCK.i \
- $(ACE_ROOT)/ace/SOCK_Dgram.i ../asnmp/oid.h \
- ../asnmp/smival.h ../asnmp/smi.h ../asnmp/vb.h ../asnmp/snmperrs.h \
- ../asnmp/timetick.h ../asnmp/integer.h ../asnmp/counter.h \
- ../asnmp/gauge.h ../asnmp/ctr64.h ../asnmp/octet.h ../asnmp/address.h \
- ../asnmp/target.h $(ACE_ROOT)/ace/INET_Addr.h \
- $(ACE_ROOT)/ace/INET_Addr.i ../asnmp/pdu.h \
- ../asnmp/transaction_result.h ../asnmp/enttraps.h
-.obj/sagent.o .obj/sagent.so .shobj/sagent.o .shobj/sagent.so: sagent.cpp $(ACE_ROOT)/ace/Reactor.h \
- $(ACE_ROOT)/ace/Handle_Set.h \
- $(ACE_ROOT)/ace/ACE.h \
- $(ACE_ROOT)/ace/OS.h \
- $(ACE_ROOT)/ace/inc_user_config.h \
- $(ACE_ROOT)/ace/config.h \
- $(ACE_ROOT)/ace/config-sunos5.6.h \
- $(ACE_ROOT)/ace/config-sunos5.5.h \
- $(ACE_ROOT)/ace/config-g++-common.h \
- $(ACE_ROOT)/ace/streams.h \
- $(ACE_ROOT)/ace/Basic_Types.h \
- $(ACE_ROOT)/ace/Basic_Types.i \
- $(ACE_ROOT)/ace/OS.i \
- $(ACE_ROOT)/ace/Trace.h \
- $(ACE_ROOT)/ace/Log_Msg.h \
- $(ACE_ROOT)/ace/Log_Record.h \
- $(ACE_ROOT)/ace/ACE.i \
- $(ACE_ROOT)/ace/Log_Priority.h \
- $(ACE_ROOT)/ace/Log_Record.i \
- $(ACE_ROOT)/ace/Handle_Set.i \
- $(ACE_ROOT)/ace/Timer_Queue.h \
- $(ACE_ROOT)/ace/Synch.h \
- $(ACE_ROOT)/ace/SV_Semaphore_Complex.h \
- $(ACE_ROOT)/ace/SV_Semaphore_Simple.h \
- $(ACE_ROOT)/ace/SV_Semaphore_Simple.i \
- $(ACE_ROOT)/ace/SV_Semaphore_Complex.i \
- $(ACE_ROOT)/ace/Synch.i \
- $(ACE_ROOT)/ace/Synch_T.h \
- $(ACE_ROOT)/ace/Event_Handler.h \
- $(ACE_ROOT)/ace/Event_Handler.i \
- $(ACE_ROOT)/ace/Synch_T.i \
- $(ACE_ROOT)/ace/Thread.h \
- $(ACE_ROOT)/ace/Thread.i \
- $(ACE_ROOT)/ace/Atomic_Op.i \
- $(ACE_ROOT)/ace/Synch_T.cpp \
- $(ACE_ROOT)/ace/Timer_Queue_T.h \
- $(ACE_ROOT)/ace/Free_List.h \
- $(ACE_ROOT)/ace/Free_List.i \
- $(ACE_ROOT)/ace/Free_List.cpp \
- $(ACE_ROOT)/ace/Timer_Queue_T.i \
- $(ACE_ROOT)/ace/Timer_Queue_T.cpp \
- $(ACE_ROOT)/ace/Signal.h \
- $(ACE_ROOT)/ace/Containers.h \
- $(ACE_ROOT)/ace/Containers.i \
- $(ACE_ROOT)/ace/Containers_T.h \
- $(ACE_ROOT)/ace/Containers_T.i \
- $(ACE_ROOT)/ace/Containers_T.cpp \
- $(ACE_ROOT)/ace/Malloc.h \
- $(ACE_ROOT)/ace/Malloc_Base.h \
- $(ACE_ROOT)/ace/Malloc.i \
- $(ACE_ROOT)/ace/Malloc_T.h \
- $(ACE_ROOT)/ace/Malloc_T.i \
- $(ACE_ROOT)/ace/Malloc_T.cpp \
- $(ACE_ROOT)/ace/Memory_Pool.h \
- $(ACE_ROOT)/ace/Mem_Map.h \
- $(ACE_ROOT)/ace/Mem_Map.i \
- $(ACE_ROOT)/ace/Memory_Pool.i \
- $(ACE_ROOT)/ace/Signal.i \
- $(ACE_ROOT)/ace/Object_Manager.h \
- $(ACE_ROOT)/ace/Object_Manager.i \
- $(ACE_ROOT)/ace/Managed_Object.h \
- $(ACE_ROOT)/ace/Managed_Object.i \
- $(ACE_ROOT)/ace/Managed_Object.cpp \
- $(ACE_ROOT)/ace/Reactor.i \
- $(ACE_ROOT)/ace/Reactor_Impl.h \
- $(ACE_ROOT)/ace/SOCK_Dgram.h \
- $(ACE_ROOT)/ace/SOCK.h \
- $(ACE_ROOT)/ace/Addr.h \
- $(ACE_ROOT)/ace/Addr.i \
- $(ACE_ROOT)/ace/IPC_SAP.h \
- $(ACE_ROOT)/ace/IPC_SAP.i \
- $(ACE_ROOT)/ace/SOCK.i \
- $(ACE_ROOT)/ace/SOCK_Dgram.i ../asnmp/oid.h \
- ../asnmp/smival.h ../asnmp/smi.h ../asnmp/vb.h ../asnmp/snmperrs.h \
- ../asnmp/timetick.h ../asnmp/integer.h ../asnmp/counter.h \
- ../asnmp/gauge.h ../asnmp/ctr64.h ../asnmp/octet.h ../asnmp/address.h \
- ../asnmp/target.h $(ACE_ROOT)/ace/INET_Addr.h \
- $(ACE_ROOT)/ace/INET_Addr.i ../asnmp/pdu.h \
- ../asnmp/snmp.h ../asnmp/transaction_result.h ../asnmp/sagent.h \
- ../asnmp/transaction.h ../asnmp/wpdu.h ../asnmp/asn1.h
-
-# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
diff --git a/ASNMP/asnmp/TODO b/ASNMP/asnmp/TODO
deleted file mode 100644
index 12beb91406b..00000000000
--- a/ASNMP/asnmp/TODO
+++ /dev/null
@@ -1,25 +0,0 @@
-This is the todo list aka wish list: feel free to add/implmement
-Fri Aug 1 19:40:55 PDT 1997
-
-0) collapse CMU and HP code - make this thing faster since it is really
- slow and bulky...
-
-1) implement response time statistics collection so that timeout can vary based
- on empirical response times
-
-2) Implement pdu fragmentation based on tooBig errors or app directed
- Snmp::set_pdu_max_size() command
-
-3) implement async interface
-
-4) make templatized version to implement sync/nonsync (thread safe version)
-
-5) add V2c when a real agent is in the field that supports it
-
-6) Add DISMAN support when IETF approves the Expression Mib
-
-7) way too many procedural case stmts in the code...
-
-8) add compare_right() method to be orthogonal to oid class.
-
-
diff --git a/ASNMP/asnmp/address.cpp b/ASNMP/asnmp/address.cpp
deleted file mode 100644
index 230788e9f67..00000000000
--- a/ASNMP/asnmp/address.cpp
+++ /dev/null
@@ -1,2686 +0,0 @@
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// address.cpp
-//
-// = DESCRIPTION
-// The Vb class is an encapsulation of the snmp variable binding.
-// This module contains the class definition for the variable binding (VB)
-// class. The VB class is an encapsulation of a SNMP VB. A VB object is
-// composed of one SNMP++ Oid and one SMI value. The Vb class utilizes Oid
-// objects and thus requires the Oid class. To use this class,
-// set oid, value then call valid() to be sure object was constructed correctly.
-//
-// = AUTHOR
-// Peter E Mellquist
-// Michael R MacFaden mrm@cisco.com - rework & ACE port
-// ============================================================================
-/*===================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
- =====================================================================*/
-
-#include "asnmp/address.h"
-
-ACE_RCSID(asnmp, address, "$Id$")
-
-//=================================================================
-//======== Abstract Address Class Implementation ==================
-//=================================================================
-
-// allow destruction of derived classes
-Address::~Address()
-{
-}
-
-
-//-----------------------------------------------------------------
-// is the address object valid?
-int Address::valid() const
-{
- return valid_flag;
-}
-
-//------------[ Address::trim_white_space( char * ptr) ]------------
-// destructive trim white space
-void Address::trim_white_space( char * ptr)
-{
- char *tmp;
-
- tmp = ptr;
- // skip leading white space
- while (*tmp==' ')tmp++;
- ACE_OS::strcpy(ptr,tmp);
-
- // find end of string
- while ((*tmp!=' ') && (*tmp !=0)) tmp++;
- if (*tmp!=0) *tmp=0;
-}
-
-//TM: this is not used nor needed, remove?
-//-----[ element access ]----------------------------------------------
-unsigned char& Address::operator[]( const int position)
-{
- if ( position < MAX_ADDR_SZ)
- return address_buffer[ position];
- else
- return address_buffer[0];
-}
-
-
-//-----------------------------------------------------------------------
-// overloaded equivlence operator, are two addresses equal?
-int operator==( const Address &lhs, const Address &rhs)
-{
- if ( strcmp( (const char*) lhs, (const char*)rhs)==0)
- return 1;
- else
- return 0;
-}
-
-//-----------------------------------------------------------------------
-// overloaded equivlence operator, are two addresses equal?
-int operator!=( const Address &lhs, const Address &rhs)
-{
- return (!( lhs == rhs));
-}
-
-
-//------------------------------------------------------------------
-// overloaded > operator, is a1 > a2
-int operator>( const Address &lhs, const Address &rhs)
-{
- if ( strcmp( (const char*) lhs, (const char*)rhs)>0)
- return 1;
- else
- return 0;
-}
-
-// overloaded >= operator, is a1 > a2
-int operator>=( const Address &lhs,const Address &rhs)
-{
- if (( lhs > rhs) || ( lhs == rhs))
- return 1;
- else
- return 0;
-}
-
-// overloaded < operator, is a1 <= a2
-int operator<=( const Address &lhs,const Address &rhs)
-{
- if (( lhs < rhs) || ( lhs == rhs))
- return 1;
- else
- return 0;
-
-}
-
-
-//-----------------------------------------------------------------
-// overloaded < operator, is a1 < a2
-int operator<( const Address &lhs, const Address &rhs)
-{
- if ( strcmp( (const char*) lhs, (const char*)rhs)<0)
- return 1;
- else
- return 0;
-}
-
-//------------------------------------------------------------------
-// equivlence operator overloaded, are an address and a string equal?
-int operator==( const Address &lhs,const char *rhs)
-{
- if (!rhs && !lhs.valid())
- return 1;
- if (strcmp( (const char *) lhs, rhs)== 0)
- return 1;
- else
- return 0;
-}
-
-//------------------------------------------------------------------
-// not equal operator overloaded, are an address and a string not equal?
-int operator!=( const Address &lhs,const char *rhs)
-{
- return (!( lhs == rhs));
-}
-
-//------------------------------------------------------------------
-// overloaded > , is a > inaddr
-int operator>( const Address &lhs,const char *rhs)
-{
- if (!rhs)
- return lhs.valid(); // if lhs valid then > 0, else invalid !> 0
- if (strcmp( (const char *) lhs, rhs)> 0)
- return 1;
- else
- return 0;
-}
-
-//------------------------------------------------------------------
-// overloaded >= , is a >= inaddr
-int operator>=( const Address &lhs,const char *rhs)
-{
- if (!rhs)
- return 1; // always >= 0
- if (strcmp( (const char *) lhs, rhs)>= 0)
- return 1;
- else
- return 0;
-}
-
-//-----------------------------------------------------------------
-// overloaded < , are an address and a string equal?
-int operator<( const Address &lhs,const char *rhs)
-{
- if (!rhs)
- return 0; // always >= 0
- if (strcmp( (const char *) lhs, rhs)< 0)
- return 1;
- else
- return 0;
-}
-
-//-----------------------------------------------------------------
-// overloaded <= , is a <= inaddr
-int operator<=( const Address &lhs,const char *rhs)
-{
- if (!rhs)
- return !lhs.valid(); // invalid == 0, else valid > 0
- if (strcmp( (const char *) lhs, rhs)<= 0)
- return 1;
- else
- return 0;
-}
-
-
-//=====================================================================
-//============ IPAddress Implementation ===============================
-//=====================================================================
-
-//-----------[ syntax type ]----------------------------------------------
-SmiUINT32 IpAddress::get_syntax()
-{
- return sNMP_SYNTAX_IPADDR;
-}
-
-//-----[ IP Address copy constructor ]---------------------------------
-IpAddress::IpAddress(const IpAddress &ipaddr)
-{
- // always initialize what type this object is
- smival.syntax = sNMP_SYNTAX_IPADDR;
- smival.value.string.len =IPV4LEN;
- smival.value.string.ptr = address_buffer;
-
- iv_friendly_name_[0] = 0;
- iv_friendly_name_status_ = 0;
- valid_flag = ipaddr.valid_flag;
- if (valid_flag) {
- ACE_OS::memcpy(address_buffer, ipaddr.address_buffer,IPV4LEN);
- ACE_OS::strcpy( iv_friendly_name_, ipaddr.iv_friendly_name_);
- }
-
- IpAddress::format_output();
-}
-
-
-//-------[ default construct, an IP address with a string ]---------------------
-IpAddress::IpAddress( const char *inaddr): Address()
-{
- // always initialize what type this object is
- smival.syntax = sNMP_SYNTAX_IPADDR;
- smival.value.string.len = IPV4LEN;
- smival.value.string.ptr = address_buffer;
-
- if (ACE_OS::strlen(inaddr) == 0) {
-
- valid_flag = 0;
- iv_friendly_name_[0] = 0;
- iv_friendly_name_status_ = 0;
- IpAddress::format_output();
- return;
- }
-
- // parse_address initializes valid, address_buffer & iv_friendly_name_
- valid_flag = parse_address(inaddr);
- IpAddress::format_output();
-}
-
-
-//-----[ construct an IP address with a GenAddress ]---------------------
-IpAddress::IpAddress( const GenAddress &genaddr)
-{
- // always initialize what type this object is
- smival.syntax = sNMP_SYNTAX_IPADDR;
- smival.value.string.len = IPV4LEN;
- smival.value.string.ptr = address_buffer;
-
- valid_flag = 0;
- iv_friendly_name_[0] = 0;
- iv_friendly_name_status_ = 0;
- // allow use of an ip or udp genaddress
- if (genaddr.get_type() == type_ip) {
- valid_flag = genaddr.valid();
- if ( valid_flag) {
- // copy in the IP address data
- IpAddress temp_ip( (const char *) genaddr);
- *this = temp_ip;
- }
- }
- else
- if (genaddr.get_type() == type_udp) {
- valid_flag = genaddr.valid();
- if ( valid_flag) {
- // copy in the IP address data
- UdpAddress temp_udp( (const char *) genaddr);
- *this = temp_udp;
- }
- }
- IpAddress::format_output();
-}
-
-//-----[ destructor ]--------------------------------------------------
-IpAddress::~IpAddress()
-{
-}
-
-// assumes member data is word aligned to avoid sigbus
-int IpAddress::is_loopback() const
-{
- if (valid()) {
- return (*(u_long *)&address_buffer == INADDR_LOOPBACK);
- }
- return 0;
-}
-
-int IpAddress::is_multicast() const
-{
- if (valid()) {
- return (IN_MULTICAST(*(u_long *)&address_buffer));
- }
- return 0;
-}
-
-// Private addressess not are not assignable in the Internet, they are
-// defined in RFC 1597 as: 10, 172.16, and 192.168.0
-// Some companies use them internally and apply NAT to allow translation
-// instead of paying for ip networks.
-// Cisco IOS devices can provide NAT aka Network Address Translation
-// but don't expect SNMP based networks to handle cross-NAT address spaces.
-// assumes storage in network byte order mrm@cisco.com 7/28/97
-
-int IpAddress::is_private() const
-{
- if (valid()) {
- if (address_buffer[0] == 10)
- return 1;
- if (address_buffer[0] == 172 && address_buffer[1] == 16)
- return 1;
- if (address_buffer[0] == 192 && address_buffer[1] == 168 &&
- address_buffer[2] == 0)
- return 1;
- }
- return 0;
-}
-
-
-// convert address into octet string format in network byte order
-void IpAddress::to_octet(OctetStr& octet) const
-{
- octet.set_data( smival.value.string.ptr, smival.value.string.len);
-}
-
-
-int IpAddress::is_broadcast() const
-{
- if (valid()) {
- return ( (*(u_long *)&address_buffer) & INADDR_BROADCAST);
- }
- return 0;
-}
-
-//-----[ IP Address general = operator ]-------------------------------
-SnmpSyntax& IpAddress::operator=( SnmpSyntax &val)
-{
- // protect against assignment from itself
- if ( this == &val )
- return *this;
-
- valid_flag = 0; // will get set 1 if really valid
- iv_friendly_name_[0]=0;
-
- if (val.valid()) {
- switch (val.get_syntax()) {
- case sNMP_SYNTAX_IPADDR:
- case sNMP_SYNTAX_OCTETS:
- if (((IpAddress &)val).smival.value.string.len ==IPV4LEN) {
- ACE_OS::memcpy(address_buffer,
- ((IpAddress &)val).smival.value.string.ptr,IPV4LEN);
- valid_flag = 1;
- }
- break;
-
- // NOTE: as a value add, other types could have "logical"
- // mappings, i.e. integer32 and unsigned32
- }
- }
- IpAddress::format_output();
- return *this;
-}
-
-//------[ assignment to another ipaddress object overloaded ]-----------------
-IpAddress& IpAddress::operator=( const IpAddress &ipaddress)
-{
- // protect against assignment from itself
- if ( this == &ipaddress )
- return *this;
-
- valid_flag = ipaddress.valid_flag;
- iv_friendly_name_[0]=0;
-
- if (valid_flag) {
- ACE_OS::memcpy(address_buffer, ipaddress.address_buffer, IPV4LEN);
- ACE_OS::strcpy(iv_friendly_name_, ipaddress.iv_friendly_name_);
- }
- IpAddress::format_output();
- return *this;
-}
-
-
-//--------[ create a new instance of this Value ]-----------------------
-SnmpSyntax *IpAddress::clone() const
-{
- return (SnmpSyntax *) new IpAddress(*this);
-}
-
-//-------[ return the Fully Qualified Domain Name ]----------------------
-char *IpAddress::resolve_hostname(int &status)
-{
- if ((iv_friendly_name_[0] == 0) && valid_flag)
- addr_to_friendly();
- status = iv_friendly_name_status_;
- return iv_friendly_name_;
-}
-
-// parse a dotted string
-int IpAddress::parse_dotted_ipstring( const char *inaddr)
-{
- char *ip_token;
- int token_count=0;
- unsigned int value;
- int error_status = 0;
- char temp[MAXHOSTNAMELEN +1]; // temp buffer for destruction
- int z,w;
-
- // check len, an ip can never be bigger than 15
- // 123456789012345
- // XXX.XXX.XXX.XXX
- if ( !inaddr || (ACE_OS::strlen( inaddr) > 30))
- return 0;
- ACE_OS::strcpy( temp, inaddr);
- trim_white_space( temp);
- if ( ACE_OS::strlen( temp) > 15)
- return 0;
-
- // must only have three dots
- // strtok will not catch this !
- char *ptr = temp;
- int dot_count = 0;
- while ( *ptr != 0) {
- if ( *ptr == '.') dot_count++;
- ptr++;
- }
- if ( dot_count != 3)
- return 0;
-
- // look for dot token separator
- ip_token = strtok( (char *) temp,".");
-
- // while more tokens..
- while ( ip_token != 0) {
- // verify that the token is all numerics
- w = ACE_OS::strlen( ip_token);
- if (w>3)
- return 0;
- for (z=0;z<w;z++)
- if (( ip_token[z] < '0') || ( ip_token[z] > '9'))
- return 0;
-
- value = ( unsigned int) strtod(ip_token,0);
- if (( value > 0)&& ( value <=255))
- address_buffer[token_count] = (unsigned char) value;
- else
- if ( strcmp(ip_token,"0")==0)
- address_buffer[token_count]= (unsigned char) 0;
- else
- error_status = 1;
- token_count++;
- ip_token = strtok( 0, ".");
- }
-
- // gota be four in len
- if ( token_count != 4)
- return 0;
-
- // any parsing errors?
- if ( error_status)
- return 0;
-
- return 1;
-}
-
-//-----[ IP Address parse Address ]---------------------------------
-int IpAddress::parse_address( const char *inaddr)
-{
- // parse the input char array
- // fill up internal buffer with four ip bytes
- // set and return validity flag
-
- in_addr ipAddr;
- char ds[MAXHOSTNAMELEN +1];
-
- // intialize the friendly_name member variable
- iv_friendly_name_[0] = 0;
- iv_friendly_name_status_ = 0;
-
- // is this a dotted IP notation string or
- // a friendly name
- if ( parse_dotted_ipstring( inaddr)) {
-
- // since this is a valid dotted string
- // don't do any DNS (Performance!)
- return 1;
- }
- else {
- int rc;
- if ((rc = resolve_to_address(inaddr, ipAddr)) == 0) {
-
- // now lets check out the dotted string
- ACE_OS::strncpy( ds, ACE_OS::inet_ntoa(ipAddr), MAXHOSTNAMELEN);
-
- if ( !parse_dotted_ipstring( ds))
- return 0;
-
- // save the friendly name
- ACE_OS::strcpy( iv_friendly_name_, inaddr);
- return 1;
-
- } // end if lookup result
- else {
- iv_friendly_name_status_ = rc;
- return 0;
- }
- } // end else not a dotted string
- return 1;
-}
-
-// using the currently defined address, do a DNS
-// and try to fill up the name
-int IpAddress::addr_to_friendly()
-{
- in_addr ipAddr;
- long result = ACE_OS::inet_addr(to_string());
- if (result == -1)
- return -1; // expected a dotted quad!
-
- ipAddr.s_addr = result;
-
- // set iv_friendly_name_ from ipAddr
- if (resolve_to_hostname(ipAddr, iv_friendly_name_) == 0) {
- return 0;
- }
- else {
- iv_friendly_name_status_ = h_errno;
- return iv_friendly_name_status_;
- }
-}
-
-// static aka class member function (1.2.3.4 -> foo.com)
-int IpAddress::resolve_to_hostname(const in_addr& quad_addr, char *hostname)
-{
- struct hostent lookupResult;
- int loc_errno = 0;
- ACE_HOSTENT_DATA buffer;
- ACE_OS::memset(&lookupResult, 0, sizeof(struct hostent));
- ACE_OS::memset(&buffer, 0, sizeof(ACE_HOSTENT_DATA));
-
- // reverse lookup (requires in-addr.arpa to be setup in DNS
- if (ACE_OS::gethostbyaddr_r((const char *)&quad_addr.s_addr, IPV4LEN,
- AF_INET, &lookupResult, buffer, &loc_errno)) {
-
- // verify right type of record
- if (lookupResult.h_addrtype == AF_INET &&
- lookupResult.h_length == IPV4LEN) {
- ACE_OS::strcpy( hostname, lookupResult.h_name);
- // setup multiple entries
- return 0;
- }
- else {
- ACE_ASSERT(0); // todo add trace and debug and dump
- return -1; // wrong resource record type
- }
- }
-
- return loc_errno;
-}
-
-// static aka class member function (foo.com -> 1.2.3.4)
-int IpAddress::resolve_to_address(const char *hostname, in_addr& quad_addr)
-{
- struct hostent lookupResult;
- ACE_HOSTENT_DATA buffer;
- ACE_OS::memset(&buffer, 0, sizeof(ACE_HOSTENT_DATA));
- ACE_OS::memset(&lookupResult, 0, sizeof(struct hostent));
- int loc_errno = 0;
- if (ACE_OS::gethostbyname_r( hostname, &lookupResult, buffer, &loc_errno)) {
- if (lookupResult.h_length == sizeof(in_addr) &&
- lookupResult.h_addrtype == AF_INET) {
- ACE_OS::memcpy((void *) &quad_addr,
- (void *) lookupResult.h_addr_list[0], sizeof(in_addr));
- return 0;
- }
- else
- return -1; // wrong address size
- }
- return loc_errno;
-}
-
-//----[ IP address char * cast ]--------------------------------------
-IpAddress::operator const char *() const
-{
- return (char *)output_buffer;
-}
-
-//----[ IP address get char representation ]--------------------------
-char * IpAddress::to_string()
-{
- return (char *)output_buffer;
-}
-
-//----[ IP address format output ]------------------------------------
-void IpAddress::format_output()
-{
- // if valid format else null it
- if ( valid_flag)
- ACE_OS::sprintf( (char *) output_buffer,"%d.%d.%d.%d",address_buffer[0],
- address_buffer[1], address_buffer[2], address_buffer[3]);
- else
- output_buffer[0] = 0;
-}
-
-//------[ return the type ]----------------------------------
-addr_type IpAddress::get_type() const
-{
- return type_ip;
-}
-
-//-----------------------------------------------------------------
-// logically and two IPaddresses and
-// return the new one
-void IpAddress::mask( const IpAddress& ipaddr)
-{
- if ( this->valid() && ipaddr.valid()) {
- this->address_buffer[0] = this->address_buffer[0] & ipaddr.address_buffer[0];
- this->address_buffer[1] = this->address_buffer[1] & ipaddr.address_buffer[1];
- this->address_buffer[2] = this->address_buffer[2] & ipaddr.address_buffer[2];
- this->address_buffer[3] = this->address_buffer[3] & ipaddr.address_buffer[3];
- format_output();
- }
-
-}
-
-//=======================================================================
-//========== DNS Iterator Implementation ================================
-//=======================================================================
-
-
-Address_Iter::Address_Iter(const char *hostname): valid_(0), count_(0),
- entry_(0)
-{
- ACE_OS::memset(&buffer_, 0, sizeof(ACE_HOSTENT_DATA));
- ACE_OS::memset(&lookupResult_, 0, sizeof(struct hostent));
- if (ACE_OS::inet_addr(hostname) == -1)
- valid_ = query_dns(hostname);
- else {
- ACE_ASSERT(0); // don't support dot-quad lookup yet
- }
-
- // count number of hostnames
- int n;
- char **pc;
- for (n = 0, pc = lookupResult_.h_addr_list; *pc != 0; ++n, ++pc);
- count_ = n; // plus first one
- entry_ = lookupResult_.h_addr_list;
-}
-
-int Address_Iter::valid() const
-{
- return (valid_ == 1);
-}
-
-int Address_Iter::how_many_addresses()
-{
- return count_;
-}
-
-// return next entry, rc = 0, if entry is null return 0
-int Address_Iter::next(IpAddress& addr)
-{
- if (!entry_ || *entry_ == 0)
- return 1;
-
- IpAddress tmp(*entry_++); // return data
- addr = tmp;
- if (*entry_ == 0)
- return 1;
- return 0;
-}
-
-// query DNS here
-int Address_Iter::query_dns(const char *hostname)
-{
- int loc_errno = 0;
- if (ACE_OS::gethostbyname_r( hostname, &lookupResult_, buffer_,
- &loc_errno)) {
- if (lookupResult_.h_length == sizeof(IPV4LEN) &&
- lookupResult_.h_addrtype == AF_INET) {
- return 0;
- }
- else
- return -1; // wrong address size
- }
- return loc_errno;
-}
-
-//=======================================================================
-//========== Udp Address Implementation =================================
-//=======================================================================
-
-//-----------[ syntax type ]----------------------------------------------
-SmiUINT32 UdpAddress::get_syntax()
-{
- return sNMP_SYNTAX_OCTETS;
-}
-
-//-----------------[ construct an Udp address with another Udp address ]---
-UdpAddress::UdpAddress( const UdpAddress &udpaddr):IpAddress(udpaddr)
-{
- // always initialize SMI info
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = UDPIPV4LEN;
- smival.value.string.ptr = address_buffer;
-
- // Copy the port value
- set_port(udpaddr.get_port());
- format_output();
-}
-
-// default constructor with a dotted string
-UdpAddress::UdpAddress( const char *inaddr):IpAddress()
-{
- if (ACE_OS::strlen(inaddr) == 0) {
- // Inherits IP Address attributes
- // Always initialize (override) what type this object is
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = UDPIPV4LEN;
- smival.value.string.ptr = address_buffer;
- set_port(0);
- format_output();
- return;
- }
-
- // always initialize SMI info
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = UDPIPV4LEN;
- smival.value.string.ptr = address_buffer;
-
- valid_flag = parse_address( (char *)inaddr);
- format_output();
-}
-
-//-----------------[ construct a UdpAddress from a GenAddress ]--------------
-UdpAddress::UdpAddress( const GenAddress &genaddr):IpAddress()
-{
- // always initialize SMI info
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = UDPIPV4LEN;
- smival.value.string.ptr = address_buffer;
-
- unsigned int port = 0;
- valid_flag = 0;
-
- // allow use of an ip or udp genaddress
- if (genaddr.get_type() == type_udp)
- {
- valid_flag = genaddr.valid();
- if ( valid_flag)
- {
- // copy in the IP address data
- UdpAddress temp_udp( (const char *) genaddr);
- *this = temp_udp;
-
- // port info since are making an UpAddress
- port = temp_udp.get_port();
- }
- }
- else
- if (genaddr.get_type() == type_ip)
- {
- valid_flag = genaddr.valid();
- if ( valid_flag)
- {
- // copy in the IP address data
- IpAddress temp_ip( (const char *) genaddr);
- *this = temp_ip;
- }
- }
- set_port(port);
- format_output();
-}
-
-
-//--------[ construct a udp from an IpAddress ]--------------------------
-UdpAddress::UdpAddress( const IpAddress &ipaddr):IpAddress(ipaddr)
-{
- // always initialize SMI info
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = UDPIPV4LEN;
- smival.value.string.ptr = address_buffer;
-
- set_port(0);
- format_output();
-}
-
-
-//-----[ destructor ]--------------------------------------------------
-UdpAddress::~UdpAddress()
-{
-}
-
-
- // copy an instance of this Value
-SnmpSyntax& UdpAddress::operator=( SnmpSyntax &val)
-{
- // protect against assignment from itself
- if ( this == &val )
- return *this;
-
- valid_flag=0; // will get set 1 if really valid
- if (val.valid()){
- switch (val.get_syntax()){
- case sNMP_SYNTAX_IPADDR:
- {
- UdpAddress temp_udp(val.to_string());
- *this = temp_udp; // valid_flag is set by the udp assignment
- }
- break;
-
- case sNMP_SYNTAX_OCTETS:
- if (((UdpAddress &)val).smival.value.string.len == UDPIPV4LEN){
- ACE_OS::memcpy(address_buffer,
- ((UdpAddress &)val).smival.value.string.ptr, UDPIPV4LEN);
- iv_friendly_name_[0] = 0;
- valid_flag = 1;
- }
- break;
-
- // NOTE: as a value add, other types could have "logical"
- // mappings, i.e. integer32 and unsigned32
- }
- }
- format_output();
- return *this;
-}
-
- // assignment to another UdpAddress object overloaded
-UdpAddress& UdpAddress::operator=( const UdpAddress &udpaddr)
-{
- // protect against assignment from itself
- if ( this == &udpaddr )
- return *this;
-
- (IpAddress &)*this = udpaddr; // use ancestor assignment for ipaddr value
- set_port(udpaddr.get_port()); // copy to port value
- format_output();
- return *this;
-}
-
-
-//-----[ IP Address parse Address ]---------------------------------
-int UdpAddress::parse_address( const char *inaddr)
-{
- char buffer[MAXHOSTNAMELEN +1];
-
- unsigned short port = 0;
- if (inaddr && (ACE_OS::strlen( inaddr)< MAXHOSTNAMELEN +1))
- ACE_OS::strcpy( buffer, inaddr);
- else {
- valid_flag = 0;
- return 0;
- }
- // look for port info @ the end of the string
- // port can be delineated by a ':' or a '/'
- // if neither are present then just treat it
- // like a normal IpAddress
- char *tmp;
- tmp = ACE_OS::strstr( buffer,":");
- if (tmp==0)
- tmp = ACE_OS::strstr(buffer,"/");
-
- if ( tmp != 0) {
- *tmp=0; // null terminator
- tmp++;
- port = ACE_OS::atoi( tmp);
- }
-
- set_port(port);
- return IpAddress::parse_address( buffer);
-}
-
-
-//----------[ create a new instance of this Value ]------------------------
-SnmpSyntax *UdpAddress::clone() const
-{
- return (SnmpSyntax *) new UdpAddress(*this);
-}
-
-//--------[ set the port number ]---------------------------------------
-void UdpAddress::set_port( const unsigned short p)
-{
- unsigned short port_nbo = htons(p);
- ACE_OS::memcpy(&address_buffer[IPV4LEN], &port_nbo, 2);
- format_output();
-}
-
-//---------[ get the port number ]--------------------------------------
-unsigned short UdpAddress::get_port() const
-{
- if (valid_flag) {
- unsigned short port_nbo;
- ACE_OS::memcpy(&port_nbo, &address_buffer[IPV4LEN], 2);
- return ntohs(port_nbo);
- }
- else
- return 0; // don't use uninitialized memory
-}
-
-//------[ return the type ]--------------------------------------------
-addr_type UdpAddress::get_type() const
-{
- return type_udp;
-}
-
-//----[ UDP address char * cast ]--------------------------------------
-UdpAddress::operator const char *() const
-{
- return (char *)output_buffer;
-}
-
-//----[ UDP address get char representation ]--------------------------
-char * UdpAddress::to_string()
-{
- return (char *)output_buffer;
-}
-
-// make format same as ACE_INET_Addr class (addr:port)
-void UdpAddress::format_output()
-{
- IpAddress::format_output(); // allow ancestors to format their buffers
-
- // if valid format else null it
- if ( valid_flag)
- ACE_OS::sprintf( (char *) output_buffer,"%s:%d",
- IpAddress::to_string(),
- get_port() );
- else
- output_buffer[0] = 0;
-}
-
-
-//=======================================================================
-//=========== Netbios Address Implementation ============================
-//=======================================================================
-
-void NetbiosAddress::format_output()
-{
- if ( valid_flag)
- ACE_OS::memcpy(output_buffer, address_buffer, NETBIOSLEN);
- else
- output_buffer[0] = 0;
-}
-
-void NetbiosAddress::InitNBAddr(const char *inaddr)
-{
- if (ACE_OS::strlen(inaddr) == 0) {
- // always initialize SMI info
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = NETBIOSLEN;
- smival.value.string.ptr = address_buffer;
-
- valid_flag=0;
- NetbiosAddress::format_output();
- return;
- }
-
- // always initialize SMI info
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = IPXLEN;
- smival.value.string.ptr = address_buffer;
-
- valid_flag = parse_address( (char *) inaddr);
- NetbiosAddress::format_output();
-}
-
-// TODO: how to handle addresses < 15 chars (zero out or pad with ' ')
-NetbiosAddress::NetbiosAddress( const char *inaddr)
-{
- InitNBAddr(inaddr);
-
-}
-
-NetbiosAddress::NetbiosAddress( const char *inaddr, nb_service svc)
-{
- InitNBAddr(inaddr);
- address_buffer[15] = svc;
-}
-
-// TODO: go back over ms/ibm specs and verify this
-// 16 chars, 15 can be any character, 16th is service number between 0 and 20
-// names beginning with IBM are reserved, and hence invalid
-// and doubt IBM would use this class anyway
-int NetbiosAddress::parse_address(const char *address)
-{
- if (ACE_OS::strlen(address) > NETBIOSLEN)
- return 0; // invalid
-
- if (ACE_OS::strncmp(address, "IBM", 3) == 0)
- return 0; // invalid
-
- // addresses are free form but this check may need to be expose to user
- //
- //if (address[15] < nb_workstation || address[15] > nb_server)
- // return 0; //invalid service type
-
- ACE_OS::memset(address_buffer, 0, NETBIOSLEN);
- ACE_OS::memcpy(address_buffer, address, NETBIOSLEN);
-
- return 1; // valid
-}
-
-NetbiosAddress::NetbiosAddress( const NetbiosAddress& nbaddr)
-{
- // always initialize SMI info
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = NETBIOSLEN;
- smival.value.string.ptr = address_buffer;
-
- valid_flag = nbaddr.valid_flag;
- if (valid_flag)
- ACE_OS::memcpy(address_buffer, nbaddr.address_buffer, NETBIOSLEN);
- NetbiosAddress::format_output();
-}
-
-NetbiosAddress::NetbiosAddress( const GenAddress& genaddr)
-{
- // always initialize SMI info
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = NETBIOSLEN;
- smival.value.string.ptr = address_buffer;
-
- valid_flag = 0;
- // allow use of an ipx or ipxsock address
- if ( (genaddr.get_type() == type_nb) ) {
- valid_flag = genaddr.valid();
- if ( valid_flag) {
- // copy in the Ipx address data
- NetbiosAddress temp_nb( (const char *) genaddr);
- *this = temp_nb;
- }
- }
- NetbiosAddress::format_output();
-}
-
-NetbiosAddress::~NetbiosAddress()
-{
-}
-
-char *NetbiosAddress::to_string()
-{
- return (char *)output_buffer;
-}
-
-void NetbiosAddress::to_octet(OctetStr& octet) const
-{
- octet.set_data( smival.value.string.ptr, smival.value.string.len);
-}
-
-NetbiosAddress& NetbiosAddress::operator=( const NetbiosAddress &val)
-{
- // protect against assignment from itself
- if ( this == &val )
- return *this;
-
- valid_flag = 0; // will set to 1 if really valid
- if (val.valid()) {
- switch (((NetbiosAddress *) &val)->get_syntax()) {
- case sNMP_SYNTAX_OCTETS:
- ACE_OS::memcpy(address_buffer,
- ((NetbiosAddress &)val).smival.value.string.ptr, NETBIOSLEN);
- valid_flag = 1;
- break;
- }
- }
- NetbiosAddress::format_output();
- return *this;
-}
-
-nb_service NetbiosAddress::get_service_type() const
-{
- return (nb_service) address_buffer[15];
-}
-
-void NetbiosAddress::set_service_type(nb_service nbservice)
-{
- address_buffer[15] = nbservice;
- NetbiosAddress::format_output();
-}
-
-NetbiosAddress::operator const char *() const
-{
- return (char *)output_buffer;
-}
-
-SnmpSyntax& NetbiosAddress::operator=( SnmpSyntax &val)
-{
- // protect against assignment from itself
- if ( this == &val )
- return *this;
-
- valid_flag = 0; // will set to 1 if really valid
- if (val.valid()) {
- switch (val.get_syntax()) {
- case sNMP_SYNTAX_OCTETS:
- if (((NetbiosAddress &)val).smival.value.string.len == NETBIOSLEN) {
- ACE_OS::memcpy(address_buffer,
- ((NetbiosAddress &)val).smival.value.string.ptr, NETBIOSLEN);
- valid_flag=1;
- }
- break;
- }
- }
- NetbiosAddress::format_output();
- return *this;
-}
-
-SnmpSyntax *NetbiosAddress::clone() const
-{
- return (SnmpSyntax *) new NetbiosAddress(*this);
-}
-
-SmiUINT32 NetbiosAddress::get_syntax()
-{
- return sNMP_SYNTAX_OCTETS;
-}
-
-addr_type NetbiosAddress::get_type() const
-{
- return type_nb;
-}
-
-//=======================================================================
-//=========== IPX Address Implementation ================================
-//=======================================================================
-
-//-----------[ syntax type ]----------------------------------------------
-SmiUINT32 IpxAddress::get_syntax()
-{
- return sNMP_SYNTAX_OCTETS;
-}
-
-
-//----------[ default constructor with a string arg ]---------------------------
-IpxAddress::IpxAddress( const char *inaddr):Address( )
-{
- if (ACE_OS::strlen(inaddr) == 0) {
- // always initialize SMI info
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = IPXLEN;
- smival.value.string.ptr = address_buffer;
-
- separator = '\0';
- valid_flag=0;
- IpxAddress::format_output();
- return;
- }
- // always initialize SMI info
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = IPXLEN;
- smival.value.string.ptr = address_buffer;
-
- separator = '\0';
- valid_flag = parse_address( (char *) inaddr);
- IpxAddress::format_output();
-}
-
-
-//-----[ IPX Address copy constructor ]----------------------------------
-IpxAddress::IpxAddress(const IpxAddress &ipxaddr)
-{
- // always initialize SMI info
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = IPXLEN;
- smival.value.string.ptr = address_buffer;
-
- separator = '\0';
- valid_flag = ipxaddr.valid_flag;
- if (valid_flag)
- ACE_OS::memcpy(address_buffer, ipxaddr.address_buffer, IPXLEN);
- IpxAddress::format_output();
-}
-
-
-//----[ construct an IpxAddress from a GenAddress ]---------------------------
-IpxAddress::IpxAddress( const GenAddress &genaddr)
-{
- // always initialize SMI info
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = IPXLEN;
- smival.value.string.ptr = address_buffer;
-
- valid_flag = 0;
- // allow use of an ipx or ipxsock address
- if ( (genaddr.get_type() == type_ipx) ) {
- valid_flag = genaddr.valid();
- if ( valid_flag) {
- // copy in the Ipx address data
- IpxAddress temp_ipx( (const char *) genaddr);
- *this = temp_ipx;
- }
- }
- else
- if ( (genaddr.get_type() == type_ipxsock) ) {
- valid_flag = genaddr.valid();
- if ( valid_flag) {
- // copy in the Ipx address data
- IpxSockAddress temp_ipxsock( (const char *) genaddr);
- *this = temp_ipxsock;
- }
- }
- IpxAddress::format_output();
-}
-
-
-//-----[ destructor ]--------------------------------------------------
-IpxAddress::~IpxAddress()
-{
-}
-
-
-//-----[ IPX Address general = operator ]-------------------------------
-SnmpSyntax& IpxAddress::operator=( SnmpSyntax &val)
-{
- // protect against assignment from itself
- if ( this == &val )
- return *this;
-
- valid_flag=0; // will set to 1 if really valid
- if (val.valid()){
- switch (val.get_syntax()){
- case sNMP_SYNTAX_OCTETS:
- if (((IpxAddress &)val).smival.value.string.len == IPXLEN){
- ACE_OS::memcpy(address_buffer, ((IpxAddress &)val).smival.value.string.ptr, IPXLEN);
- valid_flag=1;
- }
- break;
- }
- }
- IpxAddress::format_output();
- return *this;
-}
-
-//--------[ assignment to another IpAddress object overloaded ]----------
-IpxAddress& IpxAddress::operator=( const IpxAddress &ipxaddress)
-{
- // protect against assignment from itself
- if ( this == &ipxaddress )
- return *this;
-
- valid_flag = ipxaddress.valid_flag;
- if (valid_flag)
- ACE_OS::memcpy(address_buffer, ipxaddress.address_buffer, IPXLEN);
- IpxAddress::format_output();
- return *this;
-}
-
-
-// create a new instance of this Value
-SnmpSyntax *IpxAddress::clone() const
-{
- return (SnmpSyntax *) new IpxAddress(*this);
-}
-
-//-----[ IPX Address parse Address ]-----------------------------------
-// Convert a string to a ten byte ipx address
-// On success sets validity 1 or 0
-//
-// IPX address format
-//
-// NETWORK ID| MAC ADDRESS
-// 01 02 03 04|05 06 07 08 09 10
-// XX XX XX XX|XX XX XX XX XX XX
-//
-// Valid input format
-//
-// XXXXXXXX.XXXXXXXXXXXX
-// Total length must be 21
-// Must have a separator in it
-// First string length must be 8
-// Second string length must be 12
-// Each char must take on value 0-F
-//
-//
-// Input formats recognized
-//
-// XXXXXXXX.XXXXXXXXXXXX
-// XXXXXXXX:XXXXXXXXXXXX
-// XXXXXXXX-XXXXXXXXXXXX
-// XXXXXXXX.XXXXXX-XXXXXX
-// XXXXXXXX:XXXXXX-XXXXXX
-// XXXXXXXX-XXXXXX-XXXXXX
-int IpxAddress::parse_address( const char *inaddr)
-{
- char unsigned *str1,*str2;
- char temp[30]; // don't destroy original
- char unsigned *tmp;
- size_t z, tmplen;
-
-
- // save the orginal source
- if (!inaddr || (ACE_OS::strlen( inaddr) >(sizeof(temp)-1))) return 0;
- ACE_OS::strcpy( temp, inaddr);
- trim_white_space( temp);
- tmplen = ACE_OS::strlen(temp);
-
- // bad total length check
- // 123456789012345678901
- // XXXXXXXX-XXXXXXXXXXXX 21 len
- //
- // XXXXXXXX-XXXXXX-XXXXXX 22 len
- // need at least 21 chars and no more than 22
- if ( (tmplen <21) || (tmplen >22))
- return 0;
-
- // convert the string to all lower case
- // this allows hex values to be in upper or lower
- for (z=0;z< tmplen;z++)
- temp[z] = tolower(temp[z]);
-
- // check for separated nodeid
- // if found remove it
- if (temp[15] == '-')
- {
- for(z=16;z<tmplen;z++)
- temp[z-1] = temp[z];
- temp[tmplen-1] = 0;
- }
-
- // no dot or colon separator check
- separator = temp[8];
- if (( separator != ':') &&
- ( separator != '.') &&
- ( separator != '-') &&
- ( separator != ' '))
- return 0;
-
- // separate the strings
- str1 = ( unsigned char *) temp;
- while( *str1 != separator) str1++;
- str2 = str1 + 1;
- *str1 = 0;
- str1= ( unsigned char *) temp;
-
- // check len of the network portion
- if ( ACE_OS::strlen((char *) str1) != 8)
- return 0;
-
- // check len of mac portion
- if ( ACE_OS::strlen( (char *) str2) != 12)
- return 0;
-
- // ok we like then lens, make sure that all chars are 0-f
- // check out the net id
- tmp = str1;
- while( *tmp != 0)
- if (((*tmp >= '0') && (*tmp <= '9'))|| // good 0-9
- ((*tmp >= 'a') && (*tmp <= 'f'))) // or a-f
- tmp++;
- else
- return 0;
-
- // check out the MAC address
- tmp = str2;
- while( *tmp != 0)
- if (((*tmp >= '0') && (*tmp <= '9'))|| // good 0-9
- ((*tmp >= 'a') && (*tmp <= 'f'))) // or a-f
- tmp++;
- else
- return 0;
-
- // convert to target string
- tmp = str1;
- while ( *tmp != 0)
- {
- if (( *tmp >= '0') && ( *tmp <= '9'))
- *tmp = *tmp - (char unsigned )'0';
- else
- *tmp = *tmp - (char unsigned) 'a' + (char unsigned) 10;
- tmp++;
- }
-
- // network id portion
- address_buffer[0] = (str1[0]*16) + str1[1];
- address_buffer[1] = (str1[2]*16) + str1[3];
- address_buffer[2] = (str1[4]*16) + str1[5];
- address_buffer[3] = (str1[6]*16) + str1[7];
-
- tmp = str2;
- while ( *tmp != 0)
- {
- if (( *tmp >= '0') && ( *tmp <= '9'))
- *tmp = *tmp - (char unsigned) '0';
- else
- *tmp = *tmp - (char unsigned) 'a'+ (char unsigned) 10;
- tmp++;
- }
-
- address_buffer[4] = (str2[0]*16) + str2[1];
- address_buffer[5] = (str2[2]*16) + str2[3];
- address_buffer[6] = (str2[4]*16) + str2[5];
- address_buffer[7] = (str2[6]*16) + str2[7];
- address_buffer[8] = (str2[8]*16) + str2[9];
- address_buffer[9] = (str2[10]*16) + str2[11];
-
- return 1;
-}
-
-//----[ IPX address char * cast ]--------------------------------------
-IpxAddress::operator const char *() const
-{
- return (char *)output_buffer;
-}
-
-//----[ IPX address get char representation ]--------------------------
-char * IpxAddress::to_string()
-{
- return (char *)output_buffer;
-}
-
-
-//----[ IPX address format output ]-------------------------------------
-void IpxAddress::format_output()
-{
- if ( valid_flag)
- ACE_OS::sprintf((char *) output_buffer,
- "%02x%02x%02x%02x%c%02x%02x%02x%02x%02x%02x",
- address_buffer[0],address_buffer[1],
- address_buffer[2],address_buffer[3],'-',
- address_buffer[4],address_buffer[5],
- address_buffer[6],address_buffer[7],
- address_buffer[8],address_buffer[9]);
- else
- output_buffer[0] = 0;
-}
-
-
-// get the host id portion of an ipx address
-int IpxAddress::get_hostid( MacAddress& mac)
-{
- if ( valid_flag)
- {
- char buffer[18];
- ACE_OS::sprintf( buffer,"%02x:%02x:%02x:%02x:%02x:%02x",
- address_buffer[4],
- address_buffer[5], address_buffer[6], address_buffer[7],
- address_buffer[8], address_buffer[9]);
- MacAddress temp( buffer);
- // mac = (SnmpSyntax&) temp;
- mac = temp;
- if ( mac.valid())
- return 1;
- else
- return 0;
- }
- else
- return 0;
-}
-
-
-//------[ return the type ]----------------------------------
-addr_type IpxAddress::get_type() const
-{
- return type_ipx;
-}
-
-void IpxAddress::to_octet(OctetStr& octet) const
-{
- octet.set_data( smival.value.string.ptr, smival.value.string.len);
-}
-
-
-//========================================================================
-//======== IpxSockAddress Implementation =================================
-//========================================================================
-
-//-----------[ syntax type ]----------------------------------------------
-SmiUINT32 IpxSockAddress::get_syntax()
-{
- return sNMP_SYNTAX_OCTETS;
-}
-
-//-----------[ construct an IpxSockAddress with another IpxSockAddress]----
-IpxSockAddress::IpxSockAddress( const IpxSockAddress &ipxaddr):IpxAddress(ipxaddr)
-{
- // always initialize SMI info
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = IPXSOCKLEN;
- smival.value.string.ptr = address_buffer;
-
- // copy the socket value
- set_socket(ipxaddr.get_socket());
- format_output();
-}
-
-
-//---------------[ default construct a IpxSockAddress ]--------------
-IpxSockAddress::IpxSockAddress( const char *inaddr):IpxAddress()
-{
- if (ACE_OS::strlen(inaddr) == 0) {
- // always initialize SMI info
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = IPXSOCKLEN;
- smival.value.string.ptr = address_buffer;
-
- set_socket(0);
- format_output();
- return;
- }
-
- // always initialize SMI info
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = IPXSOCKLEN;
- smival.value.string.ptr = address_buffer;
-
- valid_flag = parse_address( (char *) inaddr);
- format_output();
-}
-
-
-//---------------[ construct a IpxSockAddress from a GenAddress ]----------
-IpxSockAddress::IpxSockAddress( const GenAddress &genaddr):IpxAddress()
-{
- // always initialize SMI info
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = IPXSOCKLEN;
- smival.value.string.ptr = address_buffer;
-
- valid_flag = 0;
- unsigned short socketid = 0;
- // allow use of an ipx or ipxsock address
- if ( (genaddr.get_type() == type_ipx) )
- {
- valid_flag = genaddr.valid();
- if ( valid_flag)
- {
- // copy in the Ipx address data
- IpxAddress temp_ipx( (const char *) genaddr);
- *this = temp_ipx;
- }
- }
- else
- if ( (genaddr.get_type() == type_ipxsock) )
- {
- valid_flag = genaddr.valid();
- if ( valid_flag)
- {
- // copy in the Ipx address data
- IpxSockAddress temp_ipxsock( (const char *) genaddr);
- *this = temp_ipxsock;
- // socketid info since are making an IpxSockAddress
- socketid = temp_ipxsock.get_socket();
- }
- }
- set_socket(socketid);
- format_output();
-}
-
-
-//------------[ construct an IpxSockAddress from a IpxAddress ]--------------
-IpxSockAddress::IpxSockAddress( const IpxAddress &ipxaddr):IpxAddress(ipxaddr)
-{
- // always initialize SMI info
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = IPXSOCKLEN;
- smival.value.string.ptr = address_buffer;
-
- set_socket(0);
- format_output();
-}
-
-//-----[ destructor ]--------------------------------------------------
-IpxSockAddress::~IpxSockAddress()
-{
-}
-
-// copy an instance of this Value
-SnmpSyntax& IpxSockAddress::operator=( SnmpSyntax &val)
-{
- // protect against assignment from itself
- if ( this == &val )
- return *this;
-
- valid_flag=0; // will set to 1 if really valid
- if (val.valid()){
- switch (val.get_syntax()){
- case sNMP_SYNTAX_OCTETS:
- {
- // See if it is of the Ipx address family
- // This handles IpxSockAddress == IpxAddress
- IpxSockAddress temp_ipx(val.to_string());
- if (temp_ipx.valid()){
- *this = temp_ipx; // ipxsock = ipxsock
- }
- // See if it is an OctetStr of appropriate length
- else if (((IpxSockAddress &)val).smival.value.string.len == IPXSOCKLEN){
- ACE_OS::memcpy(address_buffer,
- ((IpxSockAddress &)val).smival.value.string.ptr,
- IPXSOCKLEN);
- valid_flag=1;
- }
- }
- break;
- }
- }
- format_output();
- return *this;
-}
-
-// assignment to another IpAddress object overloaded
-IpxSockAddress& IpxSockAddress::operator=( const IpxSockAddress &ipxaddr)
-{
- // protect against assignment from itself
- if ( this == &ipxaddr )
- return *this;
-
- (IpxAddress&)*this = ipxaddr; // use ancestor assignment for ipx addr
- set_socket(ipxaddr.get_socket()); // copy socket value
- format_output();
- return *this;
-}
-
-
-//----------[ create a new instance of this Value ]------------------------
-SnmpSyntax *IpxSockAddress::clone() const
-{
- return (SnmpSyntax *) new IpxSockAddress(*this);
-}
-
-//----[ IPXSock address char * cast ]--------------------------------------
-IpxSockAddress::operator const char *() const
-{
- return (char *)output_buffer;
-}
-
-//----[ IPXSock address get char representation ]--------------------------
-char * IpxSockAddress::to_string()
-{
- return (char *)output_buffer;
-}
-
-//----[ IPX address format output ]-------------------------------------
-void IpxSockAddress::format_output()
-{
- IpxAddress::format_output(); // allow ancestors to format their buffers
-
- if ( valid_flag)
- ACE_OS::sprintf((char *) output_buffer,"%s/%d",
- IpxAddress::to_string(), get_socket());
- else
- output_buffer[0] = 0;
-}
-
-//-----[ IP Address parse Address ]---------------------------------
-int IpxSockAddress::parse_address( const char *inaddr)
-{
- char buffer[MAXHOSTNAMELEN +1];
- unsigned short socketid=0;
-
- if (inaddr && (ACE_OS::strlen( inaddr)< MAXHOSTNAMELEN))
- ACE_OS::strcpy( buffer, inaddr);
- else
- {
- valid_flag = 0;
- return 0;
- }
- // look for port info @ the end of the string
- // port can be delineated by a ':' or a '/'
- // if neither are present then just treat it
- // like a normal IpAddress
- char *tmp;
- tmp = ACE_OS::strstr( buffer,"/");
-
- if (tmp != 0)
- {
- *tmp=0; // null terminator
- tmp++;
- socketid = ACE_OS::atoi( tmp);
- }
- set_socket(socketid);
- return IpxAddress::parse_address( buffer);
-}
-
-
-
-//-------------[ set the socket number ]----------------------------------
-void IpxSockAddress::set_socket( const unsigned short s)
-{
- unsigned short sock_nbo = htons(s);
- ACE_OS::memcpy(&address_buffer[IPXLEN], &sock_nbo, 2);
-}
-
-//--------------[ get the socket number ]---------------------------------
-unsigned short IpxSockAddress::get_socket() const
-{
- if (valid_flag)
- {
- unsigned short sock_nbo;
- ACE_OS::memcpy(&sock_nbo, &address_buffer[IPXLEN], 2);
- return ntohs(sock_nbo);
- }
- else
- return 0; // don't use uninitialized memory
-}
-
-//------[ return the type ]----------------------------------------------
-addr_type IpxSockAddress::get_type() const
-{
- return type_ipxsock;
-}
-
-
-//========================================================================
-//======== MACAddress Implementation =====================================
-//========================================================================
-
-//-----------[ syntax type ]----------------------------------------------
-SmiUINT32 MacAddress::get_syntax()
-{
- return sNMP_SYNTAX_OCTETS;
-}
-
-//-----[ MAC Address copy constructor ]---------------------------------
-MacAddress::MacAddress(const MacAddress &macaddr)
-{
- // always initialize SMI info
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = MACLEN;
- smival.value.string.ptr = address_buffer;
-
- valid_flag = macaddr.valid_flag;
- if (valid_flag)
- ACE_OS::memcpy(address_buffer, macaddr.address_buffer, MACLEN);
- format_output();
-}
-
-//---------[ constructor with a string argument ]-------------------------
-MacAddress::MacAddress( const char *inaddr):Address( )
-{
- if (ACE_OS::strlen(inaddr) == 0) {
- // always initialize SMI info
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = MACLEN;
- smival.value.string.ptr = address_buffer;
-
- valid_flag=0;
- format_output();
- return;
- }
-
- // always initialize SMI info
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = MACLEN;
- smival.value.string.ptr = address_buffer;
-
- valid_flag = parse_address( (char *) inaddr);
- format_output();
-}
-
-//-----[ construct a MacAddress from a GenAddress ]------------------------
-MacAddress::MacAddress( const GenAddress &genaddr)
-{
- // always initialize SMI info
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = MACLEN;
- smival.value.string.ptr = address_buffer;
-
- valid_flag = 0;
- // allow use of mac address
- if (genaddr.get_type() == type_mac)
- {
- valid_flag = genaddr.valid();
- if ( valid_flag)
- {
- // copy in the Mac address data
- MacAddress temp_mac( (const char *) genaddr);
- *this = temp_mac;
- }
- }
- format_output();
-}
-
-//-----[ destructor ]--------------------------------------------------
-MacAddress::~MacAddress()
-{
-}
-
-//---------[ MacAddress clone ]-------------------------------------------
-SnmpSyntax *MacAddress::clone() const
-{
- return (SnmpSyntax *) new MacAddress(*this);
-}
-
-//------[ assignment to another ipaddress object overloaded ]--------------
-MacAddress& MacAddress::operator=( const MacAddress &macaddress)
-{
- // protect against assignment from itself
- if ( this == &macaddress )
- return *this;
-
- valid_flag = macaddress.valid_flag;
- if (valid_flag)
- ACE_OS::memcpy(address_buffer, macaddress.address_buffer, MACLEN);
- format_output();
- return *this;
-}
-
-
-
-//-----[ MAC Address general = operator ]---------------------------------
-SnmpSyntax& MacAddress::operator=( SnmpSyntax &val)
-{
- // protect against assignment from itself
- if ( this == &val )
- return *this;
-
- valid_flag=0; // will set to 1 if really valid
- if (val.valid()){
- switch (val.get_syntax()){
- case sNMP_SYNTAX_OCTETS:
- if (((MacAddress &)val).smival.value.string.len == MACLEN){
- ACE_OS::memcpy(address_buffer,
- ((MacAddress &)val).smival.value.string.ptr, MACLEN);
- valid_flag=1;
- }
- break;
- }
- }
- format_output();
- return *this;
-}
-
-//-----[ MAC Address parse Address ]--------------------------------------
-// Convert a string to a six byte MAC address
-// On success sets validity 1 or 0
-//
-// MAC address format
-//
-// MAC ADDRESS
-// 01 02 03 04 05 06
-// XX:XX:XX:XX:XX:XX
-// Valid input format
-//
-// XXXXXXXXXXXX
-// Total length must be 17
-// Each char must take on value 0-F
-//
-//
-int MacAddress::parse_address( const char *inaddr)
-{
- char temp[MAXHOSTNAMELEN +1]; // don't destroy original
- char unsigned *tmp;
- size_t z;
-
-
- // save the orginal source
- if ( !inaddr || (ACE_OS::strlen( inaddr) > 30)) return 0;
- ACE_OS::strcpy( temp, inaddr);
- trim_white_space( temp);
-
- // bad total length check
- if ( ACE_OS::strlen(temp) != 17)
- return 0;
-
- // check for colons
- if ((temp[2] != ':')||(temp[5] != ':')||(temp[8]!=':')||(temp[11]!=':')
- ||(temp[14] !=':'))
- return 0;
-
- // strip off the colons
- tmp = ( unsigned char *) temp;
- int i = 0;
- while ( *tmp != 0)
- {
- if (*tmp != ':')
- {
- temp[i] = *tmp;
- i++;
- }
- tmp++;
- }
- temp[i] = 0;
-
- // convert to lower
- for(z=0;z<ACE_OS::strlen(temp);z++)
- temp[z] = tolower( temp[z]);
-
-
- // check out the MAC address
- tmp = ( unsigned char *) temp;
- while( *tmp != 0)
- if (((*tmp >= '0') && (*tmp <= '9'))|| // good 0-9
- ((*tmp >= 'a') && (*tmp <= 'f'))) // or a-f
- tmp++;
- else
- return 0;
-
- // convert to target string
- tmp = (unsigned char *) temp;
- while ( *tmp != 0)
- {
- if (( *tmp >= '0') && ( *tmp <= '9'))
- *tmp = *tmp - (char unsigned )'0';
- else
- *tmp = *tmp - (char unsigned) 'a' + (char unsigned) 10;
- tmp++;
- }
-
- address_buffer[0] = (temp[0]*16) + temp[1];
- address_buffer[1] = (temp[2]*16) + temp[3];
- address_buffer[2] = (temp[4]*16) + temp[5];
- address_buffer[3] = (temp[6]*16) + temp[7];
- address_buffer[4] = (temp[8]*16) + temp[9];
- address_buffer[5] = (temp[10]*16) + temp[11];
-
- return 1;
-}
-
-//----[ MAC address char * cast ]--------------------------------------
-MacAddress::operator const char *() const
-{
- return (char *)output_buffer;
-}
-//----[ MAC address get char representation ]--------------------------
-char * MacAddress::to_string()
-{
- return (char *)output_buffer;
-}
-
-//----[ MAC address format output ]---------------------------------
-void MacAddress::format_output()
-{
- if ( valid_flag)
- sprintf(output_buffer,"%02x:%02x:%02x:%02x:%02x:%02x",address_buffer[0],
- address_buffer[1],address_buffer[2],address_buffer[3],
- address_buffer[4],address_buffer[5]);
- else
- output_buffer[0] = 0;
-}
-
-//------[ return the type ]----------------------------------
-addr_type MacAddress::get_type() const
-{
- return type_mac;
-}
-
-
-unsigned int MacAddress::hashFunction() const
-{
- return ((((address_buffer[0] << 8) + address_buffer[1]) * HASH0)
- + (((address_buffer[2] << 8) + address_buffer[3]) * HASH1)
- + (((address_buffer[4] << 8) + address_buffer[5]) * HASH2));
-}
-
-void MacAddress::to_octet(OctetStr& octet) const
-{
- octet.set_data( smival.value.string.ptr, smival.value.string.len);
-}
-
-//========================================================================
-//========== Generic Address Implementation ==============================
-//========================================================================
-
-//-----------[ get the syntax]----------------------------------------------
-SmiUINT32 GenAddress::get_syntax()
-{
- if (address != 0)
- return address->get_syntax();
-
- return sNMP_SYNTAX_NULL;
-}
-
-void GenAddress::init_smi()
-{
- smival.syntax = sNMP_SYNTAX_NULL; // to be overridden
- smival.value.string.len = 0; // to be overridden
- smival.value.string.ptr = address_buffer; // constant
-}
-
-//-----------[ constructor with a string argument ]----------------------
-GenAddress::GenAddress( const char *addr): address(0)
-{
- valid_flag = 0;
- // initialize SMI info
- // BOK: smival is generally not used for GenAddress, but
- // we need this to be a replica of the real address'
- // smival info so that <class>::operator=SnmpSyntax
- // will work.
- init_smi();
-
- if (addr && ACE_OS::strlen(addr) == 0) {
- format_output();
- return;
- }
-
- parse_address(addr);
-
- // Copy real address smival info into GenAddr smival
- // BOK: smival is generally not used for GenAddress, but
- // we need this to be a replica of the real address'
- // smival info so that <class>::operator=SnmpSyntax
- // will work.
- if ( valid_flag ) {
- smival.syntax = ((GenAddress *)address)->smival.syntax;
- smival.value.string.len =
- ((GenAddress *)address)->smival.value.string.len;
- ACE_OS::memcpy(smival.value.string.ptr,
- ((GenAddress *)address)->smival.value.string.ptr,
- (size_t)smival.value.string.len);
- }
-}
-
-//-----------[ constructor with an Address argument ]--------------------
-GenAddress::GenAddress( const Address &addr): address(0)
-{
- valid_flag = 0;
-
- // initialize SMI info
- // BOK: this is generally not used for GenAddress,
- // but we need this to be a replica of the real address'
- // smival info so that operator=SnmpSyntax will work.
- init_smi();
- // make sure that the object is valid
- if (!addr.valid()) {
- format_output();
- return;
- }
-
- address = (Address*)addr.clone();
- if (address)
- valid_flag = address->valid();
-
- // Copy real address smival info into GenAddr smival
- // BOK: smival is generally not used for GenAddress, but
- // we need this to be a replica of the real address'
- // smival info so that <class>::operator=SnmpSyntax
- // will work.
- if ( valid_flag ) {
- smival.syntax = address->get_syntax();
- smival.value.string.len =
- ((GenAddress *)address)->smival.value.string.len;
- ACE_OS::memcpy(smival.value.string.ptr,
- ((GenAddress *)address)->smival.value.string.ptr,
- (size_t)smival.value.string.len);
- }
-
- format_output();
-}
-
-//-----------------[ constructor with another GenAddress object ]-------------
-GenAddress::GenAddress( const GenAddress &addr): address(0)
-{
- valid_flag = 0;
-
- // initialize SMI info
- // BOK: this is generally not used for GenAddress,
- // but we need this to be a replica of the real address'
- // smival info so that operator=SnmpSyntax will work.
- init_smi();
-
- // make sure that the object is valid
- if (!addr.valid_flag) {
- format_output();
- return;
- }
-
- address = (Address *)addr.address->clone();
- if (address)
- valid_flag = address->valid();
-
- // Copy real address smival info into GenAddr smival
- // BOK: smival is generally not used for GenAddress, but
- // we need this to be a replica of the real address'
- // smival info so that <class>::operator=SnmpSyntax
- // will work.
- if ( valid_flag ) {
- smival.syntax = ((GenAddress *)address)->smival.syntax;
- smival.value.string.len =
- ((GenAddress *)address)->smival.value.string.len;
- ACE_OS::memcpy(smival.value.string.ptr,
- ((GenAddress *)address)->smival.value.string.ptr,
- (size_t)smival.value.string.len);
- }
-
- format_output();
-}
-
-//----------[ destructor ] ------------------------------------------------
-GenAddress::~GenAddress()
-{
- if ( address != 0)
- delete address;
-}
-
-//----------[ create a new instance of this Value ]------------------------
-SnmpSyntax *GenAddress::clone() const
-{
- return (SnmpSyntax *) new GenAddress(*this);
-}
-
-//------[ assignment GenAddress = GenAddress ]-----------------------------
-GenAddress& GenAddress::operator=( const GenAddress &addr)
-{
- // protect against assignment from itself
- if ( this == &addr )
- return *this;
-
- valid_flag = 0;
- if (address) {
- delete address;
- address = 0;
- }
-
- if (addr.address)
- address = (Address *)(addr.address)->clone();
-
- if (address)
- valid_flag = address->valid();
-
- // Copy real address smival info into GenAddr smival
- // BOK: smival is generally not used for GenAddress, but
- // we need this to be a replica of the real address'
- // smival info so that <class>::operator=SnmpSyntax
- // will work.
- if ( valid_flag ) {
- smival.syntax = ((GenAddress *)address)->smival.syntax;
- smival.value.string.len =
- ((GenAddress *)address)->smival.value.string.len;
- ACE_OS::memcpy(smival.value.string.ptr,
- ((GenAddress *)address)->smival.value.string.ptr,
- (size_t)smival.value.string.len);
- }
-
- format_output();
- return *this;
-}
-
-
-//------[ assignment GenAddress = any SnmpSyntax ]-----------------------
-SnmpSyntax& GenAddress::operator=( SnmpSyntax &val)
-{
- // protect against assignment from itself
- if ( this == &val )
- return *this;
-
- valid_flag = 0; // will get set to 1 if really valid
- if ( address != 0) {
- delete address;
- address = 0;
- }
-
- if (val.valid()) {
- switch ( val.get_syntax() ) {
- //-----[ ip address case ]-------------
- // BOK: this case shouldn't be needed since there is an explicit
- // GenAddr=Address assignment that will override this assignment.
- // Left here for posterity.
- case sNMP_SYNTAX_IPADDR:
- {
- address = (Address *)val.clone();
- if (address)
- valid_flag = address->valid();
- }
- break;
-
- //-----[ udp address case ]------------
- //-----[ ipx address case ]------------
- //-----[ mac address case ]------------
- // BOK: This is here only to support GenAddr = primitive OctetStr.
- // The explicit GenAddr=Address assignment will handle the cases
- // GenAddr = [UdpAdd|IpxAddr|IpxSock|MacAddr|DecNetAddr|NetbiosAddr|AppleTlk].
- // Note, using the heuristic of octet str len to determine type of
- // address to create is not accurate when address lengths are equal
- // (e.g., UDPIPV4LEN == MACLEN). It gets worse if we add AppleTalk or
- // OSI which use variable length addresses! assume AppleTalk as used in IOS Mibs
- // is defined in CISCO-TC.my as fixed length of 3 octets
-
- case sNMP_SYNTAX_OCTETS:
- {
- unsigned long val_len;
- val_len = ((GenAddress &)val).smival.value.string.len;
-
- if (val_len == UDPIPV4LEN) {
- ACE_NEW_RETURN(address, UdpAddress, *this);
- }
- else if (val_len ==IPV4LEN) {
- ACE_NEW_RETURN(address, IpAddress, *this);
- }
- else if (val_len == IPXLEN) {
- ACE_NEW_RETURN(address, IpxAddress, *this);
- }
- else if (val_len == IPXSOCKLEN) {
- ACE_NEW_RETURN(address, IpxSockAddress, *this);
- }
- else if (val_len == MACLEN) {
- ACE_NEW_RETURN(address, MacAddress, *this);
- }
- else if (val_len == APPLETKLEN) {
- ACE_NEW_RETURN(address, AppleTalkAddress, *this);
- }
- else if (val_len == DECNETLEN) {
- ACE_NEW_RETURN(address, DecNetAddress, *this);
- }
- else if (val_len == NETBIOSLEN) {
- ACE_NEW_RETURN(address, DecNetAddress, *this);
- }
-
- if (address) {
- *address = val;
- valid_flag = address->valid();
- }
- }
- break;
- } // end switch
- }
-
- // Copy real address smival info into GenAddr smival
- // BOK: smival is generally not used for GenAddress, but
- // we need this to be a replica of the real address'
- // smival info so that <class>::operator=SnmpSyntax
- // will work.
- if ( valid_flag ) {
- smival.syntax = ((GenAddress *)address)->smival.syntax;
- smival.value.string.len =
- ((GenAddress *)address)->smival.value.string.len;
- ACE_OS::memcpy(smival.value.string.ptr,
- ((GenAddress *)address)->smival.value.string.ptr,
- (size_t)smival.value.string.len);
- }
-
- format_output();
- return *this;
-}
-
-
-// redefined parse address for macs
-// TODO: Add netbios, appletalk, and decnet addresses here
-int GenAddress::parse_address( const char *addr)
-{
- if ( address != 0)
- delete address;
-
- // try to create each of the addresses until the correct one
- // is found
-
-//BOK: Need to try IPX Sock and IPX before UDP since on Win32,
-// gethostbyname() seems to think the ipx network number
-// portion is a valid ipaddress string... stupid WinSOCK!
-
- // ipxsock address
- ACE_NEW_RETURN(address, IpxSockAddress( addr), -1);
- valid_flag = address->valid();
- if ( valid_flag && ((IpxSockAddress*)address)->get_socket()) {
- format_output();
- return 1; // ok its an ipxsock address
- }
- // otherwise delete it and try another
- delete address;
-
- // ipx address
- ACE_NEW_RETURN(address, IpxAddress( addr), -1);
- valid_flag = address->valid();
- if ( valid_flag) {
- format_output();
- return 1; // ok its an ipx address
- }
- // otherwise delete it and try another
- delete address;
-
-//TM: Must try the derived classes first...one pitfall of the
-//following solution is if someone creates with a port/socket of 0 the
-//class will get demoted to ip/ipx. The only proper way to do this is
-//to parse the strings ourselves.
-
- // udp address
- ACE_NEW_RETURN(address, UdpAddress( addr), -1);
- valid_flag = address->valid();
- if ( valid_flag && ((UdpAddress*)address)->get_port()) {
- format_output();
- return 1; // ok its a udp address
- }
-
- // otherwise delete it and try another
- delete address;
-
- // ip address
- ACE_NEW_RETURN(address, IpAddress( addr), -1);
- valid_flag = address->valid();
- if ( valid_flag)
- {
- format_output();
- return 1; // ok its an ip address
- }
- // otherwise delete it and try another
- delete address;
-
- // mac address
- ACE_NEW_RETURN(address, MacAddress( addr), -1);
- valid_flag = address->valid();
- if ( valid_flag) {
- format_output();
- return 1; // ok, its a mac
- }
-
- // guess by length of argument the type of address
- switch (ACE_OS::strlen(addr)) {
- case NETBIOSLEN:
- ACE_NEW_RETURN(address, NetbiosAddress( addr), -1);
- valid_flag = address->valid();
- if ( valid_flag) {
- format_output();
- return 1; // ok, its a mac
- }
- break;
-
- case APPLETKLEN:
- ACE_NEW_RETURN(address, AppleTalkAddress( addr), -1);
- valid_flag = address->valid();
- if ( valid_flag) {
- format_output();
- return 1; // ok, its a mac
- }
- break;
-
- case DECNETLEN:
- ACE_NEW_RETURN(address, DecNetAddress( addr), -1);
- valid_flag = address->valid();
- if ( valid_flag) {
- format_output();
- return 1; // ok, its a mac
- }
- break;
-
- }
- // otherwise its invalid
- delete address;
- address = 0;
- format_output();
- return 0;
-}
-
-GenAddress::operator const char *() const
-{
- if ( address != 0)
- return (const char *)*address; // pass thru
- else
- return (char *)output_buffer;
-}
-
-// to_string form of the contained address
-char * GenAddress::to_string()
-{
- if ( address != 0)
- return address->to_string(); // pass thru
- else
- return (char *)output_buffer;
-}
-
-// format output
-void GenAddress::format_output()
-{
- output_buffer[0] = '\0';
-}
-
-//------[ return the type ]----------------------------------
-addr_type GenAddress::get_type() const
-{
- if (!valid())
- return type_invalid;
- else
- return address->get_type();
-}
-
-// call the particular type class here
-void GenAddress::to_octet(OctetStr& octet) const
-{
- if (!valid())
- return;
-
- address->to_octet(octet);
-}
-
-//------------------------------------------------------------------------
-//---------[ DecNet Address Class ]---------------------------------------
-//------------------------------------------------------------------------
-
-DecNetAddress::DecNetAddress( const char *inaddr): Address()
-{
- if (ACE_OS::strlen(inaddr) == 0) {
- // always initialize SMI info
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = DECNETLEN;
- smival.value.string.ptr = address_buffer;
-
- valid_flag=0;
- DecNetAddress::format_output();
- return;
- }
-
- // always initialize SMI info
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = DECNETLEN;
- smival.value.string.ptr = address_buffer;
-
- valid_flag = parse_address( (char *) inaddr);
- DecNetAddress::format_output();
-}
-
-DecNetAddress::DecNetAddress( const DecNetAddress&)
-{
-}
-
-DecNetAddress::DecNetAddress( const GenAddress& genaddr)
-{
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = DECNETLEN;
- smival.value.string.ptr = address_buffer;
-
- valid_flag = 0;
- // allow use of an ipx or ipxsock address
- if ( (genaddr.get_type() == type_decnet) ) {
- valid_flag = genaddr.valid();
- if ( valid_flag) {
- // copy in the Ipx address data
- DecNetAddress temp_ipx( (const char *) genaddr);
- *this = temp_ipx;
- }
- }
- DecNetAddress::format_output();
-}
-
-DecNetAddress::~DecNetAddress()
-{
-}
-
-char *DecNetAddress::to_string()
-{
- return (char *)output_buffer;
-}
-
-DecNetAddress& DecNetAddress::operator=( const DecNetAddress &decaddr)
-{
- // protect against assignment from itself
- if ( this == &decaddr )
- return *this;
- valid_flag = decaddr.valid_flag;
- if (valid_flag)
- ACE_OS::memcpy(address_buffer, decaddr.address_buffer, DECNETLEN);
- format_output();
- return *this;
-}
-
-void DecNetAddress::to_octet(OctetStr& octet) const
-{
- octet.set_data( smival.value.string.ptr, smival.value.string.len);
-}
-
-DecNetAddress::operator const char *() const
-{
- return (char *)output_buffer;
-}
-
-SmiUINT32 DecNetAddress::get_syntax()
-{
- return sNMP_SYNTAX_OCTETS;
-}
-
-SnmpSyntax& DecNetAddress::operator=( SnmpSyntax &val)
-{
- // protect against assignment from itself
- if ( this == &val )
- return *this;
-
- valid_flag = 0; // will get set 1 if really valid
-
- if (val.valid()) {
- if (((DecNetAddress &)val).smival.value.string.len ==DECNETLEN) {
- ACE_OS::memcpy(address_buffer,
- ((DecNetAddress &)val).smival.value.string.ptr, DECNETLEN);
- valid_flag = 1;
- }
- }
- DecNetAddress::format_output();
- return *this;
-}
-
-SnmpSyntax *DecNetAddress::clone() const
-{
- return (SnmpSyntax *) new DecNetAddress(*this);
-}
-
-addr_type DecNetAddress::get_type() const
-{
- return type_decnet;
-}
-
-void DecNetAddress::format_output()
-{
- // if valid format else null it
- if ( valid_flag)
- ACE_OS::sprintf( (char *) output_buffer,"%d.%d",address_buffer[0],
- address_buffer[1]);
- else
- output_buffer[0] = 0;
-}
-
-int DecNetAddress::parse_address( const char *address)
-{
- if (ACE_OS::strlen(address) > DECNETLEN)
- return 0; // invalid
-
- ACE_OS::memset(address_buffer, 0, DECNETLEN);
- ACE_OS::memcpy(address_buffer, address, DECNETLEN);
-
- return 1; // valid
-}
-
-
-//------------------------------------------------------------------------
-//---------[ AppleTalk Address Class ]------------------------------------
-//------------------------------------------------------------------------
-
-AppleTalkAddress::AppleTalkAddress( const char *inaddr): Address()
-{
- if (ACE_OS::strlen(inaddr) == 0) {
- // always initialize SMI info
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = APPLETKLEN;
- smival.value.string.ptr = address_buffer;
-
- valid_flag=0;
- AppleTalkAddress::format_output();
- return;
- }
-
- // always initialize SMI info
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = APPLETKLEN;
- smival.value.string.ptr = address_buffer;
-
- valid_flag = parse_address( (char *) inaddr);
- AppleTalkAddress::format_output();
-}
-AppleTalkAddress::AppleTalkAddress( const AppleTalkAddress&)
-{
-}
-
-AppleTalkAddress::AppleTalkAddress( const GenAddress& genaddr)
-{
- smival.syntax = sNMP_SYNTAX_OCTETS;
- smival.value.string.len = APPLETKLEN;
- smival.value.string.ptr = address_buffer;
-
- valid_flag = 0;
- // allow use of an ipx or ipxsock address
- if ( (genaddr.get_type() == type_atk) ) {
- valid_flag = genaddr.valid();
- if ( valid_flag) {
- // copy in the Ipx address data
- AppleTalkAddress temp_ipx( (const char *) genaddr);
- *this = temp_ipx;
- }
- }
- AppleTalkAddress::format_output();
-}
-
-AppleTalkAddress::~AppleTalkAddress()
-{
-}
-
-char *AppleTalkAddress::to_string()
-{
- return (char *)output_buffer;
-}
-
-AppleTalkAddress& AppleTalkAddress::operator=( const AppleTalkAddress &ataddr)
-{
- // protect against assignment from itself
- if ( this == &ataddr )
- return *this;
- valid_flag = ataddr.valid_flag;
- if (valid_flag)
- ACE_OS::memcpy(address_buffer, ataddr.address_buffer, APPLETKLEN);
- format_output();
- return *this;
-}
-
-void AppleTalkAddress::to_octet(OctetStr& octet) const
-{
- octet.set_data( smival.value.string.ptr, smival.value.string.len);
-}
-
-AppleTalkAddress::operator const char *() const
-{
- return (char *)output_buffer;
-}
-
-SmiUINT32 AppleTalkAddress::get_syntax()
-{
- return sNMP_SYNTAX_OCTETS;
-}
-
-SnmpSyntax& AppleTalkAddress::operator=( SnmpSyntax &val)
-{
- // protect against assignment from itself
- if ( this == &val )
- return *this;
-
- valid_flag = 0; // will get set 1 if really valid
-
- if (val.valid()) {
- if (((AppleTalkAddress &)val).smival.value.string.len ==APPLETKLEN) {
- ACE_OS::memcpy(address_buffer,
- ((AppleTalkAddress &)val).smival.value.string.ptr,APPLETKLEN);
- valid_flag = 1;
- }
- }
- AppleTalkAddress::format_output();
- return *this;
-}
-
-SnmpSyntax *AppleTalkAddress::clone() const
-{
- return (SnmpSyntax *) new AppleTalkAddress(*this);
-}
-
-addr_type AppleTalkAddress::get_type() const
-{
- return type_atk;
-}
-
-void AppleTalkAddress::format_output()
-{
- // if valid format else null it
- if ( valid_flag)
- ACE_OS::sprintf( (char *) output_buffer,"%d.%d.%d", address_buffer[0],
- address_buffer[1], address_buffer[3]);
- else
- output_buffer[0] = 0;
-}
-
-int AppleTalkAddress::parse_address( const char *address)
-{
- if (ACE_OS::strlen(address) > APPLETKLEN)
- return 0; // invalid
-
- ACE_OS::memset(address_buffer, 0, APPLETKLEN);
- ACE_OS::memcpy(address_buffer, address, APPLETKLEN);
-
- return 1; // valid
-}
-
-char AppleTalkAddress::get_host_address() const
-{
- return address_buffer[2];
-}
-
-void AppleTalkAddress::set_host_address(const char host)
-{
- address_buffer[2] = host;
-}
-
-short AppleTalkAddress::get_net_address() const
-{
- short net;
- ACE_OS::memcpy(&net, address_buffer, APPLETKLEN - 1);
- return net;
-}
-
-void AppleTalkAddress::set_net_address(const short atknet)
-{
- ACE_OS::memcpy(address_buffer, &atknet, APPLETKLEN -1);
-}
diff --git a/ASNMP/asnmp/address.h b/ASNMP/asnmp/address.h
deleted file mode 100644
index 5258304e109..00000000000
--- a/ASNMP/asnmp/address.h
+++ /dev/null
@@ -1,812 +0,0 @@
-/* -*-C++-*- */
-// $Id$
-#ifndef ADDRESS_
-#define ADDRESS_
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// address.h
-//
-// = DESCRIPTION
-// Address class definition. Encapsulates various network
-// addresses into easy to use, safe and portable classes.
-//
-// = AUTHOR
-// Peter E Mellquist
-//
-// ============================================================================
-
-/*===================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
-=====================================================================*/
-
-//----[ includes ]-----------------------------------------------------
-// ACE OS Adaption layer
-#include "ace/OS.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-# pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-#include "asnmp/smival.h"
-#include "asnmp/octet.h"
-
-//----[ enumerated types ] --------------------------------
-enum address_lengths {
- IPV4LEN=4,
- UDPIPV4LEN=6,
- IPV6LEN=16,
- UDPIPV6LEN=18,
- IPXLEN=10,
- IPXSOCKLEN=12,
- NETBIOSLEN=16,
- APPLETKLEN=3,
- DECNETLEN=2,
- MACLEN=6,
- HASH0=19,
- HASH1=13,
- HASH2=7,
- MAX_ADDR_SZ=20,
- MAX_DISPLAY_SZ=MAXHOSTNAMELEN+1
-};
-
-enum addr_type {
- type_ip,
- type_ipx,
- type_udp,
- type_ipxsock,
- type_mac,
- type_nb,
- type_atk,
- type_decnet,
- type_e164,
- type_sip, // IPv6
- type_invalid
-};
-
-// TODO: get rest of nb service types added here
-enum nb_service {
- nb_workstation = 0x0, nb_server = 0x20
-};
-
-//---[ forward declarations ]-----------------------------------------
-class GenAddress;
-class UdpAddress;
-class IpxSockAddress;
-class NetbiosAddress;
-class SIPAddress; // aka ipv6
-
-// TODO:
-// class AtmE164Address;
-
-
-//--------------------------------------------------------------------
-//----[ Address class ]-----------------------------------------------
-//--------------------------------------------------------------------
-class ACE_Export Address: public SnmpSyntax
- // = TITLE
- // Defines the member functions for the abstract base class
- // Address. An Address is a unique network endpoint.
-{
-
-public:
- virtual ~Address();
- // allow destruction of derived classes
-
- friend int operator==( const Address &lhs,const Address &rhs);
- // overloaded equivlence operator, are two addresses equal?
-
- friend int operator!=( const Address &lhs,const Address &rhs);
- // overloaded not equivlence operator, are two addresses not equal?
-
- friend int operator>( const Address &lhs,const Address &rhs);
- // overloaded > operator, is a1 > a2
-
- friend int operator>=( const Address &lhs,const Address &rhs);
- // overloaded >= operator, is a1 >= a2
-
- friend int operator<( const Address &lhs,const Address &rhs);
- // overloaded < operator, is a1 < a2
-
- friend int operator<=( const Address &lhs,const Address &rhs);
- // overloaded <= operator, is a1 <= a2
-
- friend int operator==( const Address &lhs,const char *rhs);
- // equivlence operator overloaded, are an address and a string equal?
-
- friend int operator!=( const Address &lhs,const char *rhs);
- // overloaded not equivlence operator, are an address and string not equal?
-
- friend int operator>( const Address &lhs,const char *rhs);
- // overloaded < , is an address greater than a string?
-
- friend int operator>=( const Address &lhs,const char *rhs);
- // overloaded >=, is an address greater than or equal to a string?
-
- friend int operator<( const Address &lhs,const char *rhs);
- // overloaded < , is an address less than a string?
-
- friend int operator<=( const Address &lhs,const char *rhs);
- // overloaded <=, is an address less than or equal to a string?
-
- virtual operator const char *() const = 0;
- // overloaded const char * cast
-
- virtual int valid() const;
- // verify the is the address object constructed ok
-
- virtual void to_octet(OctetStr& octet) const = 0;
- // return a suitable buffer to contain the address
-
- virtual SmiUINT32 get_syntax() = 0;
- // (pure virtual) syntax type
-
- unsigned char& operator[]( const int position);
- // for non const [], allows reading and writing
-
- virtual char *to_string() = 0;
- // get a printable ASCII value
-
- virtual SnmpSyntax *clone() const = 0;
- // create a new instance of this Value
-
- virtual addr_type get_type() const = 0;
- // return the type of address
-
- virtual SnmpSyntax& operator=( SnmpSyntax &val) = 0;
- // overloaded assignment operator
-
- virtual unsigned int hashFunction() const { return 0;};
- // return a hash key
-
-
-protected:
- int valid_flag;
- // state of constructed object (1/0)
- unsigned char address_buffer[MAX_ADDR_SZ];
- // addr internal representation
-
- virtual int parse_address( const char * inaddr) =0;
- // parse the address string
- // redefined for each specific address subclass
-
- virtual void format_output() =0;
- // format the output
- // redefined for each specific address subclass
-
- void trim_white_space( char * ptr);
- // a reused trimm white space method
-};
-
-
-//-----------------------------------------------------------------------
-//---------[ IPv4 Address Class ]----------------------------------------
-//-----------------------------------------------------------------------
-class ACE_Export IpAddress : public Address
- // = TITLE
- // Defines the member functions for the concrete class IpAddress
- // An IP Version 4 Address is 4 bytes long and consists of a
- // Network, Sub Network, and host component.
-{
-public:
- IpAddress( const char *inaddr = "");
- // default construct an IP address with a string
-
- IpAddress( const IpAddress &ipaddr);
- // construct an IP address with another IP address
-
- IpAddress( const GenAddress &genaddr);
- // construct an IP address with a GenAddress
-
- ~IpAddress();
- // destructor (ensure that SnmpSyntax::~SnmpSyntax() is overridden)
-
- SnmpSyntax& operator=( SnmpSyntax &val);
- // copy an instance of this Value
-
- IpAddress& operator=( const IpAddress &ipaddress);
- // assignment to another IpAddress object overloaded
-
- // TODO: add ability to set addr given long
-
- SnmpSyntax *clone() const;
- // create a new instance of this Value
-
- char *resolve_hostname(int& was_found);
- // return the DNS Fully Qualified Domain Name (host.domain)
- // on failure returns dotted_quad string
-
- virtual char *to_string() ;
- // return string representation of object (dotted quad returned)
-
- virtual operator const char *() const;
- // const char * operator overloaded for streaming output
-
- void mask( const IpAddress& ipaddr);
- // logically AND two IPaddresses and
- // return the new one
-
- virtual addr_type get_type() const;
- // return the type
-
- virtual SmiUINT32 get_syntax();
- // syntax type
-
- int is_loopback() const;
- // is this the loopback address? 127.0.0.1/loopback/1.0.0.127.in-addr.arpa
-
- int is_multicast() const;
- // determine if this is a multicast address
-
- int is_broadcast() const;
- // determine if this a broadcast address
-
- int is_private() const;
- // per RFC 1597, private addresses are:: 10, 172.16, and 192.168.0
-
- virtual void to_octet(OctetStr& octet) const;
- // convert address into octet string format in network byte order
-
-protected:
- char output_buffer[MAX_DISPLAY_SZ]; // output buffer
-
- char iv_friendly_name_[MAX_DISPLAY_SZ];
- // friendly name storage
-
- int iv_friendly_name_status_;
- // did resolver call work? some addrs won't resolve
-
- virtual int parse_address( const char *inaddr);
- // redefined parse address
- // specific to IP addresses
-
- virtual void format_output();
- // redefined format output
- // specific to IP addresses
-
- int parse_dotted_ipstring( const char *inaddr);
- // parse a dotted string
-
- int addr_to_friendly();
- // using the currently defined address, do a gethostbyname()
- // and try to fill up the name
-
- static int resolve_to_address(const char *hostname, in_addr& quad_addr);
- // thread safe routine to lookup ip address given hostname
- // return <> 0 on error
-
- static int resolve_to_hostname(const in_addr& quad_addr, char *hostname);
- // thread safe routine to lookup name given ip address
- // return <> 0 on error
-
-};
-
-//------------------------------------------------------------------------
-//--------------[ DNS Iterator Class ]------------------------------------
-//------------------------------------------------------------------------
-
-class ACE_Export Address_Iter
- // = TITLE
- // Defines routines to obtain information on a hostname/FQDN
- // such as multiple addresses
-{
-public:
- Address_Iter(const char *hostname); // fully qualified domain name, hostname
-
- int valid() const;
- // did hostname resolve via DNS?
-
- int how_many_addresses();
- // how many addresses associated with this hostname
-
- int next(IpAddress& addr);
- // return next address
-
-private:
- Address_Iter(const Address_Iter&);
- int valid_; // ctor status
- int count_; // number of addresses
- char **entry_; // ptr to current address
- struct hostent lookupResult_;
- ACE_HOSTENT_DATA buffer_;
- int query_dns(const char *hostname);
-};
-
-//------------------------------------------------------------------------
-//---------[ UDP/IPv4 Address Class ]-------------------------------------
-//------------------------------------------------------------------------
-class ACE_Export UdpAddress : public IpAddress
- // = TITLE
- // Defines the member functions for the concrete class UdpAddress
- // A Udp Address consists of an IP Version 4 Address (IpAddress)
- // and a 2 byte unsigned port number. (see /etc/services file)
- // User Datagram Protocol (UDP) is a best effort transport
-{
-public:
- UdpAddress( const char *inaddr = "");
- // default constructor with a dotted string in the form of addr:port
-
- UdpAddress( const UdpAddress &udpaddr);
- // construct an Udp address with another Udp address
-
- UdpAddress( const GenAddress &genaddr);
- // construct a Udp address with a GenAddress
-
- UdpAddress( const IpAddress &ipaddr);
- // construct a Udp address with an IpAddress
- // default port # to zero
-
- ~UdpAddress();
- // destructor
-
- SmiUINT32 get_syntax();
- // syntax type
-
- SnmpSyntax& operator=( SnmpSyntax &val);
- // copy an instance of this Value
-
- UdpAddress& operator=( const UdpAddress &udpaddr);
- // assignment to another IpAddress object overloaded
-
- SnmpSyntax *clone() const;
- // create a new instance of this Value
-
- virtual char *to_string() ;
- // output in the form of address:port
-
- virtual operator const char *() const;
- // const char * operator overloaded for streaming output
-
- void set_port( const unsigned short p);
- // set the port number
-
- unsigned short get_port() const;
- // get the port number
-
- virtual addr_type get_type() const;
- // return the type
-
-protected:
- char output_buffer[MAX_DISPLAY_SZ];
- // output buffer
-
- virtual int parse_address( const char *inaddr);
- // redefined parse address
- // specific to IP addresses
-
- virtual void format_output();
- // redefined format output
- // specific to IP addresses
-};
-
-
-//-------------------------------------------------------------------------
-//---------[ 802.3 MAC Address Class ]-------------------------------------
-//-------------------------------------------------------------------------
-class ACE_Export MacAddress : public Address
- // = TITLE
- // Defines the member functions for the concrete class MacAddress.
- // A Media Access Control Address consists of 48 bits as defined
- // in IEEE 802.3 specifications.
-{
-public:
- MacAddress( const char *inaddr = "");
- // constructor with a string argument
-
- MacAddress( const MacAddress &macaddr);
- // constructor with another MAC object
-
- MacAddress( const GenAddress &genaddr);
- // construct a MacAddress with a GenAddress
-
- ~MacAddress();
- // destructor
-
- SmiUINT32 get_syntax();
- // syntax type
-
- SnmpSyntax& operator=( SnmpSyntax &val);
- // copy an instance of this Value
-
- MacAddress& operator=( const MacAddress &macaddress);
- // assignment to another IpAddress object overloaded
-
- SnmpSyntax *clone() const;
- // create a new instance of this Value
-
- virtual char *to_string();
- // create a string to internal class storage representing object
-
- virtual operator const char *() const;
- // const char * operator overloaded for streaming output
-
- virtual addr_type get_type() const;
- // return the type
-
- unsigned int hashFunction() const;
- // return a hash key
-
- virtual void to_octet(OctetStr& octet) const;
- // return byte array of the mac address
-
-protected:
- char output_buffer[MAX_DISPLAY_SZ];
- // output buffer containing string representation of object
-
- virtual int parse_address( const char *inaddr);
- // redefined parse address for macs
-
- virtual void format_output();
- // redefined format output for MACs
-};
-
-//------------------------------------------------------------------------
-//---------[ Netbios Address Class ]--------------------------------------
-//------------------------------------------------------------------------
-class ACE_Export NetbiosAddress : public Address
- // = TITLE
- // Defines the member functions for the concrete class NetbiosAddress.
- // The IBM/Microsoft address for NETBIOS, NETBEUI protocol transport.
-{
-public:
-
- NetbiosAddress( const char *inaddr = "");
- // default constructor with string arg
-
- NetbiosAddress( const char *inaddr, nb_service svc);
- // set name and service type
-
- NetbiosAddress( const NetbiosAddress& nbaddr);
- // copy constructor
-
- NetbiosAddress( const GenAddress& genaddr);
- // construct with a GenAddress
-
- ~NetbiosAddress();
-
- virtual char *to_string();
-
- NetbiosAddress& operator=( const NetbiosAddress &nbaddr);
-
- nb_service get_service_type() const;
- // retrieve the network service type
-
- void set_service_type(nb_service nbservice);
- // set the service type (workstation, server, etc)
-
- virtual operator const char *() const;
- // const char * operator overloaded for streaming output
-
- virtual SmiUINT32 get_syntax();
- // syntax type
-
- SnmpSyntax& operator=( SnmpSyntax &val);
- // copy an instance of this Value
-
- SnmpSyntax *clone() const;
- // create a new instance of this Value
-
- virtual void to_octet(OctetStr& octet) const;
- // output byte buffer containing netbios name
-
-protected:
- void InitNBAddr(const char *inaddr);
- char output_buffer[MAX_DISPLAY_SZ];
-
- virtual void format_output();
- // output buffer to hold string representation
- virtual int parse_address( const char *inaddr);
- virtual addr_type get_type() const;
-};
-
-//------------------------------------------------------------------------
-//---------[ DecNet Address Class ]---------------------------------------
-//------------------------------------------------------------------------
-class ACE_Export DecNetAddress : public Address
- // = TITLE
- // Defines the member functions for the concrete class DecNetAddress.
- // DecNet Phase ? address consists of two octets (CISCO-TC.my)
-{
- public:
- DecNetAddress( const char *inaddr = "");
- // default constructor with string arg
-
- DecNetAddress( const DecNetAddress& decaddr);
- // copy constructor
-
- DecNetAddress( const GenAddress& genaddr);
- // construct with a GenAddress
-
- ~DecNetAddress();
-
- virtual char *to_string();
-
- DecNetAddress& operator=( const DecNetAddress &decaddr);
-
- virtual void to_octet(OctetStr& octet) const;
- // convert address into octet string format 2 bytes of decnet address
-
- virtual operator const char *() const;
- // const char * operator overloaded for streaming output
-
- virtual SmiUINT32 get_syntax();
- // syntax type
-
- SnmpSyntax& operator=( SnmpSyntax &val);
- // copy an instance of this Value
-
- SnmpSyntax *clone() const;
- // create a new instance of this Value
-
- protected:
- virtual int parse_address( const char *inaddr);
- virtual addr_type get_type() const;
- virtual void format_output();
- char output_buffer[MAX_DISPLAY_SZ];
-};
-
-//------------------------------------------------------------------------
-//---------[ AppleTalk Address Class ]------------------------------------
-//------------------------------------------------------------------------
-class ACE_Export AppleTalkAddress : public Address
- // = TITLE
- // Defines the member functions for the concrete class DecNetAddress.
- // DecNet Phase ? address consists of two octets (CISCO-TC.my)
-{
- public:
- AppleTalkAddress( const char *inaddr = "");
- // default constructor with string arg
-
- AppleTalkAddress( const AppleTalkAddress& atkaddr);
- // copy constructor
-
- AppleTalkAddress( const GenAddress& genaddr);
- // construct with a GenAddress
-
- ~AppleTalkAddress();
-
- virtual char *to_string();
-
- AppleTalkAddress& operator=( const AppleTalkAddress &atkaddr);
-
- virtual void to_octet(OctetStr& octet) const;
- // convert address into octet string format 3 bytes of atk address
-
- char get_host_address() const;
- // get the host part of the address
-
- void set_host_address(const char);
- // set the host part of the address
-
- short get_net_address() const;
- // get the 2 byte atk network address
-
- void set_net_address(const short atknet);
- // set the host 2 byte atk network address
-
- virtual operator const char *() const;
- // const char * operator overloaded for streaming output
-
- virtual SmiUINT32 get_syntax();
- // syntax type
-
- SnmpSyntax& operator=( SnmpSyntax &val);
- // copy an instance of this Value
-
- SnmpSyntax *clone() const;
- // create a new instance of this Value
-
- private:
- virtual int parse_address( const char *inaddr);
- virtual addr_type get_type() const;
- virtual void format_output();
- char output_buffer[MAX_DISPLAY_SZ];
-};
-
-//------------------------------------------------------------------------
-//---------[ IPX Address Class ]------------------------------------------
-//------------------------------------------------------------------------
-class ACE_Export IpxAddress : public Address
- // = TITLE
- // Defines the member functions for the concrete class IpxAddress.
- // Novell's IPX (version ?) network protocol endpoint
-{
-public:
- IpxAddress( const char *inaddr = "");
- // default constructor with a string arg
-
- IpxAddress( const IpxAddress &ipxaddr);
- // constructor with another ipx object
-
- IpxAddress( const GenAddress &genaddr);
- // construct with a GenAddress
-
- ~IpxAddress();
- // destructor
-
- virtual SmiUINT32 get_syntax();
- // syntax type
-
- SnmpSyntax& operator=( SnmpSyntax &val);
- // copy an instance of this Value
-
- IpxAddress& operator=( const IpxAddress &ipxaddress);
- // assignment to another IpxAddress object overloaded
-
- int get_hostid( MacAddress& mac);
- // get the host id portion of an ipx address
-
- SnmpSyntax *clone() const;
- // create a new instance of this Value
-
- virtual char *to_string();
- // create string represtation of object value
-
- virtual operator const char *() const;
- // const char * operator overloaded for streaming output
-
- virtual addr_type get_type() const;
- // return the type
-
- virtual void to_octet(OctetStr& octet) const;
- // return byte sequence containing ipx address
-
-protected:
- char separator;
- // ipx format separator {:,/}
-
- char output_buffer[MAX_DISPLAY_SZ];
- // output buffer to hold string representation
-
- virtual int parse_address( const char *inaddr);
- // redefined parse address for ipx strings
-
- virtual void format_output();
- // redefined format output for ipx strings
- // uses same separator as when constructed
-};
-
-
-
-//------------------------------------------------------------------------
-//---------[ IpxSock Address Class ]--------------------------------------
-//------------------------------------------------------------------------
-class ACE_Export IpxSockAddress : public IpxAddress
- // = TITLE
- // Defines the member functions for the concrete class IpxAddress.
- // Novell's IPX (version ?) network protocol endpoint
-{
-public:
- IpxSockAddress( const char *inaddr = "");
- // constructor with a dotted string
-
- IpxSockAddress( const IpxSockAddress &ipxaddr);
- // construct an Udp address with another Udp address
-
- IpxSockAddress( const GenAddress &genaddr);
- //constructor with a GenAddress
-
- IpxSockAddress( const IpxAddress &ipxaddr);
- //constructor with a IpxAddress
- // default socket # is 0
-
- ~IpxSockAddress();
- // destructor
-
- virtual SmiUINT32 get_syntax();
- // syntax type
-
- SnmpSyntax& operator=( SnmpSyntax &val);
- // copy an instance of this Value
-
- IpxSockAddress& operator=( const IpxSockAddress &ipxaddr);
- // assignment to another IpxAddress object overloaded
-
- SnmpSyntax *clone() const;
- // create a new instance of this Value
-
- void set_socket( const unsigned short s);
- // set the socket number
-
- unsigned short get_socket() const;
- // get the socket number
-
- virtual char *to_string();
- // create string representation of object value
-
- virtual operator const char *() const;
- // const char * operator overloaded for streaming output
-
- virtual addr_type get_type() const;
- // return the type
-
-protected:
- char output_buffer[MAX_DISPLAY_SZ];
- // output buffer to hold string representation of object
-
- virtual int parse_address( const char *inaddr);
- // redefined parse address for ipx strings
-
- virtual void format_output();
- // redefined format output
- // specific to IP addresses
-};
-
-//-------------------------------------------------------------------------
-//--------[ Generic Address ]----------------------------------------------
-//-------------------------------------------------------------------------
-class ACE_Export GenAddress : public Address
- // = TITLE
- // Defines the member functions for the concrete class GenAddress.
- // This class attempts to determine an address type given a char string.
-{
-public:
- GenAddress( const char *addr = "");
- // constructor with a string argument
-
- GenAddress( const Address &addr);
- // constructor with an Address
-
- GenAddress( const GenAddress &addr);
- // constructor with another GenAddress
-
- ~GenAddress();
- // destructor
-
- SmiUINT32 get_syntax();
- // get the snmp syntax of the contained address
-
- SnmpSyntax *clone() const;
- // create a new instance of this Value
-
- GenAddress& operator=( const GenAddress &addr);
- // assignment of a GenAddress
-
- SnmpSyntax& operator=( SnmpSyntax &val);
- // copy an instance of this Value
-
- virtual char *to_string();
- // string representation of object value
-
- virtual operator const char *() const;
- // const char * operator overloaded for streaming output
-
- virtual addr_type get_type() const;
- // return the type
-
- virtual void to_octet(OctetStr& octet) const;
- // return the address as a octet sequence
-
-protected:
- Address *address;
- // pointer to a a concrete address
-
- char output_buffer[MAX_DISPLAY_SZ];
- // output buffer of objects value
-
- virtual int parse_address( const char *addr);
- // redefined parse address for macs
-
- virtual void format_output();
- // format output for a generic address
-
- void init_smi();
- // initialize smi data structure
-};
-
-#endif //_ADDRESS
diff --git a/ASNMP/asnmp/asn1.cpp b/ASNMP/asnmp/asn1.cpp
deleted file mode 100644
index 77dc9baa5ec..00000000000
--- a/ASNMP/asnmp/asn1.cpp
+++ /dev/null
@@ -1,1728 +0,0 @@
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// asn1.cpp
-//
-// = DESCRIPTION
-// The Vb class is an encapsulation of the snmp variable binding.
-// This module contains the class definition for the variable binding (VB)
-// class. The VB class is an encapsulation of a SNMP VB. A VB object is
-// composed of one SNMP++ Oid and one SMI value. The Vb class utilizes Oid
-// objects and thus requires the Oid class. To use this class,
-// set oid, value then call valid() to be sure object was constructed correctly.
-//
-// = AUTHOR
-// S. Waldbusser (assumed)
-// Michael R MacFaden mrm@cisco.com - rework & ACE port
-// ============================================================================
-/**********************************************************************
-// *
- * Abstract Syntax Notation One, ASN.1
- * As defined in ISO/IS 8824 and ISO/IS 8825
- * This implements a subset of the above International Standards that
- * is sufficient to implement SNMP.
- *
- * Encodes abstract data types into a machine independent stream of bytes.
- *
- Copyright 1988, 1989, 1991, 1992 by Carnegie Mellon University
-
- All Rights Reserved
-
- Permission to use, copy, modify, and distribute this software and its
- documentation for any purpose and without fee is hereby granted,
- provided that the above copyright notice appear in all copies and that
- both that copyright notice and this permission notice appear in
- supporting documentation, and that the name of CMU not be
- used in advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
- CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
- ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- SOFTWARE.
- ******************************************************************/
-
-#include "asnmp/asn1.h"
-#include "asnmp/snmp.h"
-
-ACE_RCSID(asnmp, asn1, "$Id$")
-
-/*
- * parse_int - pulls a long out of an ASN int type.
- * On entry, datalength is input as the number of valid bytes following
- * "data". On exit, it is returned as the number of valid bytes
- * following the end of this object.
- *
- * Returns a pointer to the first byte past the end
- * of this object (i.e. the start of the next object).
- * Returns 0 on any error.
- */
-u_char * asn1::parse_int( u_char *data,
- int *datalength,
- u_char *type,
- long int *intp,
- int intsize)
-{
- ACE_TRACE("asn1::parse_int");
- /*
- * ASN.1 integer ::= 0x02 asnlength byte {byte}*
- */
- u_char *bufp = data;
- u_long asn_length;
- long value = 0;
-
- if (intsize != sizeof (long)){
- ASNERROR("not long");
- return 0;
- }
- *type = *bufp++;
- bufp =asn1::parse_length(bufp, &asn_length);
- if (bufp == 0){
- ASNERROR("bad length");
- return 0;
- }
- if ((int)(asn_length + (bufp - data)) > *datalength){
- ASNERROR("overflow of message");
- return 0;
- }
- if ((int)asn_length > intsize){
- ASNERROR("I don't support such large integers");
- return 0;
- }
- *datalength -= (int)asn_length + (bufp - data);
- if (*bufp & 0x80)
- value = -1; /* integer is negative */
- while(asn_length--)
- value = (value << 8) | *bufp++;
- *intp = value;
- return bufp;
-};
-
-
-/*
- * parse_unsigned_int - pulls an u_long out of an ASN int type.
- * On entry, datalength is input as the number of valid bytes following
- * "data". On exit, it is returned as the number of valid bytes
- * following the end of this object.
- *
- * Returns a pointer to the first byte past the end
- * of this object (i.e. the start of the next object).
- * Returns 0 on any error.
- */
-u_char * asn1::parse_unsigned_int( u_char *data,
- int *datalength,
- u_char *type,
- u_long *intp,
- int intsize)
-{
- ACE_TRACE("asn1::parse_unsigned_int");
- /*
- * ASN.1 integer ::= 0x02 asnlength byte {byte}*
- */
- u_char *bufp = data;
- u_long asn_length;
- u_long value = 0;
-
- if (intsize != sizeof (long)){
- ASNERROR("not long");
- return 0;
- }
- *type = *bufp++;
- bufp = asn1::parse_length(bufp, &asn_length);
- if (bufp == 0){
- ASNERROR("bad length");
- return 0;
- }
- if ((int)(asn_length + (bufp - data)) > *datalength){
- ASNERROR("overflow of message");
- return 0;
- }
- if (((int)asn_length > (intsize + 1)) ||
- (((int)asn_length == intsize + 1) && *bufp != 0x00)){
- ASNERROR("I don't support such large integers");
- return 0;
- }
- *datalength -= (int)asn_length + (bufp - data);
- if (*bufp & 0x80)
- value = (u_long) -1;
- while(asn_length--)
- value = (value << 8) | *bufp++;
- *intp = value;
- return bufp;
-};
-
-
-/*
- * build_int - builds an ASN object containing an integer.
- * On entry, datalength is input as the number of valid bytes following
- * "data". On exit, it is returned as the number of valid bytes
- * following the end of this object.
- *
- * Returns a pointer to the first byte past the end
- * of this object (i.e. the start of the next object).
- * Returns 0 on any error.
- */
-u_char * asn1::build_int( u_char *data,
- int *datalength,
- u_char type,
- long *intp,
- int intsize)
-{
- ACE_TRACE("asn1::build_int");
- /*
- * ASN.1 integer ::= 0x02 asnlength byte {byte}*
- */
-
- long integer;
- u_long mask;
-
- if (intsize != sizeof (long))
- return 0;
- integer = *intp;
- /*
- * Truncate "unnecessary" bytes off of the most significant end of this
- * 2's complement integer. There should be no sequence of 9
- * consecutive 1's or 0's at the most significant end of the
- * integer.
- */
- mask = 0x1FF << ((8 * (sizeof(long) - 1)) - 1);
- /* mask is 0xFF800000 on a big-endian machine */
- while((((integer & mask) == 0) || ((integer & mask) == mask))
- && intsize > 1){
- intsize--;
- integer <<= 8;
- }
- data = asn1::build_header(data, datalength, type, intsize);
- if (data == 0)
- return 0;
- if (*datalength < intsize)
- return 0;
- *datalength -= intsize;
- mask = 0xFF << (8 * (sizeof(long) - 1));
- /* mask is 0xFF000000 on a big-endian machine */
- while(intsize--){
- *data++ = (u_char)((integer & mask) >> (8 * (sizeof(long) - 1)));
- integer <<= 8;
- }
- return data;
-};
-
-
-/*
- * build_unsigned_int - builds an ASN object containing an integer.
- * On entry, datalength is input as the number of valid bytes following
- * "data". On exit, it is returned as the number of valid bytes
- * following the end of this object.
- *
- * Returns a pointer to the first byte past the end
- * of this object (i.e. the start of the next object).
- * Returns 0 on any error.
- */
-u_char * asn1::build_unsigned_int( u_char *data,
- int *datalength,
- u_char type,
- u_long *intp,
- int intsize)
-{
- ACE_TRACE("asn1::build_unsigned_int");
- /*
- * ASN.1 integer ::= 0x02 asnlength byte {byte}*
- */
-
- u_long integer;
- u_long mask;
- int add_null_byte = 0;
-
- if (intsize != sizeof (long))
- return 0;
- integer = *intp;
- mask = 0xFF << (8 * (sizeof(long) - 1));
- /* mask is 0xFF000000 on a big-endian machine */
- if ((u_char)((integer & mask) >> (8 * (sizeof(long) - 1))) & 0x80){
- /* if MSB is set */
- add_null_byte = 1;
- intsize++;
- }
- /*
- * Truncate "unnecessary" bytes off of the most significant end of this 2's complement integer.
- * There should be no sequence of 9 consecutive 1's or 0's at the most significant end of the
- * integer.
- */
- mask = 0x1FF << ((8 * (sizeof(long) - 1)) - 1);
- /* mask is 0xFF800000 on a big-endian machine */
- while((((integer & mask) == 0) || ((integer & mask) == mask)) && intsize > 1){
- intsize--;
- integer <<= 8;
- }
- data = asn1::build_header(data, datalength, type, intsize);
- if (data == 0)
- return 0;
- if (*datalength < intsize)
- return 0;
- *datalength -= intsize;
- if (add_null_byte == 1){
- *data++ = '\0';
- intsize--;
- }
- mask = 0xFF << (8 * (sizeof(long) - 1));
- /* mask is 0xFF000000 on a big-endian machine */
- while(intsize--){
- *data++ = (u_char)((integer & mask) >> (8 * (sizeof(long) - 1)));
- integer <<= 8;
- }
- return data;
-};
-
-
-/*
- * parse_string - pulls an octet string out of an ASN octet string type.
- * On entry, datalength is input as the number of valid bytes following
- * "data". On exit, it is returned as the number of valid bytes
- * following the beginning of the next object.
- *
- * "string" is filled with the octet string.
- *
- * Returns a pointer to the first byte past the end
- * of this object (i.e. the start of the next object).
- * Returns 0 on any error.
- */
-u_char * asn1::parse_string( u_char *data,
- int *datalength,
- u_char *type,
- u_char *string,
- int *strlength)
-{
- ACE_TRACE("asn1::parse_string");
- /*
- * ASN.1 octet string ::= primstring | cmpdstring
- * primstring ::= 0x04 asnlength byte {byte}*
- * cmpdstring ::= 0x24 asnlength string {string}*
- */
- u_char *bufp = data;
- u_long asn_length;
-
- *type = *bufp++;
- bufp = asn1::parse_length(bufp, &asn_length);
- if (bufp == 0)
- return 0;
- if ((int)(asn_length + (bufp - data)) > *datalength){
- ASNERROR("overflow of message");
- return 0;
- }
- if ((int)asn_length > *strlength){
- ASNERROR("I don't support such long strings");
- return 0;
- }
- // fixed
- ACE_OS::memcpy((char *)string, (char *)bufp, (int)asn_length);
- *strlength = (int)asn_length;
- *datalength -= (int)asn_length + (bufp - data);
- return bufp + asn_length;
-};
-
-
-/*
- * build_string - Builds an ASN octet string object containing the input string.
- * On entry, datalength is input as the number of valid bytes following
- * "data". On exit, it is returned as the number of valid bytes
- * following the beginning of the next object.
- *
- * Returns a pointer to the first byte past the end
- * of this object (i.e. the start of the next object).
- * Returns 0 on any error.
- */
-u_char * asn1::build_string( u_char *data,
- int *datalength,
- u_char type,
- u_char *string,
- int strlength)
-{
- ACE_TRACE("asn1::build_string");
- /*
- * ASN.1 octet string ::= primstring | cmpdstring
- * primstring ::= 0x04 asnlength byte {byte}*
- * cmpdstring ::= 0x24 asnlength string {string}*
- * This code will never send a compound string.
- */
- data = asn1::build_header(data, datalength, type, strlength);
- if (data == 0)
- return 0;
- if (*datalength < strlength)
- return 0;
- // fixed
- ACE_OS::memcpy((u_char *)data,(u_char *)string, strlength);
- *datalength -= strlength;
- return data + strlength;
-};
-
-
-/*
- * parse_header - interprets the ID and length of the current object.
- * On entry, datalength is input as the number of valid bytes following
- * "data". On exit, it is returned as the number of valid bytes
- * in this object following the id and length.
- *
- * Returns a pointer to the first byte of the contents of this object.
- * Returns 0 on any error.
- */
-u_char *asn1::parse_header( u_char *data,
- int *datalength,
- u_char *type)
-{
- ACE_TRACE("asn1::parse_header");
- u_char *bufp = data;
- register int header_len;
- u_long asn_length;
-
- /* this only works on data types < 30, i.e. no extension octets */
- if (IS_EXTENSION_ID(*bufp)){
- ASNERROR("can't process ID >= 30");
- return 0;
- }
- *type = *bufp;
- bufp = asn1::parse_length(bufp + 1, &asn_length);
- if (bufp == 0)
- return 0;
- header_len = bufp - data;
- if ((int)(header_len + asn_length) > *datalength){
- ASNERROR("asn length too long");
- return 0;
- }
- *datalength = (int)asn_length;
- return bufp;
-}
-
-/*
- * asn1::build_header - builds an ASN header for an object with the ID and
- * length specified.
- * On entry, datalength is input as the number of valid bytes following
- * "data". On exit, it is returned as the number of valid bytes
- * in this object following the id and length.
- *
- * This only works on data types < 30, i.e. no extension octets.
- * The maximum length is 0xFFFF;
- *
- * Returns a pointer to the first byte of the contents of this object.
- * Returns 0 on any error.
- */
-u_char * asn1::build_header( u_char *data,
- int *datalength,
- u_char type,
- int length)
-{
- ACE_TRACE("asn1::build_header");
- if (*datalength < 1)
- return 0;
- *data++ = type;
- (*datalength)--;
- return asn1::build_length(data, datalength, length);
-
-}
-
-/*
- * asn_build_sequence - builds an ASN header for a sequence with the ID and
- * length specified.
- * On entry, datalength is input as the number of valid bytes following
- * "data". On exit, it is returned as the number of valid bytes
- * in this object following the id and length.
- *
- * This only works on data types < 30, i.e. no extension octets.
- * The maximum length is 0xFFFF;
- *
- * Returns a pointer to the first byte of the contents of this object.
- * Returns 0 on any error.
- */
-u_char * asn1::build_sequence( u_char *data,
- int *datalength,
- u_char type,
- int length)
-{
- ACE_TRACE("asn1::build_sequence");
- *datalength -= 4;
- if (*datalength < 0){
- *datalength += 4; /* fix up before punting */
- return 0;
- }
- *data++ = type;
- *data++ = (u_char)(0x02 | ASN_LONG_LEN);
- *data++ = (u_char)((length >> 8) & 0xFF);
- *data++ = (u_char)(length & 0xFF);
- return data;
-};
-
-/*
- * parse_length - interprets the length of the current object.
- * On exit, length contains the value of this length field.
- *
- * Returns a pointer to the first byte after this length
- * field (aka: the start of the data field).
- * Returns 0 on any error.
- */
-u_char * asn1::parse_length( u_char *data,
- u_long *length)
-{
- ACE_TRACE("asn1::parse_length");
- u_char lengthbyte = *data;
-
- if (lengthbyte & ASN_LONG_LEN){
- lengthbyte &= ~ASN_LONG_LEN; /* turn MSb off */
- if (lengthbyte == 0){
- ASNERROR("We don't support indefinite lengths");
- return 0;
- }
- if (lengthbyte > sizeof(long)){
- ASNERROR("we can't support data lengths that long");
- return 0;
- }
- // fixed
- ACE_OS::memcpy((char *)length, (char *)data + 1, (int)lengthbyte);
- *length = ntohl(*length);
- *length >>= (8 * ((sizeof *length) - lengthbyte));
- return data + lengthbyte + 1;
- } else { /* short asnlength */
- *length = (long)lengthbyte;
- return data + 1;
- }
-};
-
-u_char *asn1::build_length( u_char *data,
- int *datalength,
- int length)
-{
- ACE_TRACE("asn1::build_length");
- u_char *start_data = data;
-
- /* no indefinite lengths sent */
- if (length < 0x80){
- if (*datalength < 1){
- ASNERROR("build_length");
- return 0;
- }
- *data++ = (u_char)length;
- } else if (length <= 0xFF){
- if (*datalength < 2){
- ASNERROR("build_length");
- return 0;
- }
- *data++ = (u_char)(0x01 | ASN_LONG_LEN);
- *data++ = (u_char)length;
- } else { /* 0xFF < length <= 0xFFFF */
- if (*datalength < 3){
- ASNERROR("build_length");
- return 0;
- }
- *data++ = (u_char)(0x02 | ASN_LONG_LEN);
- *data++ = (u_char)((length >> 8) & 0xFF);
- *data++ = (u_char)(length & 0xFF);
- }
- *datalength -= (data - start_data);
- return data;
-
-}
-
-/*
- * parse_objid - pulls an object indentifier out of an ASN object identifier type.
- * On entry, datalength is input as the number of valid bytes following
- * "data". On exit, it is returned as the number of valid bytes
- * following the beginning of the next object.
- *
- * "objid" is filled with the object identifier.
- *
- * Returns a pointer to the first byte past the end
- * of this object (i.e. the start of the next object).
- * Returns 0 on any error.
- */
-u_char *asn1::parse_objid( u_char *data,
- int *datalength,
- u_char *type,
- oid *objid,
- int *objidlength)
-{
- ACE_TRACE("asn1::parse_objid");
- /*
- * ASN.1 objid ::= 0x06 asnlength subidentifier {subidentifier}*
- * subidentifier ::= {leadingbyte}* lastbyte
- * leadingbyte ::= 1 7bitvalue
- * lastbyte ::= 0 7bitvalue
- */
- u_char *bufp = data;
- oid *oidp = objid + 1;
- u_long subidentifier;
- long length;
- u_long asn_length;
-
- *type = *bufp++;
- bufp = asn1::parse_length(bufp, &asn_length);
- if (bufp == 0)
- return 0;
- if ((int)asn_length + (bufp - data) > *datalength){
- ASNERROR("overflow of message");
- return 0;
- }
- *datalength -= (int)asn_length + (bufp - data);
-
- /* Handle invalid object identifier encodings of the form 06 00 robustly */
- if (asn_length == 0)
- objid[0] = objid[1] = 0;
-
- length = asn_length;
- (*objidlength)--; /* account for expansion of first byte */
- while (length > 0 && (*objidlength)-- > 0){
- subidentifier = 0;
- do { /* shift and add in low order 7 bits */
- subidentifier = (subidentifier << 7) + (*(u_char *)bufp & ~ASN_BIT8);
- length--;
- } while (*(u_char *)bufp++ & ASN_BIT8); /* last byte has high bit clear */
- if (subidentifier > (u_long)MAX_SUBID){
- ASNERROR("subidentifier too long");
- return 0;
- }
- *oidp++ = (oid)subidentifier;
- }
-
- /*
- * The first two subidentifiers are encoded into the first component
- * with the value (X * 40) + Y, where:
- * X is the value of the first subidentifier.
- * Y is the value of the second subidentifier.
- */
- subidentifier = (u_long)objid[1];
- if (subidentifier == 0x2B){
- objid[0] = 1;
- objid[1] = 3;
- } else {
- objid[1] = (u_char)(subidentifier % 40);
- objid[0] = (u_char)((subidentifier - objid[1]) / 40);
- }
-
- *objidlength = (int)(oidp - objid);
- return bufp;
-}
-
-/*
- * build_objid - Builds an ASN object identifier object containing the
- * input string.
- * On entry, datalength is input as the number of valid bytes following
- * "data". On exit, it is returned as the number of valid bytes
- * following the beginning of the next object.
- *
- * Returns a pointer to the first byte past the end
- * of this object (i.e. the start of the next object).
- * Returns 0 on any error.
- */
-u_char *asn1::build_objid( u_char *data,
- int *datalength,
- u_char type,
- oid *objid,
- int objidlength)
-{
- ACE_TRACE("asn1::build_objid");
- /*
- * ASN.1 objid ::= 0x06 asnlength subidentifier {subidentifier}*
- * subidentifier ::= {leadingbyte}* lastbyte
- * leadingbyte ::= 1 7bitvalue
- * lastbyte ::= 0 7bitvalue
- */
- u_char buf[MAX_OID_LEN];
- u_char *bp = buf;
- oid *op = objid;
- int asnlength;
- u_long subid, mask, testmask;
- int bits, testbits;
-
- if (objidlength < 2){
- *bp++ = 0;
- objidlength = 0;
- } else {
- *bp++ = (u_char) (op[1] + (op[0] * 40));
- objidlength -= 2;
- op += 2;
- }
-
- while(objidlength-- > 0){
- subid = *op++;
- if (subid < 127){ /* off by one? */
- *bp++ = (u_char )subid;
- } else {
- mask = 0x7F; /* handle subid == 0 case */
- bits = 0;
- /* testmask *MUST* !!!! be of an u_type */
- for(testmask = 0x7F, testbits = 0; testmask != 0;
- testmask <<= 7, testbits += 7){
- if (subid & testmask){ /* if any bits set */
- mask = testmask;
- bits = testbits;
- }
- }
- /* mask can't be zero here */
- for(;mask != 0x7F; mask >>= 7, bits -= 7){
- /* fix a mask that got truncated above */
- if (mask == 0x1E00000)
- mask = 0xFE00000;
- *bp++ = (u_char)(((subid & mask) >> bits) | ASN_BIT8);
- }
- *bp++ = (u_char)(subid & mask);
- }
- }
- asnlength = bp - buf;
- data = asn1::build_header(data, datalength, type, asnlength);
- if (data == 0)
- return 0;
- if (*datalength < asnlength)
- return 0;
- // fixed
- ACE_OS::memcpy((char *)data, (char *)buf, asnlength);
- *datalength -= asnlength;
- return data + asnlength;
-}
-
-/*
- * parse_null - Interprets an ASN null type.
- * On entry, datalength is input as the number of valid bytes following
- * "data". On exit, it is returned as the number of valid bytes
- * following the beginning of the next object.
- *
- * Returns a pointer to the first byte past the end
- * of this object (i.e. the start of the next object).
- * Returns 0 on any error.
- */
-u_char *asn1::parse_null(u_char *data,
- int *datalength,
- u_char *type)
-{
- ACE_TRACE("asn1::parse_null");
- /*
- * ASN.1 null ::= 0x05 0x00
- */
- u_char *bufp = data;
- u_long asn_length;
-
- *type = *bufp++;
- bufp = asn1::parse_length(bufp, &asn_length);
- if (bufp == 0)
- return 0;
- if (asn_length != 0){
- ASNERROR("Malformed 0");
- return 0;
- }
- *datalength -= (bufp - data);
- return bufp + asn_length;
-}
-
-
-/*
- * build_null - Builds an ASN null object.
- * On entry, datalength is input as the number of valid bytes following
- * "data". On exit, it is returned as the number of valid bytes
- * following the beginning of the next object.
- *
- * Returns a pointer to the first byte past the end
- * of this object (i.e. the start of the next object).
- * Returns 0 on any error.
- */
-u_char *asn1::build_null( u_char *data,
- int *datalength,
- u_char type)
-{
- ACE_TRACE("asn1::build_null");
- /*
- * ASN.1 null ::= 0x05 0x00
- */
- return asn1::build_header(data, datalength, type, 0);
-};
-
-/*
- * parse_bitstring - pulls a bitstring out of an ASN bitstring type.
- * On entry, datalength is input as the number of valid bytes following
- * "data". On exit, it is returned as the number of valid bytes
- * following the beginning of the next object.
- *
- * "string" is filled with the bit string.
- *
- * Returns a pointer to the first byte past the end
- * of this object (i.e. the start of the next object).
- * Returns 0 on any error.
- */
-u_char *asn1::parse_bitstring( u_char *data,
- int *datalength,
- u_char *type,
- u_char *string,
- int *strlength)
-{
- ACE_TRACE("asn1::parse_bitstring");
- /*
- * bitstring ::= 0x03 asnlength unused {byte}*
- */
- u_char *bufp = data;
- u_long asn_length;
-
- *type = *bufp++;
- bufp = asn1::parse_length(bufp, &asn_length);
- if (bufp == 0)
- return 0;
- if ((int)(asn_length + (bufp - data)) > *datalength){
- ASNERROR("overflow of message");
- return 0;
- }
- if ((int) asn_length > *strlength){
- ASNERROR("I don't support such long bitstrings");
- return 0;
- }
- if (asn_length < 1){
- ASNERROR("Invalid bitstring");
- return 0;
- }
- if (*bufp > 7){
- ASNERROR("Invalid bitstring");
- return 0;
- }
- // fixed
- ACE_OS::memcpy((char *)string,(char *)bufp, (int)asn_length);
- *strlength = (int)asn_length;
- *datalength -= (int)asn_length + (bufp - data);
- return bufp + asn_length;
-}
-
-
-/*
- * build_bitstring - Builds an ASN bit string object containing the
- * input string.
- * On entry, datalength is input as the number of valid bytes following
- * "data". On exit, it is returned as the number of valid bytes
- * following the beginning of the next object.
- *
- * Returns a pointer to the first byte past the end
- * of this object (i.e. the start of the next object).
- * Returns 0 on any error.
- */
-u_char *asn1::build_bitstring( u_char *data,
- int *datalength,
- u_char type,
- u_char *string,
- int strlength)
-{
- ACE_TRACE("asn1::build_bitstring");
- /*
- * ASN.1 bit string ::= 0x03 asnlength unused {byte}*
- */
- if (strlength < 1 || *string || *string > 7){
- ASNERROR("Building invalid bitstring");
- return 0;
- }
- data = asn1::build_header(data, datalength, type, strlength);
- if (data == 0)
- return 0;
- if (*datalength < strlength)
- return 0;
- // fixed
- ACE_OS::memcpy((char *)data,(char *)string, strlength);
- *datalength -= strlength;
- return data + strlength;
-}
-
-
-/*
- * parse_unsigned_int64 - pulls a 64 bit u_long out of an ASN int
- * type.
- * On entry, datalength is input as the number of valid bytes following
- * "data". On exit, it is returned as the number of valid bytes
- * following the end of this object.
- *
- * Returns a pointer to the first byte past the end
- * of this object (i.e. the start of the next object).
- * Returns 0 on any error.
- */
-u_char * asn1::parse_unsigned_int64(u_char *data,
- int *datalength,
- u_char *type,
- struct counter64 *cp,
- int countersize)
-{
- ACE_TRACE("asn1::parse_unsigned_int64");
- /*
- * ASN.1 integer ::= 0x02 asnlength byte {byte}*
- */
- u_char *bufp = data;
- u_long asn_length;
- u_long low = 0, high = 0;
- int intsize = 4;
-
- if (countersize != sizeof(struct counter64)){
- ASNERROR("not right size");
- return 0;
- }
- *type = *bufp++;
- bufp = asn1::parse_length(bufp, &asn_length);
- if (bufp == 0){
- ASNERROR("bad length");
- return 0;
- }
- if ((int)(asn_length + (bufp - data)) > *datalength){
- ASNERROR("overflow of message");
- return 0;
- }
- if (((int)asn_length > (intsize * 2 + 1)) ||
- (((int)asn_length == (intsize * 2) + 1) && *bufp != 0x00)){
- ASNERROR("I don't support such large integers");
- return 0;
- }
- *datalength -= (int)asn_length + (bufp - data);
- if (*bufp & 0x80){
- low = (u_long) -1; // integer is negative
- high = (u_long) -1;
- }
- while(asn_length--){
- high = (high << 8) | ((low & 0xFF000000) >> 24);
- low = (low << 8) | *bufp++;
- }
- cp->low = low;
- cp->high = high;
- return bufp;
-}
-
-
-/*
- * build_unsigned_int64 - builds an ASN object containing a 64 bit integer.
- * On entry, datalength is input as the number of valid bytes following
- * "data". On exit, it is returned as the number of valid bytes
- * following the end of this object.
- *
- * Returns a pointer to the first byte past the end
- * of this object (i.e. the start of the next object).
- * Returns 0 on any error.
- */
-u_char * asn1::build_unsigned_int64( u_char *data,
- int *datalength,
- u_char type,
- struct counter64 *cp,
- int countersize)
-{
- ACE_TRACE("asn1::build_unsigned_int64");
- /*
- * ASN.1 integer ::= 0x02 asnlength byte {byte}*
- */
-
- u_long low, high;
- u_long mask, mask2;
- int add_null_byte = 0;
- int intsize;
-
- if (countersize != sizeof (struct counter64))
- return 0;
- intsize = 8;
- low = cp->low;
- high = cp->high;
- mask = 0xFF << (8 * (sizeof(long) - 1));
- /* mask is 0xFF000000 on a big-endian machine */
- if ((u_char)((high & mask) >> (8 * (sizeof(long) - 1))) & 0x80){
- /* if MSB is set */
- add_null_byte = 1;
- intsize++;
- }
- /*
- * Truncate "unnecessary" bytes off of the most significant end of this 2's
- * complement integer.
- * There should be no sequence of 9 consecutive 1's or 0's at the most
- * significant end of the integer.
- */
- mask2 = 0x1FF << ((8 * (sizeof(long) - 1)) - 1);
- /* mask2 is 0xFF800000 on a big-endian machine */
- while((((high & mask2) == 0) || ((high & mask2) == mask2))
- && intsize > 1){
- intsize--;
- high = (high << 8)
- | ((low & mask) >> (8 * (sizeof(long) - 1)));
- low <<= 8;
- }
- data = asn1::build_header(data, datalength, type, intsize);
- if (data == 0)
- return 0;
- if (*datalength < intsize)
- return 0;
- *datalength -= intsize;
- if (add_null_byte == 1){
- *data++ = '\0';
- intsize--;
- }
- while(intsize--){
- *data++ = (u_char)((high & mask) >> (8 * (sizeof(long) - 1)));
- high = (high << 8)
- | ((low & mask) >> (8 * (sizeof(long) - 1)));
- low <<= 8;
-
- }
- return data;
-}
-
-
-// create a pdu
-struct snmp_pdu * cmu_snmp::pdu_create( int command)
-{
- ACE_TRACE("cmu_snmp::snmp_pdu_create");
- struct snmp_pdu *pdu;
-
- ACE_NEW_RETURN(pdu, snmp_pdu, 0);
- ACE_OS::memset((char *)pdu, 0,sizeof(struct snmp_pdu));
- pdu->command = command;
- pdu->errstat = 0;
- pdu->errindex = 0;
- pdu->enterprise = 0;
- pdu->enterprise_length = 0;
- pdu->variables = 0;
- return pdu;
-}
-
-// release a pdu from memory
-void cmu_snmp::free_pdu( struct snmp_pdu *pdu)
-{
- ACE_TRACE("cmu_snmp::free_pdu");
- struct variable_list *vp, *ovp;
-
- vp = pdu->variables;
- while(vp){
- // release the oid part
- if (vp->name)
- delete [] vp->name;
- // if deep data, then release as well
- if (vp->val.string)
- delete [] vp->val.string;
- ovp = vp;
- // go to the next one
- vp = vp->next_variable;
- // release up vb itself
- delete ovp;
- }
- // if enterprise release it up
- if (pdu->enterprise)
- delete [] pdu->enterprise;
- // release up pdu itself
- delete pdu;
-}
-
-
-// add a null var to a pdu
-void cmu_snmp::add_var(struct snmp_pdu *pdu,
- oid *name,
- int name_length,
- SmiVALUE *smival)
-{
- ACE_TRACE("cmu_snmp::add_var");
-
- struct variable_list *vars;
-
- // if we don't have a vb list ,create one
- if (pdu->variables == 0) {
- ACE_NEW(pdu->variables, variable_list);
- vars = pdu->variables;
- }
- else
- { // we have one, find the end
- for(vars = pdu->variables; vars->next_variable; vars = vars->next_variable);
- // create one
- ACE_NEW(vars->next_variable, variable_list);
- // bump ptr
- vars = vars->next_variable;
- }
-
- // add the oid with no data
- vars->next_variable = 0;
-
- // hook in the Oid portion
- ACE_NEW(vars->name, oid[(name_length)]);
-
- // fixed
- ACE_OS::memcpy((char *)vars->name,(char *)name, name_length * sizeof(oid));
- vars->name_length = name_length;
-
- // hook in the SMI value
- switch( smival->syntax)
- {
- // null , do nothing
- case sNMP_SYNTAX_NULL:
- case sNMP_SYNTAX_NOSUCHOBJECT:
- case sNMP_SYNTAX_NOSUCHINSTANCE:
- case sNMP_SYNTAX_ENDOFMIBVIEW:
- {
- vars->type = (u_char) smival->syntax;
- vars->val.string = 0;
- vars->val_len = 0;
- }
- break;
-
- // octects
- case sNMP_SYNTAX_OCTETS:
- case sNMP_SYNTAX_OPAQUE:
- case sNMP_SYNTAX_IPADDR:
- {
- vars->type = (u_char) smival->syntax;
- ACE_NEW(vars->val.string,
- u_char[(unsigned)smival->value.string.len]);
- vars->val_len = (int) smival->value.string.len;
- ACE_OS::memcpy( (u_char *) vars->val.string,
- (u_char *) smival->value.string.ptr,
- (unsigned) smival->value.string.len);
- }
- break;
-
- // oid
- case sNMP_SYNTAX_OID:
- {
- vars->type = (u_char) smival->syntax;
- vars->val_len = (int) smival->value.oid.len * sizeof(oid);
- ACE_NEW(vars->val.objid, oid[(unsigned)vars->val_len]);
- ACE_OS::memcpy((u_long *)vars->val.objid,
- (u_long *)smival->value.oid.ptr,
- (unsigned) vars->val_len);
- }
- break;
-
-
-
- case sNMP_SYNTAX_TIMETICKS:
- case sNMP_SYNTAX_CNTR32:
- case sNMP_SYNTAX_GAUGE32:
- case sNMP_SYNTAX_UINT32:
- {
- long templong;
- vars->type = (u_char) smival->syntax;
- ACE_NEW(vars->val.integer, long);
- vars->val_len = sizeof(long);
- templong = (long) smival->value.uNumber;
- ACE_OS::memcpy( (long*) vars->val.integer,
- (long*) &templong,
- sizeof(long));
- }
- break;
-
- case sNMP_SYNTAX_INT32:
- {
- long templong;
- vars->type = (u_char) smival->syntax;
- ACE_NEW(vars->val.integer, long);
- vars->val_len = sizeof(long);
- templong = (long) smival->value.sNumber;
- ACE_OS::memcpy( (long*) vars->val.integer,
- (long*) &templong,
- sizeof(long));
- }
- break;
-
- // 64 bit counter
- case sNMP_SYNTAX_CNTR64:
- {
- vars->type = ( u_char) smival->syntax;
- ACE_NEW(vars->val.counter64, counter64);
- vars->val_len = sizeof(struct counter64);
- ACE_OS::memcpy( (struct counter64*) vars->val.counter64,
- (SmiLPCNTR64) &(smival->value.hNumber),
- sizeof( SmiCNTR64));
- }
- break;
-
- } // end switch
-
-}
-
-// build the authentication
-// works for v1 or v2c
-u_char *cmu_snmp::auth_build( u_char *data,
- int *length,
- long int version,
- u_char *community,
- int community_len,
- int messagelen)
-{
- ACE_TRACE("cmu_snmp::auth_build");
- u_char *params;
- int plen;
-
- params = community;
- plen = community_len;
-
- data = asn1::build_sequence(data,
- length,
- (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR),
- messagelen + plen + 5);
- if (data == 0){
- ASNERROR("buildheader");
- return 0;
- }
- data = asn1::build_int(data,
- length,
- (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
- (long *)&version,
- sizeof(version));
- if (data == 0){
- ASNERROR("buildint");
- return 0;
- }
-
- data = asn1::build_string(data,
- length,
- (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR),
- params,
- plen );
- if (data == 0){
- ASNERROR("buildstring");
- return 0;
- }
-
- return (u_char *)data;
-};
-
-
-// build a variable binding
-u_char * cmu_snmp::build_var_op(u_char *data, oid * var_name,
- int *var_name_len,
- u_char var_val_type,
- int var_val_len, u_char *var_val,
- int *listlength)
-
-{
- ACE_TRACE("cmu_snmp::build_var_op");
- int dummyLen, headerLen;
- u_char *dataPtr;
-
- dummyLen = *listlength;
- dataPtr = data;
-
- data += 4;
- dummyLen -=4;
- if (dummyLen < 0)
- return 0;
-
- headerLen = data - dataPtr;
- *listlength -= headerLen;
- data = asn1::build_objid( data, listlength,
- (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OBJECT_ID),
- var_name, *var_name_len);
- if (data == 0) {
- ASNERROR("");
- return 0;
- }
-
- // based on the type...
- switch(var_val_type) {
- case ASN_INTEGER:
- data = asn1::build_int( data, listlength, var_val_type, (long *)var_val,
- var_val_len);
- break;
-
- case SMI_GAUGE:
- case SMI_COUNTER:
- case SMI_TIMETICKS:
- case SMI_UINTEGER:
- data = asn1::build_unsigned_int( data,
- listlength,
- var_val_type,
- (u_long *)var_val,
- var_val_len);
- break;
-
- case SMI_COUNTER64:
- data = asn1::build_unsigned_int64(data,
- listlength,
- var_val_type,
- (struct counter64 *)var_val,
- var_val_len);
- break;
-
- case ASN_OCTET_STR:
- case SMI_IPADDRESS:
- case SMI_OPAQUE:
- case SMI_NSAP:
- data = asn1::build_string(data, listlength, var_val_type,
- var_val, var_val_len);
- break;
-
- case ASN_OBJECT_ID:
- data = asn1::build_objid(data, listlength, var_val_type,
- (oid *)var_val, var_val_len / sizeof(oid));
- break;
-
- case ASN_NULL:
- data = asn1::build_null(data, listlength, var_val_type);
- break;
-
- case ASN_BIT_STR:
- data = asn1::build_bitstring(data, listlength, var_val_type,
- var_val, var_val_len);
- break;
-
- case SNMP_NOSUCHOBJECT:
- case SNMP_NOSUCHINSTANCE:
- case SNMP_ENDOFMIBVIEW:
- data = asn1::build_null(data, listlength, var_val_type);
- break;
-
- default:
- ASNERROR("wrong type");
- return 0;
- }
- if (data == 0) {
- ASNERROR("");
- return 0;
- }
- dummyLen = (data - dataPtr) - headerLen;
-
- asn1::build_sequence(dataPtr, &dummyLen,
- (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR),
- dummyLen);
- return data;
-}
-
-
-// serialize the pdu
-int cmu_snmp::build( struct snmp_pdu *pdu, u_char *packet,
- int *out_length, long version,
- u_char* community, int community_len)
-{
- ACE_TRACE("cmu_snmp::build");
- u_char buf[SNMP_MSG_LENGTH];
- u_char *cp;
- struct variable_list *vp;
- int length;
- int totallength;
-
- length = *out_length;
- cp = packet;
- for(vp = pdu->variables; vp; vp = vp->next_variable) {
- cp = cmu_snmp::build_var_op( cp, vp->name,
- &vp->name_length, vp->type,
- vp->val_len, (u_char *)vp->val.string,
- &length);
- if (cp == 0)
- return -1;
- }
- totallength = cp - packet;
-
- length = SNMP_MSG_LENGTH;
-
- // encode the total len
- cp = asn1::build_header( buf, &length,
- (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR),
- totallength);
- if (cp == 0)
- return -1;
- ACE_OS::memcpy( (char *)cp, (char *)packet,totallength);
- totallength += cp - buf;
-
- length = *out_length;
- if (pdu->command != TRP_REQ_MSG) {
-
- // request id
- cp = asn1::build_int( packet,
- &length,
- (u_char )(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
- (long *)&pdu->reqid,
- sizeof(pdu->reqid));
- if (cp == 0)
- return -1;
-
- // error status
- cp = asn1::build_int(cp,
- &length,
- (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
- (long *)&pdu->errstat, sizeof(pdu->errstat));
- if (cp == 0)
- return -1;
-
- // error index
- cp = asn1::build_int(cp,
- &length,
- (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
- (long *)&pdu->errindex, sizeof(pdu->errindex));
- if (cp == 0)
- return -1;
- }
- else { // this is a trap message
-
- // enterprise
- cp = asn1::build_objid( packet,
- &length,
- (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OBJECT_ID),
- (oid *)pdu->enterprise,
- pdu->enterprise_length);
- if (cp == 0)
- return -1;
-
- // agent-addr
- cp = asn1::build_string(cp,
- &length,
- // HDN Fixed to use correct tag
- (u_char)SMI_IPADDRESS,
- //(u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OCTET_STR),
- (u_char *)&pdu->agent_addr.sin_addr.s_addr,
- sizeof(pdu->agent_addr.sin_addr.s_addr));
- if (cp == 0)
- return -1;
-
- // generic trap
- cp = asn1::build_int(cp,
- &length,
- (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
- (long *)&pdu->trap_type,
- sizeof(pdu->trap_type));
- if (cp == 0)
- return -1;
-
- // specific trap
- cp = asn1::build_int( cp,
- &length,
- (u_char)(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
- (long *)&pdu->specific_type,
- sizeof(pdu->specific_type));
- if (cp == 0)
- return -1;
-
- // timestamp
- cp = asn1::build_int(cp,
- &length,
- // HDN Fixed to use correct tag
- (u_char)SMI_TIMETICKS,
- //(u_char )(ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_INTEGER),
- (long *)&pdu->time,
- sizeof(pdu->time));
- if (cp == 0)
- return -1;
- }
-
- if (length < totallength)
- return -1;
- // fixed
- ACE_OS::memcpy((char *)cp, (char *)buf, totallength);
- totallength += cp - packet;
-
- length = SNMP_MSG_LENGTH;
- cp = asn1::build_header(buf,
- &length,
- (u_char)pdu->command,
- totallength);
- if (cp == 0)
- return -1;
- if (length < totallength)
- return -1;
- // fixed
- ACE_OS::memcpy((char *)cp, (char *)packet, totallength);
- totallength += cp - buf;
-
- length = *out_length;
-
- cp = cmu_snmp::auth_build( packet,
- &length,
- version,
- community,
- community_len,
- totallength );
- if (cp == 0)
- return -1;
- if ((*out_length - (cp - packet)) < totallength)
- return -1;
- // fixed
- ACE_OS::memcpy((char *)cp, (char *)buf, totallength);
- totallength += cp - packet;
- *out_length = totallength;
-
- return 0;
-}
-
-// parse the authentication header
-u_char *cmu_snmp::auth_parse(u_char *data,
- int *length, u_char *sid,
- int *slen, long *version)
-{
- ACE_TRACE("cmu_snmp::auth_parse");
- u_char type;
-
- // get the type
- data = asn1::parse_header( data, length, &type);
- if (data == 0){
- ASNERROR("bad header");
- return 0;
- }
-
- if (type != (ASN_SEQUENCE | ASN_CONSTRUCTOR)) {
- ASNERROR("wrong auth header type");
- return 0;
- }
-
- // get the version
- data = asn1::parse_int(data, length, &type, version, sizeof(*version));
- if (data == 0) {
- ASNERROR("bad parse of version");
- return 0;
- }
-
- // get the community name
- data = asn1::parse_string(data, length, &type, sid, slen);
- if (data == 0) {
- ASNERROR("bad parse of community");
- return 0;
- }
-
- return (u_char *)data;
-}
-
-/* u_char *data, // IN - pointer to the start of object
- oid *var_name, // OUT - object id of variable
- int *var_name_len, // IN/OUT - length of variable name
- u_char *var_val_type, // OUT - type of variable
- (int or octet string) (one byte)
- int *var_val_len, // OUT - length of variable
- u_char **var_val, // OUT - pointer to ASN1 encoded value of variable
-*/
-
-u_char *
-cmu_snmp::parse_var_op( u_char *data, oid *var_name,
- int *var_name_len, u_char *var_val_type,
- int *var_val_len, u_char **var_val,
- int *listlength)
-{
- ACE_TRACE("cmu_snmp::parse_var_op");
- u_char var_op_type;
- int var_op_len = *listlength;
- u_char *var_op_start = data;
-
- data = asn1::parse_header(data, &var_op_len, &var_op_type);
- if (data == 0){
- ASNERROR("");
- return 0;
- }
- if (var_op_type != (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR))
- return 0;
- data = asn1::parse_objid(data, &var_op_len, &var_op_type, var_name, var_name_len);
- if (data == 0) {
- ASNERROR("");
- return 0;
- }
- if (var_op_type != (u_char)
- (ASN_UNIVERSAL | ASN_PRIMITIVE | ASN_OBJECT_ID))
- return 0;
- *var_val = data; /* save pointer to this object */
- /* find out what type of object this is */
- data = asn1::parse_header(data, &var_op_len, var_val_type);
- if (data == 0) {
- ASNERROR("");
- return 0;
- }
- *var_val_len = var_op_len;
- data += var_op_len;
- *listlength -= (int)(data - var_op_start);
- return data;
-}
-
-
-
-// build a pdu from a data and length
-int cmu_snmp::parse( struct snmp_pdu *pdu,
- u_char *data,
- u_char *community_name,
- u_long &community_len,
- snmp_version &spp_version,
- int length)
-{
- ACE_TRACE("cmu_snmp::parse");
- u_char msg_type;
- u_char type;
- u_char *var_val;
- long version;
- int len, four;
- u_char community[256];
- int community_length = 256;
- struct variable_list *vp = 0;
- oid objid[MAX_NAME_LEN], *op;
-
- // authenticates message and returns length if valid
- data = cmu_snmp::auth_parse(data,
- &length,
- community,
- &community_length,
- &version);
- if (data == 0)
- return -1;
-
- // copy the returned community name
- ACE_OS::memcpy( (u_char *) community_name,
- (u_char *) community,
- community_length);
- community_len = (long) community_length;
-
- if( version != SNMP_VERSION_1 && version != SNMP_VERSION_2C ) {
- ASNERROR("Wrong version");
- return -1;
- }
-
- spp_version = (snmp_version) version;
-
- data = asn1::parse_header(data,
- &length,
- &msg_type);
- if (data == 0)
- return -1;
- pdu->command = msg_type;
-
- if (pdu->command != TRP_REQ_MSG){
- // get the rid
- data = asn1::parse_int(data,
- &length, &type,
- (long *)&pdu->reqid,
- sizeof(pdu->reqid));
- if (data == 0)
- return -1;
- // get the error status
- data = asn1::parse_int(data,
- &length,
- &type,
- (long *)&pdu->errstat,
- sizeof(pdu->errstat));
- if (data == 0)
- return -1;
- // get the error index
- data = asn1::parse_int(data,
- &length,
- &type,
- (long *)&pdu->errindex,
- sizeof(pdu->errindex));
- if (data == 0)
- return -1;
- }
- else { // is a trap
-
- // get the enterprise
- pdu->enterprise_length = MAX_NAME_LEN;
- data = asn1::parse_objid(data,
- &length,
- &type,
- objid,
- &pdu->enterprise_length);
- if (data == 0)
- return -1;
-
- ACE_NEW_RETURN(pdu->enterprise,
- oid[pdu->enterprise_length*sizeof(oid)],-1);
-
- // fixed
- ACE_OS::memcpy((char *)pdu->enterprise,(char *)objid,
- pdu->enterprise_length * sizeof(oid));
-
- // get source address
- four = 4;
- data = asn1::parse_string(data, &length, &type,
- (u_char *)&pdu->agent_addr.sin_addr.s_addr,
- &four);
- if (data == 0)
- return -1;
-
- // get trap type
- data = asn1::parse_int(data, &length, &type, (long *)&pdu->trap_type,
- sizeof(pdu->trap_type));
- if (data == 0)
- return -1;
-
- // trap type
- data = asn1::parse_int(data, &length, &type, (long *)&pdu->specific_type,
- sizeof(pdu->specific_type));
- if (data == 0)
- return -1;
-
- // timestamp
- data = asn1::parse_int(data, &length, &type, (long *)&pdu->time,
- sizeof(pdu->time));
- if (data == 0)
- return -1;
- }
-
- // get the vb list
- data = asn1::parse_header(data, &length, &type);
- if (data == 0)
- return -1;
-
- if (type != (u_char)(ASN_SEQUENCE | ASN_CONSTRUCTOR))
- return -1;
-
- while((int)length > 0) {
- if (pdu->variables == 0) {
- ACE_NEW_RETURN(pdu->variables, variable_list, -1);
- vp = pdu->variables;
- } else {
- ACE_NEW_RETURN(vp->next_variable, variable_list, -1);
- vp = vp->next_variable;
- }
- vp->next_variable = 0;
- vp->val.string = 0;
- vp->name = 0;
- vp->name_length = MAX_NAME_LEN;
- data = cmu_snmp::parse_var_op( data, objid,
- &vp->name_length, &vp->type,
- &vp->val_len, &var_val,
- (int *)&length);
- if (data == 0)
- return -1;
-
- ACE_NEW_RETURN(op, oid[(unsigned)vp->name_length * sizeof(oid)], -1);
-
- // fixed
- ACE_OS::memcpy((char *)op, (char *)objid, vp->name_length * sizeof(oid));
- vp->name = op;
-
- len = SNMP_MSG_LENGTH;
- switch((short)vp->type) {
- case ASN_INTEGER:
- case SMI_COUNTER:
- case SMI_GAUGE:
- case SMI_TIMETICKS:
- case SMI_UINTEGER:
- ACE_NEW_RETURN(vp->val.integer,long, -1);
- vp->val_len = sizeof(long);
- asn1::parse_int(var_val, &len, &vp->type, (long *)vp->val.integer, sizeof(vp->val.integer));
- break;
- case SMI_COUNTER64:
- ACE_NEW_RETURN(vp->val.counter64, counter64, -1);
- vp->val_len = sizeof(struct counter64);
- asn1::parse_unsigned_int64(var_val, &len, &vp->type,
- (struct counter64 *)vp->val.counter64,
- sizeof(*vp->val.counter64));
- break;
-
- case ASN_OCTET_STR:
- case SMI_IPADDRESS:
- case SMI_OPAQUE:
- case SMI_NSAP:
- ACE_NEW_RETURN(vp->val.string, u_char[(unsigned)vp->val_len + 1], -1);
- asn1::parse_string(var_val, &len, &vp->type, vp->val.string,
- &vp->val_len);
- break;
-
- case ASN_OBJECT_ID:
- vp->val_len = MAX_NAME_LEN;
- asn1::parse_objid(var_val, &len, &vp->type, objid, &vp->val_len);
- //vp->val_len *= sizeof(oid);
-
- ACE_NEW_RETURN(vp->val.objid, oid[(unsigned)vp->val_len*sizeof(oid)], -1);
-
- // fixed
- ACE_OS::memcpy((char *)vp->val.objid,
- (char *)objid,
- vp->val_len * sizeof(oid));
- break;
-
- case SNMP_NOSUCHOBJECT:
- case SNMP_NOSUCHINSTANCE:
- case SNMP_ENDOFMIBVIEW:
- case ASN_NULL:
- break;
- default:
- ASNERROR("bad type returned ");
- break;
- }
- }
- return 0;
-}
diff --git a/ASNMP/asnmp/asn1.h b/ASNMP/asnmp/asn1.h
deleted file mode 100644
index 82a81f4a561..00000000000
--- a/ASNMP/asnmp/asn1.h
+++ /dev/null
@@ -1,342 +0,0 @@
-/* -*-C++-*- */
-// $Id$
-#ifndef ASN1
-#define ASN1
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// asn1.h
-//
-// = DESCRIPTION
-// Abstract Syntax Notation One, ASN.1
-// As defined in ISO/IS 8824 and ISO/IS 8825
-// This implements a subset of the above International Standards that
-// is sufficient to implement SNMP.
-//
-// = AUTHOR
-// Steve Waldbusser/CMU ?
-//
-// ============================================================================
-
-/**********************************************************************
- Copyright 1988, 1989, 1991, 1992 by Carnegie Mellon University
-
- All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose and without fee is hereby granted,
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
-supporting documentation, and that the name of CMU not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
-
-CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-******************************************************************/
-
-#include "ace/OS.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-# pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-#include "asnmp/snmp.h"
-
-// CMU code to define "oid" typedef (old C style)
-#ifndef EIGHTBIT_SUBIDS
-typedef unsigned long oid;
-#define MAX_SUBID 0xFFFFFFFF
-#else
-typedef unsigned char oid;
-#define MAX_SUBID 0xFF
-#endif
-
-#define MAX_OID_LEN 64 /* max subid's in an oid */
-
-
-// asn.1 values
-#define ASN_BOOLEAN (0x01)
-#define ASN_INTEGER (0x02)
-#define ASN_BIT_STR (0x03)
-#define ASN_OCTET_STR (0x04)
-#define ASN_NULL (0x05)
-#define ASN_OBJECT_ID (0x06)
-#define ASN_SEQUENCE (0x10)
-#define ASN_SET (0x11)
-#define ASN_UNIVERSAL (0x00)
-#define ASN_APPLICATION (0x40)
-#define ASN_CONTEXT (0x80)
-#define ASN_PRIVATE (0xC0)
-#define ASN_PRIMITIVE (0x00)
-#define ASN_CONSTRUCTOR (0x20)
-#define ASN_LONG_LEN (0x80)
-#define ASN_EXTENSION_ID (0x1F)
-#define ASN_BIT8 (0x80)
-
-#define IS_CONSTRUCTOR(byte) ((byte) & ASN_CONSTRUCTOR)
-#define IS_EXTENSION_ID(byte) (((byte) & ASN_EXTENSION_ID) == ASN_EXTENSION_ID)
-
-#define ASNERROR( string)
-#define MAX_NAME_LEN 64
-#define SNMP_VERSION_1 0
-#define SNMP_VERSION_2C 1
-
-
-// defined types (from the SMI, RFC 1065)
-#define SMI_IPADDRESS (ASN_APPLICATION | 0)
-#define SMI_COUNTER (ASN_APPLICATION | 1)
-#define SMI_GAUGE (ASN_APPLICATION | 2)
-#define SMI_TIMETICKS (ASN_APPLICATION | 3)
-#define SMI_OPAQUE (ASN_APPLICATION | 4)
-#define SMI_NSAP (ASN_APPLICATION | 5)
-#define SMI_COUNTER64 (ASN_APPLICATION | 6)
-#define SMI_UINTEGER (ASN_APPLICATION | 7)
-
-#define GET_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x0)
-#define GETNEXT_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x1)
-#define GET_RSP_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x2)
-#define SET_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x3)
-#define TRP_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x4)
-
-#define GETBULK_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x5)
-#define INFORM_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x6)
-#define TRP2_REQ_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x7)
-#define REPORT_MSG (ASN_CONTEXT | ASN_CONSTRUCTOR | 0x8)
-
-#define SNMP_NOSUCHOBJECT (ASN_CONTEXT | ASN_PRIMITIVE | 0x0)
-#define SNMP_NOSUCHINSTANCE (ASN_CONTEXT | ASN_PRIMITIVE | 0x1)
-#define SNMP_ENDOFMIBVIEW (ASN_CONTEXT | ASN_PRIMITIVE | 0x2)
-
-#define SNMP_MSG_LENGTH 1500
-
-typedef struct sockaddr_in ipaddr;
-
-// pdu
-struct snmp_pdu {
- int command; // pdu type
- unsigned long reqid; // Request id
- unsigned long errstat; // Error status
- unsigned long errindex; // Error index
-
- // Trap information
- oid *enterprise; // System OID
- int enterprise_length;
- ipaddr agent_addr; // address of object generating trap
- int trap_type; // trap type
- int specific_type; // specific type
- unsigned long time; // Uptime
-
- // vb list
- struct variable_list *variables;
-};
-
-// vb list
-struct variable_list {
- struct variable_list *next_variable; // 0 for last variable
- oid *name; // Object identifier of variable
- int name_length; // number of subid's in name
- unsigned char type; // ASN type of variable
- union { // value of variable
- long *integer;
- unsigned char *string;
- oid *objid;
- unsigned char *bitstring;
- struct counter64 *counter64;
- } val;
- int val_len;
-};
-
-struct counter64 {
- unsigned long high;
- unsigned long low;
-};
-
-// CMU Interface class for ASN.1 routines
-class ACE_Export asn1
- // = TITLE
- // Defines the member functions for the asn1 concrete interface class
- // CMU routines for performing ASN.1 data marshalling / representation
-
-{
-public:
-static unsigned char *parse_int( unsigned char *data,
- int *datalength,
- unsigned char *type,
- long int *intp,
- int intsize);
-static unsigned char *parse_unsigned_int( unsigned char *data,
- int *datalength,
- unsigned char *type,
- unsigned long *intp,
- int intsize);
-static unsigned char *build_int( unsigned char *data,
- int *datalength,
- unsigned char type,
- long *intp,
- int intsize);
-
-static unsigned char *build_unsigned_int( unsigned char *data,
- int *datalength,
- unsigned char type,
- unsigned long *intp,
- int intsize);
-
-static unsigned char *parse_string( unsigned char *data,
- int *datalength,
- unsigned char *type,
- unsigned char *string,
- int *strlength);
-
-static unsigned char *build_string( unsigned char *data,
- int *datalength,
- unsigned char type,
- unsigned char *string,
- int strlength);
-
-static unsigned char *parse_header( unsigned char *data,
- int *datalength,
- unsigned char *type);
-
-static unsigned char * build_header( unsigned char *data,
- int *datalength,
- unsigned char type,
- int length);
-
-static unsigned char * build_sequence( unsigned char *data,
- int *datalength,
- unsigned char type,
- int length);
-
-static unsigned char * parse_length( unsigned char *data,
- unsigned long *length);
-
-static unsigned char *build_length( unsigned char *data,
- int *datalength,
- int length);
-
-static unsigned char *build_objid( unsigned char *data,
- int *datalength,
- unsigned char type,
- oid *objid,
- int objidlength);
-
-static unsigned char *parse_objid( unsigned char *data,
- int *datalength,
- unsigned char *type,
- oid *objid,
- int *objidlength);
-
-static unsigned char *parse_null(unsigned char *data,
- int *datalength, unsigned
- char *type);
-
-static unsigned char *build_null( unsigned char *data,
- int *datalength,
- unsigned char type);
-
-static unsigned char *parse_bitstring( unsigned char *data,
- int *datalength,
- unsigned char *type,
- unsigned char *string,
- int *strlength);
-
-static unsigned char *build_bitstring( unsigned char *data,
- int *datalength,
- unsigned char type,
- unsigned char *string,
- int strlength);
-
-static unsigned char * parse_unsigned_int64(unsigned char *data,
- int *datalength,
- unsigned char *type,
- struct counter64 *cp,
- int countersize);
-
-static unsigned char * build_unsigned_int64( unsigned char *data,
- int *datalength,
- unsigned char type,
- struct counter64 *cp,
- int countersize);
-
-};
-
-
-// CMU Interface class for SNMPv1, SNMPv2c routines
-class ACE_Export cmu_snmp
- // = TITLE
- // Defines the static functions for the cmu_snmp concrete class.
- // These routine create cmu pdu's that can be sent/received on/from agents
-{
- public:
- static struct snmp_pdu *pdu_create( int command);
- static void free_pdu( struct snmp_pdu *pdu);
- static int build( struct snmp_pdu *pdu,
- unsigned char *packet,
- int *out_length,
- long version,
- unsigned char* community,
- int community_len);
-
- static void add_var(struct snmp_pdu *pdu,
- oid *name,
- int name_length,
- SmiVALUE *smival);
-
- static int parse( struct snmp_pdu *pdu,
- unsigned char *data,
- unsigned char *community_name,
- unsigned long &community_len,
- snmp_version &version,
- int length);
- static unsigned char *auth_build( unsigned char *data,
- int *length,
- long int version,
- unsigned char *community,
- int community_len,
- int messagelen);
-
- static unsigned char *build_var_op(unsigned char *data,
- oid * var_name,
- int *var_name_len,
- unsigned char var_val_type,
- int var_val_len,
- unsigned char *var_val,
- int *listlength);
-
-
-static unsigned char *auth_parse(unsigned char *data,
- int *length,
- unsigned char *sid,
- int *slen,
- long *version);
-
-/*
- @params data, IN - pointer to the start of object
- var_name OUT - object id of variable
- var_name_len IN/OUT - length of variable name
- var_val_type OUT - type of variable (int or octet string) (one byte)
- var_val_len OUT - length of variable
- var_val, OUT - pointer to ASN1 encoded value of variable
- listlength IN/OUT - number of valid bytes left in var_op_list
-*/
-static unsigned char *parse_var_op( unsigned char *data,
- oid *var_name,
- int *var_name_len,
- unsigned char *var_val_type,
- int *var_val_len,
- unsigned char **var_val,
- int *listlength);
-
-};
-
-#endif // ASN1
-
diff --git a/ASNMP/asnmp/counter.cpp b/ASNMP/asnmp/counter.cpp
deleted file mode 100644
index 04c50dd6475..00000000000
--- a/ASNMP/asnmp/counter.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// counter.cpp
-//
-// = DESCRIPTION
-// Class implementation for SMI Counter32 class.
-//
-// = AUTHOR
-// Peter E Mellquist
-// Michael R MacFaden mrm@cisco.com - rework & ACE port
-// ============================================================================
-/*===================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
-=====================================================================*/
-
-#include "asnmp/counter.h"
-
-ACE_RCSID(asnmp, counter, "$Id$")
-
-// constructor with a value
-Counter32::Counter32( const unsigned long i):SnmpUInt32(i)
-{
- smival.syntax = sNMP_SYNTAX_CNTR32;
-}
-
-// copy constructor
-Counter32::Counter32( const Counter32 &c)
-{
- this->smival.value.uNumber = c.smival.value.uNumber;
- smival.syntax = sNMP_SYNTAX_CNTR32;
- valid_flag = 1;
-}
-
-// syntax type
-SmiUINT32 Counter32::get_syntax()
-{
- return sNMP_SYNTAX_CNTR32;
-}
-
-// general assignment from any Value
-SnmpSyntax& Counter32::operator=( SnmpSyntax &in_val){
- if ( this == &in_val ) // handle assignement from itself
- return *this;
-
- valid_flag = 0; // will get set true if really valid
- if (in_val.valid())
- {
- switch (in_val.get_syntax())
- {
- case sNMP_SYNTAX_UINT32:
- // case sNMP_SYNTAX_GAUGE32: .. indistinquishable from UINT32
- case sNMP_SYNTAX_CNTR32:
- case sNMP_SYNTAX_TIMETICKS:
- case sNMP_SYNTAX_INT32: // implied cast int -> uint
- this->smival.value.uNumber =
- ((Counter32 &)in_val).smival.value.uNumber;
- valid_flag = 1;
- break;
- }
- }
- return *this;
-}
-
-// overloaded assignment
-Counter32& Counter32::operator=( const unsigned long int i)
-{
- this->smival.value.uNumber=i;
- return *this;
-}
-
-// overloaded assignment
-Counter32& Counter32::operator=( const Counter32 &uli)
-{
- this->smival.value.uNumber = uli.smival.value.uNumber;
- return *this;
-}
-
-// otherwise, behave like an unsigned long int
-Counter32::operator unsigned long()
-{
- return this->smival.value.uNumber;
-}
-
-// clone
-SnmpSyntax * Counter32::clone() const
-{
- return ( SnmpSyntax *) new Counter32(*this);
-}
diff --git a/ASNMP/asnmp/counter.h b/ASNMP/asnmp/counter.h
deleted file mode 100644
index 2b0f79807f3..00000000000
--- a/ASNMP/asnmp/counter.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* -*-C++-*- */
-// $Id$
-#ifndef COUNTER_
-#define COUNTER_
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// counter.h
-//
-// = DESCRIPTION
-// Class definition for SMI Counter32 class.
-//
-// = AUTHOR
-// Peter E Mellquist
-//
-// ============================================================================
-/*===================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
-=====================================================================*/
-
-#include "asnmp/smival.h"
-#include "asnmp/integer.h"
-
-//------------[ Counter32 Class ]------------------------------------------
-// The counter class allows all the functionality of unsigned
-// 32 bit integers but is recognized as a distinct SMI type. Counter32
-// class objects may be set or get into Vb objects.
-//
-// This class does not behave as defined by the abstract model
-// in RFC 1155 section 3.2.3.3
-
-class ACE_Export Counter32: public SnmpUInt32
- // = TITLE
- // Defines the member functions for the Counter32 concrete class
- // This class implements RFC 1155 Counter Object and is named
- // Counter32 after the RFC1902 redefinition of V1 SMI datatypes
-{
- public:
- Counter32( const unsigned long i = 0);
- // constructor with a value
-
- Counter32( const Counter32 &c);
- // copy constructor
-
- SmiUINT32 get_syntax();
- // syntax type
-
- SnmpSyntax *clone() const;
- // create a new instance of this Value
-
- SnmpSyntax& operator=( SnmpSyntax &val);
- // copy an instance of this Value
-
- Counter32& operator=( const Counter32 &uli);
- // overloaded assignment
-
- Counter32& operator=( const unsigned long i);
- // overloaded assignment
-
- operator unsigned long();
- // otherwise, behave like an unsigned long int
-};
-
-#endif // COUNTER_
diff --git a/ASNMP/asnmp/ctr64.cpp b/ASNMP/asnmp/ctr64.cpp
deleted file mode 100644
index 264c97a3ac2..00000000000
--- a/ASNMP/asnmp/ctr64.cpp
+++ /dev/null
@@ -1,211 +0,0 @@
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// ctr64.cpp
-//
-// = DESCRIPTION
-// Implementation for Counter64 ( 64 bit counter class).
-//
-// = AUTHOR
-// Peter E Mellquist
-// Michael R MacFaden mrm@cisco.com - rework & ACE port
-// ============================================================================
-/*===================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
-=====================================================================*/
-
-#include "asnmp/ctr64.h"
-
-ACE_RCSID(asnmp, ctr64, "$Id$")
-
-#define MAX32 4294967295u
-
-//-----------[ syntax type ]----------------------------------------------
-SmiUINT32 Counter64::get_syntax()
-{
- return sNMP_SYNTAX_CNTR64;
-}
-
-//------------------[ constructor with values ]--------------------------
-Counter64::Counter64( unsigned long hiparm, unsigned long loparm)
-{
- smival.syntax = sNMP_SYNTAX_CNTR64;
- smival.value.hNumber.hipart = hiparm;
- smival.value.hNumber.lopart = loparm;
-}
-
-//------------------[ constructor with low value only ]------------------
-Counter64::Counter64( unsigned long long llw )
-{
- smival.syntax = sNMP_SYNTAX_CNTR64;
- smival.value.hNumber.hipart = (unsigned long) (llw >> 32);
- smival.value.hNumber.lopart = (unsigned long) llw & 0xffffffff;
-}
-
-//------------------[ copy constructor ]---------------------------------
-Counter64::Counter64( const Counter64 &ctr64 )
-{
- smival.syntax = sNMP_SYNTAX_CNTR64;
- smival.value.hNumber.hipart = ctr64.high();
- smival.value.hNumber.lopart = ctr64.low();
-}
-
-//------------------[ destructor ]---------------------------------
-Counter64::~Counter64()
-{
-}
-
-
-//------------------[ Counter64::high() ]------------------------------
-// return the high part
-unsigned long Counter64::high() const
-{
- return smival.value.hNumber.hipart;
-}
-
-
-//------------------[ Counter64::low() ]-------------------------------
-// return the low part
-unsigned long Counter64::low() const
-{
- return smival.value.hNumber.lopart;
-}
-
-//------------------[ set_high( const unsigned long h) ]-----------
-// set the high part
-void Counter64::set_high( const unsigned long h)
-{
- smival.value.hNumber.hipart = h;
-}
-
-//------------------[ set_low( const unsigned long l) ]------------
-// set the low part
-void Counter64::set_low( const unsigned long l)
-{
- smival.value.hNumber.lopart = l;
-}
-
-
-//-----------[ to_long_double( Counter64 c64) ]-----------------------------
-// convert a Counter 64 to a long double
-long double Counter64::to_long_double() const
-{
- long double ld = this->high();
- ld *= MAX32;
- ld += this->low();
- return ld;
-}
-
-
-//-----------[ ld_to_c64( long double ld) ]----------------------------
-// convert a long double to a Counter64
-// semantics changed from prior version
-Counter64& Counter64::assign( long double ld)
-{
- smival.syntax = sNMP_SYNTAX_CNTR64;
- unsigned long h = smival.value.hNumber.hipart = (unsigned long)(ld / MAX32);
- smival.value.hNumber.lopart = (unsigned long)(ld - h);
- return *this;
-}
-
-//----------------[ general Value = operator ]---------------------
-SnmpSyntax& Counter64::operator=( SnmpSyntax &val)
-{
- // protect against assignment from itself
- if ( this == &val )
- return *this;
-
- smival.value.hNumber.lopart = 0; // pessimsitic - assume no mapping
- smival.value.hNumber.hipart = 0;
-
- // try to make assignment valid
- if (val.valid()){
- switch (val.get_syntax()){
- case sNMP_SYNTAX_CNTR64:
- smival.value.hNumber.hipart =
- ((Counter64 &)val).smival.value.hNumber.hipart;
- smival.value.hNumber.lopart =
- ((Counter64 &)val).smival.value.hNumber.lopart;
- break;
-
- case sNMP_SYNTAX_CNTR32:
- case sNMP_SYNTAX_TIMETICKS:
- case sNMP_SYNTAX_GAUGE32:
- // case sNMP_SYNTAX_UINT32: .. indistinguishable from GAUGE32
- case sNMP_SYNTAX_INT32:
- // take advantage of union...
- smival.value.hNumber.lopart = ((Counter64 &)val).smival.value.uNumber;
- smival.value.hNumber.hipart = 0;
- break;
- }
- }
- return *this;
-}
-
-// overloaded assignment
-Counter64& Counter64::operator=( const unsigned long long rhs)
-{
- smival.value.hNumber.hipart = (unsigned long) (rhs >> 32);
- smival.value.hNumber.lopart = (unsigned long) rhs;
- return *this;
-}
-
-// overloaded assignment
-Counter64& Counter64::operator=( const Counter64 &rhs)
-{
- smival.value.hNumber.hipart = rhs.high();
- smival.value.hNumber.lopart = rhs.low();
- return *this;
-}
-
-// otherwise, behave like an unsigned long int
-Counter64::operator unsigned long long()
-{
- unsigned long long val = smival.value.hNumber.hipart;
- val = val << 32; // shift right 4 bytes
- val |= smival.value.hNumber.lopart;
- return val;
-}
-
-//----------------[ Counter64::clone() ]-----------------------------------
-// create a new instance of this Value
-SnmpSyntax* Counter64::clone() const
-{
- return ( SnmpSyntax *) new Counter64(*this);
-}
-
-//----------------[ Counter64::valid() ]-------------------------------------
-int Counter64::valid() const
-{
- return 1;
-}
-
-//----------[ return ASCII format ]-------------------------
-// TODO: Fix up to do real 64bit decimal value printing...
-// For now, print > 32-bit values in hex
-char * Counter64::to_string()
-{
- if ( high() != 0 )
- sprintf(output_buffer, "0x%X%08X",
- (unsigned int)high(), (unsigned int)low());
- else
- sprintf(output_buffer, "%d", (int) low());
- return output_buffer;
-}
diff --git a/ASNMP/asnmp/ctr64.h b/ASNMP/asnmp/ctr64.h
deleted file mode 100644
index f9dc641a94a..00000000000
--- a/ASNMP/asnmp/ctr64.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/* -*-C++-*- */
-// $Id$
-#ifndef CTR64_
-#define CTR64_
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// ctr64.h
-//
-// = DESCRIPTION
-// SNMP Counter64 class definition.
-//
-// = AUTHOR
-// Peter E Mellquist
-//
-// ============================================================================
-/*===================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
-=====================================================================*/
-
-#include "asnmp/smival.h"
-
-#define CTR64OUTBUF 30 // maximum ascii string for a 64-bit ctr
-
-
-//---------[ 64 bit Counter Class ]--------------------------------
-// Counter64 Class encapsulates two unsigned integers into a
-// a single entity. This type has is available in SNMPv2 but
-// may be used anywhere where needed.
-//
-class ACE_Export Counter64: public SnmpSyntax
- // = TITLE
- // Defines the member functions for the Counter64 concrete class
- // This class implements RFC 1902 64 bit Counter Object.
-{
-public:
- Counter64( unsigned long long llw = 0);
- // default constructor
-
- Counter64( unsigned long hiparm, unsigned long loparm);
- // constructor with values
-
- Counter64( const Counter64 &ctr64);
- // copy constructor
-
- ~Counter64();
- // destructor (ensure that SnmpSyntax::~SnmpSyntax() is overridden)
-
- SmiUINT32 get_syntax();
- // syntax type
-
- long double to_long_double() const;
- // return a long double representation
-
- Counter64& assign( long double ld);
- // assign a long double to a counter64
-
- unsigned long high() const;
- // return the high part
-
- unsigned long low() const;
- // return the low part
-
- void set_high( const unsigned long h);
- // set the high part
-
- void set_low( const unsigned long l);
- // set the low part
-
- Counter64& operator=( const unsigned long long rhs);
- // overloaded assignment
-
- Counter64& operator=( const Counter64 &rhs);
- // overloaded assignment
-
- char *to_string();
- // get a printable ASCII representation
-
- SnmpSyntax *clone() const;
- // create a new instance of this Value
-
- SnmpSyntax& operator=( SnmpSyntax &val);
- // copy an instance of this Value
-
- int valid() const;
- // general validity test, always true
-
- operator unsigned long long();
- // otherwise, behave like an unsigned long long
-
-protected:
- char output_buffer[CTR64OUTBUF];
-};
-
-#endif // CTR64_
diff --git a/ASNMP/asnmp/enttraps.h b/ASNMP/asnmp/enttraps.h
deleted file mode 100644
index d90a593a4e4..00000000000
--- a/ASNMP/asnmp/enttraps.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/* -*-C++-*- */
-// $Id$
-#ifndef ENTTRAPS_
-#define ENTTRAPS_
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// enttraps.cpp
-//
-// = DESCRIPTION
-// constants for Enterprise Traps
-//
-// = AUTHOR
-// Peter E Mellquist
-// Michael R MacFaden mrm@cisco.com - rework & ACE port
-// ============================================================================
-/*===================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
-=====================================================================*/
-
-#include "asnmp/asn1.h" // ASN.1 header file
-
-//--------------[ well known trap ids ]-----------------------------------
-class ACE_Export snmpTrapsOid: public Oid
- // = TITLE
- // Defines the member functions for the snmpTrapsOid base class
- // to implement the traps defined in RFC 1215
-{
- public:
- snmpTrapsOid (void):Oid("1.3.6.1.6.3.1.1.5"){}
-};
-
-class ACE_Export snmpTrapEnterpriseOid: public Oid
- // = TITLE
- // Defines the default Enterprise Oid for this software package
-{
- public:
- snmpTrapEnterpriseOid(void): Oid("1.3.6.1.6.3.1.1.4.3.0") { }
-};
-
-class ACE_Export coldStartOid: public snmpTrapsOid
- // = TITLE
- // Defines the RFC 1215 agent cold start generic trap (system reboot)
-{
- public:
- coldStartOid( void){*this+=".1";}
-};
-
-class ACE_Export warmStartOid: public snmpTrapsOid
- // = TITLE
- // Defines the RFC 1215 agent warm start generic trap (agent reboot)
-{
- public:
- warmStartOid( void){*this+=".2";}
-};
-
-class ACE_Export linkDownOid: public snmpTrapsOid
- // = TITLE
- // Defines the RFC 1215 interface (link) down trap
-{
- public:
- linkDownOid( void){*this+=".3";}
-};
-
-
-// SMI LinkUp Oid
-class ACE_Export linkUpOid: public snmpTrapsOid
- // = TITLE
- // Defines the RFC 1215 interface (link) up trap
-{
- public:
- linkUpOid( void){*this+=".4";}
-};
-
-class ACE_Export authenticationFailureOid: public snmpTrapsOid
- // = TITLE
- // Defines the RFC 1215 device/agent invalid access trap
-{
- public:
- authenticationFailureOid( void){*this+=".5";}
-};
-
-class ACE_Export egpNeighborLossOid: public snmpTrapsOid
- // = TITLE
- // Defines the RFC 1215 Exterior Gateway Protocol neighbor loss trap
-{
- public:
- egpNeighborLossOid( void){*this+=".6";}
-};
-
-#ifdef DEFINE_TRAP_CONSTANTS_
-
-const coldStartOid coldStart;
-const warmStartOid warmStart;
-const linkDownOid linkDown;
-const linkUpOid linkUp;
-const authenticationFailureOid authenticationFailure;
-const egpNeighborLossOid egpNeighborLoss;
-const snmpTrapEnterpriseOid snmpTrapEnterprise;
-
-#endif
-
-#endif // ENTTRAPS_
diff --git a/ASNMP/asnmp/gauge.cpp b/ASNMP/asnmp/gauge.cpp
deleted file mode 100644
index aac715f2730..00000000000
--- a/ASNMP/asnmp/gauge.cpp
+++ /dev/null
@@ -1,113 +0,0 @@
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// gauge.cpp
-//
-// = DESCRIPTION
-// Class implemtation for SMI Gauge32 class.
-// NOTES: This does not behave exactly as a Gauge described in RFC 1155
-//
-// = AUTHOR
-// Peter E Mellquist
-// Michael R MacFaden mrm@cisco.com - rework & ACE port
-// ============================================================================
-/*===================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
-=====================================================================*/
-
-#include "asnmp/gauge.h" // header file for gauge class
-
-ACE_RCSID(asnmp, gauge, "$Id$")
-
-// constructor with a value
-Gauge32::Gauge32( const unsigned long i):SnmpUInt32(i)
-{
- smival.syntax = sNMP_SYNTAX_GAUGE32;
-}
-
-// copy constructor
-Gauge32::Gauge32 ( const Gauge32 &g)
-{ this->smival.value.uNumber = g.smival.value.uNumber;
- smival.syntax = sNMP_SYNTAX_GAUGE32;
- valid_flag = 1;
-}
-
-// destructor
-Gauge32::~Gauge32()
-{
-}
-
-// syntax type
-SmiUINT32 Gauge32::get_syntax()
-{
- return sNMP_SYNTAX_GAUGE32;
-}
-
-// overloaded assignment
-Gauge32& Gauge32::operator=( const Gauge32 &uli)
-{
- this->smival.value.uNumber = uli.smival.value.uNumber;
- return *this;
-}
-
-// overloaded assignment
-Gauge32& Gauge32::operator=( const unsigned long int i)
-{
- smival.value.uNumber=i; return *this;
-}
-
-// general assignment from any Value
-// TODO: this is broken if not inherited from UInt32 (see UInt32 code).
-SnmpSyntax& Gauge32::operator=( SnmpSyntax &in_val)
-{
-
- if ( this == &in_val ) // handle assignement from itself
- return *this;
-
- valid_flag = 0; // will get set true if really valid
- if (in_val.valid())
- {
- switch (in_val.get_syntax())
- {
- case sNMP_SYNTAX_UINT32:
- case sNMP_SYNTAX_GAUGE32:
- case sNMP_SYNTAX_CNTR32:
- case sNMP_SYNTAX_TIMETICKS:
- case sNMP_SYNTAX_INT32: // implied cast int -> uint
- this->smival.value.uNumber =
- ((Gauge32 &)in_val).smival.value.uNumber;
- valid_flag = 1;
- break;
- }
- }
- return *this;
-}
-
-// otherwise, act as unsigned long
-Gauge32::operator unsigned long()
-{
- return smival.value.uNumber;
-}
-
-// clone - create a new instance of this Value
-SnmpSyntax* Gauge32::clone() const
-{
- return ( SnmpSyntax *) new Gauge32(*this);
-}
diff --git a/ASNMP/asnmp/gauge.h b/ASNMP/asnmp/gauge.h
deleted file mode 100644
index 765a713736c..00000000000
--- a/ASNMP/asnmp/gauge.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* -*-C++-*- */
-// $Id$
-#ifndef GAUGE_
-#define GAUGE_
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// gauge32.cpp
-//
-// = DESCRIPTION
-// Class definition for SMI Gauge32 class.
-// This class currently does not behave as defined by the abstract model
-// in RFC 1155 section 3.2.3.4 (ie the value doesn't latch on the max value)
-//
-// = AUTHOR
-// Peter E Mellquist
-//
-// ============================================================================
-/*===================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
-=====================================================================*/
-
-#include "asnmp/integer.h"
-
-//------------[ Gauge32 Class ]------------------------------------------
-// The gauge class allows all the functionality of unsigned
-// integers but is recognized as a distinct SMI type. Gauge32
-// objects may be set or get into Vb objects.
-//
-
-class ACE_Export Gauge32: public SnmpUInt32
- // = TITLE
- // Define RFC1902 Gauge datatype from RFC 1155 section 3.2.3.4
- // Note that this datatype does not behave exactly (acts like a long)
-{
- public:
- Gauge32( const unsigned long i = 0);
- // constructor with a value
-
- Gauge32 ( const Gauge32 &g);
- // copy constructor
-
- ~Gauge32();
- // destructor for a Gauge32 (ensure that Value::~Value() is overridden)
-
- SmiUINT32 get_syntax();
- // syntax type
-
- SnmpSyntax *clone() const;
- // create a new instance of this Value
-
- Gauge32& operator=( const Gauge32 &uli);
- // overloaded assignment
-
- Gauge32& operator=( const unsigned long i);
- // overloaded assignment
-
- operator unsigned long();
- // otherwise, behave like an unsigned int
-
- SnmpSyntax& operator=( SnmpSyntax &val);
- // copy an instance of this Value
-};
-#endif //GAUGE_
-
diff --git a/ASNMP/asnmp/integer.cpp b/ASNMP/asnmp/integer.cpp
deleted file mode 100644
index e0da5b6dfab..00000000000
--- a/ASNMP/asnmp/integer.cpp
+++ /dev/null
@@ -1,227 +0,0 @@
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// integer.cpp
-//
-// = DESCRIPTION
-// Class implemtation for SMI Integer classes.
-//
-// = AUTHOR
-// Jeff Meyer
-// Michael R MacFaden mrm@cisco.com - rework & ACE port
-// ============================================================================
-/*===================================================================
-
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
-=====================================================================*/
-
-#include "asnmp/integer.h" // header file for gauge class
-
-ACE_RCSID(asnmp, integer, "$Id$")
-
-// constructor with value
-SnmpUInt32::SnmpUInt32 (const u_long i)
-{
- smival.value.uNumber=i;
- smival.syntax = sNMP_SYNTAX_UINT32;
- valid_flag = 1;
-}
-
-// copy constructor
-SnmpUInt32::SnmpUInt32( const SnmpUInt32 &c)
-{
- smival.value.uNumber=c.smival.value.uNumber;
- smival.syntax = sNMP_SYNTAX_UINT32;
- valid_flag = 1;
-}
-
-// destructor (ensure that SnmpSyntax::~SnmpSyntax() is overridden)
-SnmpUInt32::~SnmpUInt32()
-{
-}
-
-// syntax type
-SmiUINT32 SnmpUInt32::get_syntax()
-{
- return sNMP_SYNTAX_UINT32;
-}
-
-// object validity
-int SnmpUInt32::valid( void) const
-{
- return valid_flag;
-}
-
-// overloaded assignment
-SnmpUInt32& SnmpUInt32::operator=( const unsigned long int i)
-{
- smival.value.uNumber=i;
- valid_flag = 1;
- return *this;
-}
-
-// general assignment from any Value
-SnmpSyntax& SnmpUInt32::operator=( SnmpSyntax &in_val)
-{
- if ( this == &in_val ) // handle assignement from itself
- return *this;
-
- valid_flag = 0; // will get set true if really valid
- if (in_val.valid())
- {
- switch (in_val.get_syntax())
- {
- case sNMP_SYNTAX_UINT32:
- // case sNMP_SYNTAX_GAUGE32: .. indistinquishable from UINT32
- case sNMP_SYNTAX_CNTR32:
- case sNMP_SYNTAX_TIMETICKS:
- case sNMP_SYNTAX_INT32: // implied cast int -> uint
- this->smival.value.uNumber =
- ((SnmpUInt32 &)in_val).smival.value.uNumber;
- valid_flag = 1;
- break;
- }
- }
- return *this;
-}
-
-// overloaded assignment
-SnmpUInt32& SnmpUInt32::operator=( const SnmpUInt32 &uli)
-{
- this->smival.value.uNumber = uli.smival.value.uNumber; return *this;
-}
-
-// otherwise, behave like an unsigned long int
-SnmpUInt32::operator unsigned long()
-{
- return smival.value.uNumber;
-}
-
-// create a new instance of this Value
-SnmpSyntax* SnmpUInt32::clone() const
-{
- return (SnmpSyntax *) new SnmpUInt32(*this);
-}
-
-// ASCII format return
-char * SnmpUInt32::to_string()
-{
- sprintf(output_buffer, "%d", (int) (this->smival.value.uNumber));
- return output_buffer;
-}
-
-
-//====================================================================
-// INT 32 Implementation
-//====================================================================
-
-// default constructor
-SnmpInt32::SnmpInt32 (const long i)
-{
- smival.value.sNumber=i;
- smival.syntax = sNMP_SYNTAX_INT32;
- valid_flag = 1;
-}
-
-// constructor with value
-SnmpInt32::SnmpInt32 (const SnmpInt32 &c)
-{
- smival.value.sNumber=c.smival.value.sNumber;
- smival.syntax = sNMP_SYNTAX_INT32;
- valid_flag = 1;
-}
-
-// destructor
-SnmpInt32::~SnmpInt32()
-{
-}
-
-// syntax type
-SmiUINT32 SnmpInt32::get_syntax()
-{
- return sNMP_SYNTAX_INT32;
-}
-
-// object validity
-int SnmpInt32::valid( void) const
-{
- return valid_flag;
-}
-
-// overloaded assignment
-SnmpInt32& SnmpInt32::operator=( const long i)
-{
- this->smival.value.sNumber = (unsigned long) i;
- valid_flag = 1;
- return *this;
-}
-
-// overloaded assignment
-SnmpInt32& SnmpInt32::operator=( const SnmpInt32 &uli)
-{
- this->smival.value.sNumber = uli.smival.value.sNumber;
- valid_flag = 1;
- return *this;
-}
-
-// general assignment from any Value
-SnmpSyntax& SnmpInt32::operator=( SnmpSyntax &in_val)
-{
- if ( this == &in_val ) // handle assignement from itself
- return *this;
-
- valid_flag = 0; // will get set true if really valid
- if (in_val.valid())
- {
- switch (in_val.get_syntax())
- {
- case sNMP_SYNTAX_INT32:
- case sNMP_SYNTAX_UINT32: // implied cast uint -> int
- // case sNMP_SYNTAX_GAUGE32: .. indistinquishable from UINT32
- case sNMP_SYNTAX_CNTR32: // implied cast uint -> int
- case sNMP_SYNTAX_TIMETICKS: // implied cast uint -> int
- this->smival.value.sNumber =
- ((SnmpInt32 &)in_val).smival.value.sNumber;
- valid_flag = 1;
- break;
- }
- }
- return *this;
-}
-
-// otherwise, behave like a long int
-SnmpInt32::operator long()
-{
- return (long) smival.value.sNumber;
-}
-
-// clone - create a new instance of this Value
-SnmpSyntax* SnmpInt32::clone() const
-{
- return ( SnmpSyntax *) new SnmpInt32(*this);
-}
-
-// ASCII format return
-
-char *SnmpInt32::to_string()
-{
- sprintf(output_buffer, "%d", (int) (long) this->smival.value.sNumber);
- return output_buffer;
-}
diff --git a/ASNMP/asnmp/integer.h b/ASNMP/asnmp/integer.h
deleted file mode 100644
index d0dc2972742..00000000000
--- a/ASNMP/asnmp/integer.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/* -*-C++-*- */
-// $Id$
-#ifndef SNMPINTEGER_
-#define SNMPINTEGER_
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// integer.cpp
-//
-// = DESCRIPTION
-// Class definition for Integer classes convertable to SMI.
-//
-// = AUTHOR
-// Jeff Meyer
-//
-// ============================================================================
-/*===================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
-=====================================================================*/
-
-#include "asnmp/smival.h"
-
-// TODO get rid of this constant
-#define INTOUTBUF 15 // largest ASCII formatted integer
-
-//------------[ Integer Classes ]------------------------------------------
-// The integer class allows all the functionality of the various
-// integers but is contained in a Value object for consistency
-// among the various types.
-// class objects may be set or get into Vb objects.
-//
-
-// 32 bit unsigned integer class
-class ACE_Export SnmpUInt32: public SnmpSyntax
- // = TITLE
- // Implement RFC 1920 Unsigned Integer SMI datatype
-{
-
- public:
- SnmpUInt32 (const unsigned long i = 0);
- // default constructor
-
- SnmpUInt32( const SnmpUInt32 &c);
- // copy constructor
-
- virtual ~SnmpUInt32();
- // destructor (ensure that SnmpSyntax::~SnmpSyntax() is overridden)
-
- virtual SmiUINT32 get_syntax();
- // syntax type
-
- SnmpUInt32& operator=( const unsigned long i);
- // overloaded assignment
-
- SnmpUInt32& operator=( const SnmpUInt32 &uli);
- // overloaded assignment
-
- operator unsigned long();
- // otherwise, behave like an unsigned long int
-
- virtual char *to_string();
- // get a printable ASCII value
-
- virtual SnmpSyntax *clone() const;
- // create a new instance of this Value
-
- SnmpSyntax& operator=( SnmpSyntax &val);
- // copy an instance of this Value
-
- int valid() const;
- // did object construct properly
-
- protected:
- int valid_flag;
- char output_buffer[INTOUTBUF];
- // contain string representation of object
-};
-
-
-// 32 bit signed integer class
-class ACE_Export SnmpInt32: public SnmpSyntax
-{
- // = TITLE
- // Implement RFC 1902 32 bit Integer SMI data object
- public:
- SnmpInt32 (const long i = 0);
- // constructor with value
-
- SnmpInt32 (const SnmpInt32 &c);
- // constructor with value
-
- virtual ~SnmpInt32();
- // destructor (ensure that SnmpSyntax::~SnmpSyntax() is overridden)
-
- virtual SmiUINT32 get_syntax();
- // syntax type
-
- SnmpInt32& operator=( const long i);
- // overloaded assignment
-
- SnmpInt32& operator=( const SnmpInt32 &li);
- // overloaded assignment
-
- operator long();
- // otherwise, behave like a long int
-
- SnmpSyntax *clone() const;
- // create a new instance of this Value
-
- SnmpSyntax& operator=( SnmpSyntax &val);
- // copy an instance of this Value
-
- char *to_string();
- // get a printable ASCII value
-
- int valid() const;
- // logical state of object
-
- protected:
- int valid_flag;
- char output_buffer[INTOUTBUF];
- // contain string representation of object
-};
-
-#endif
diff --git a/ASNMP/asnmp/octet.cpp b/ASNMP/asnmp/octet.cpp
deleted file mode 100644
index 2a422a5fe88..00000000000
--- a/ASNMP/asnmp/octet.cpp
+++ /dev/null
@@ -1,594 +0,0 @@
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// octet.cpp
-//
-// = DESCRIPTION
-// Implements the SMI Octet datatype (RFC 1155)
-// This class is fully contained and does not rely on or any other
-// SNMP libraries. Ported to ACE by Michael MacFaden mrm@cisco.com
-//
-// = AUTHOR
-// Peter E Mellquist
-//
-// ============================================================================
-/*===================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
-=====================================================================*/
-
-#include "ace/OS.h"
-#include "asnmp/octet.h" // include definition for octet class
-
-ACE_RCSID(asnmp, octet, "$Id$")
-
-//============[ syntax type ]=========================================
-SmiUINT32 OctetStr::get_syntax()
-{
- return sNMP_SYNTAX_OCTETS;
-}
-
-inline
-void init_octet_smi(SmiVALUE& smi)
-{
- smi.syntax = sNMP_SYNTAX_OCTETS;
- smi.value.string.ptr = 0;
- smi.value.string.len = 0;
-}
-
-inline
-void reset_octet_smi(SmiVALUE& smi)
-{
- delete [] smi.value.string.ptr;
- smi.value.string.ptr = 0;
- smi.value.string.len = 0;
-}
-
-inline
-int copy_octet_smi(SmiVALUE& smi, int size, const char *src, int& valid_flag)
-{
- valid_flag = 0;
-
- if (smi.value.string.ptr)
- delete [] smi.value.string.ptr;
-
- ACE_NEW_RETURN(smi.value.string.ptr, SmiBYTE[size], 1);
- ACE_OS::memcpy( smi.value.string.ptr, src, size);
- smi.value.string.len = size;
- valid_flag = 1;
- return 0;
-}
-
-//============[ default constructor ]=========================
-OctetStr::OctetStr( const char * string, long size):
- output_buffer(0), validity(0)
-{
-
- size_t z;
- init_octet_smi(smival);
-
- // check for null string
- if ( !string)
- return;
-
- if (size == -1) // calc if no length given - assume c style string
- size = z = ACE_OS::strlen( string);
-
- copy_octet_smi(smival, size, string, validity);
-}
-
-
-//============[ set the data on an already constructed Octet ]============
-// TODO: should return status since it can fail in so many places
-void OctetStr::set_data( const SmiBYTE* string, long size)
-{
- size_t z;
-
- // invalid args, set octetStr to not valid
- if ( !string || !size) {
- validity = 0;
- return;
- }
-
- // assume non-zero terminated string
- if (size == -1) // calc if no length given - assume c style string
- size = z = ACE_OS::strlen( (char *)string);
-
- // free up already used space
- if ( smival.value.string.ptr ) {
- reset_octet_smi(smival);
- }
- smival.value.string.len = 0;
-
-
- copy_octet_smi(smival, size, (const char *)string, validity);
-}
-
-//============[ constructor using another octet object ]==============
-OctetStr::OctetStr ( const OctetStr &octet):
- output_buffer(0), validity(1)
-{
- init_octet_smi(smival);
- // check for zero len case
- if ( octet.smival.value.string.len == 0) {
- return;
- }
-
- // must be a valid object
- if ( octet.validity == 0) {
- validity = 0;
- return;
- }
-
- // get the mem needed
- copy_octet_smi(smival, octet.smival.value.string.len,
- (const char *)octet.smival.value.string.ptr, validity);
-}
-
-//=============[ destructor ]=========================================
-OctetStr::~OctetStr()
-{
- reset_octet_smi(smival);
- delete [] output_buffer;
-}
-
-
-//=============[ assignment to a string operator overloaded ]=========
-OctetStr& OctetStr::operator=( const char *string)
-{
- // get the string size
- size_t nz;
-
- // free up previous memory if needed
- if ( smival.value.string.ptr ) {
- reset_octet_smi(smival);
- }
-
- // if empty then we are done
- if (!string || !(nz = ACE_OS::strlen( string))) {
- validity = 1;
- return *this;
- }
-
- // get memory needed
- copy_octet_smi(smival, nz, string, validity);
- return *this;
-}
-
-//=============[ assignment to another oid object overloaded ]========
-OctetStr& OctetStr::operator=( const OctetStr &octet)
-{
- // protect against assignment from self
- if ( this == &octet )
- return *this;
-
- // don't assign from invalid objs
- if (!octet.validity) {
- return *this;
- }
-
- // free up previous memory if needed
- if ( smival.value.string.len ) {
- reset_octet_smi(smival);
- }
-
- if (!octet.smival.value.string.len) {
- validity = 1;
- return *this;
- }
-
- // get some memory
- copy_octet_smi(smival, octet.smival.value.string.len,
- (const char*) octet.smival.value.string.ptr, validity);
- return *this; // return self reference
-}
-
-//==============[ equivlence operator overloaded ]====================
-int operator==( const OctetStr &lhs, const OctetStr &rhs)
-{
- if( lhs.left_comparison( rhs.smival.value.string.len, rhs)==0)
- return 1;
- else
- return 0;
-}
-
-//==============[ not equivlence operator overloaded ]================
-int operator!=( const OctetStr &lhs, const OctetStr &rhs)
-{
- if( lhs.left_comparison( rhs.smival.value.string.len, rhs)!=0)
- return 1;
- else
- return 0;
-}
-
-//==============[ less than < overloaded ]============================
-int operator<( const OctetStr &lhs, const OctetStr &rhs)
-{
- if( lhs.left_comparison( rhs.smival.value.string.len, rhs)<0)
- return 1;
- else
- return 0;
-}
-
-//==============[ less than <= overloaded ]===========================
-int operator<=( const OctetStr &lhs, const OctetStr &rhs)
-{
- if(( lhs.left_comparison( rhs.smival.value.string.len, rhs)<0) ||
- ( lhs.left_comparison( rhs.smival.value.string.len, rhs)==0))
- return 1;
- else
- return 0;
-}
-
-//===============[ greater than > overloaded ]========================
-int operator>( const OctetStr &lhs, const OctetStr &rhs)
-{
- if( lhs.left_comparison( rhs.smival.value.string.len, rhs)>0)
- return 1;
- else
- return 0;
-}
-
-//===============[ greater than >= overloaded ]=======================
-int operator>=( const OctetStr &lhs, const OctetStr &rhs)
-{
- if(( lhs.left_comparison( rhs.smival.value.string.len, rhs)>0) ||
- ( lhs.left_comparison( rhs.smival.value.string.len, rhs)==0))
- return 1;
- else
- return 0;
-}
-
-//===============[ equivlence operator overloaded ]===================
-int operator==( const OctetStr &lhs,const char *rhs)
-{
- OctetStr to( rhs);
- if( lhs.left_comparison( to.smival.value.string.len,to)==0)
- return 1;
- else
- return 0;
-}
-
-//===============[ not equivlence operator overloaded ]===============
-int operator!=( const OctetStr &lhs,const char *rhs)
-{
- OctetStr to( rhs);
- if ( lhs.left_comparison( to.smival.value.string.len,to)!=0)
- return 1;
- else
- return 0;
-}
-
-//===============[ less than < operator overloaded ]==================
-int operator<( const OctetStr &lhs,const char *rhs)
-{
- OctetStr to( rhs);
- if ( lhs.left_comparison( to.smival.value.string.len,to)<0)
- return 1;
- else
- return 0;
-}
-
-//===============[ less than <= operator overloaded ]=================
-int operator<=( const OctetStr &lhs,char *rhs)
-{
- OctetStr to( rhs);
- if (( lhs.left_comparison( to.smival.value.string.len,to)<0) ||
- ( lhs.left_comparison( to.smival.value.string.len,to)==0))
- return 1;
- else
- return 0;
-}
-
-//===============[ greater than > operator overloaded ]===============
-int operator>( const OctetStr &lhs,const char *rhs)
-{
- OctetStr to( rhs);
- if ( lhs.left_comparison( to.smival.value.string.len,to)>0)
- return 1;
- else
- return 0;
-}
-
-//===============[ greater than >= operator overloaded ]==============
-int operator>=( const OctetStr &lhs,const char *rhs)
-{
- OctetStr to( rhs);
- if (( lhs.left_comparison( to.smival.value.string.len,to)>0) ||
- ( lhs.left_comparison( to.smival.value.string.len,to)==0))
- return 1;
- else
- return 0;
-}
-
-//===============[ append operator, appends a string ]================
-OctetStr& OctetStr::operator+=( const char *a)
-{
- SmiBYTE *tmp; // temp pointer
- size_t slen,nlen;
-
- // get len of string
- if ( !a || ((slen = ACE_OS::strlen( a)) == 0))
- return *this;
-
- // total len of octet
- nlen = slen + (size_t) smival.value.string.len;
- ACE_NEW_RETURN(tmp, SmiBYTE [ nlen], *this);
- ACE_OS::memcpy ( tmp, smival.value.string.ptr,
- (size_t) smival.value.string.len);
- ACE_OS::memcpy( tmp + smival.value.string.len, a, (size_t) slen);
- // delete the original
- if ( smival.value.string.ptr )
- reset_octet_smi(smival);
- smival.value.string.ptr = tmp;
- smival.value.string.len = nlen;
- return *this;
-}
-
-//================[ append one OctetStr to another ]==================
-OctetStr& OctetStr::operator+=( const OctetStr& octetstr)
-{
- SmiBYTE *tmp; // temp pointer
- size_t slen,nlen;
-
- if (!octetstr.validity ||
- !(slen = (size_t)octetstr.length()))
- return *this;
-
- // total len of octet
- nlen = slen + (size_t) smival.value.string.len;
- // get mem needed
- ACE_NEW_RETURN(tmp, SmiBYTE[ nlen], *this);
- ACE_OS::memcpy ( tmp, smival.value.string.ptr,
- (size_t) smival.value.string.len);
- ACE_OS::memcpy( tmp + smival.value.string.len, octetstr.data(),
- (size_t) slen);
- if ( smival.value.string.ptr )
- reset_octet_smi(smival);
- smival.value.string.ptr = tmp;
- smival.value.string.len = nlen;
- return *this;
-}
-
-//================[ appends an int ]==================================
-OctetStr& OctetStr::operator+=( const char c)
-{
- SmiBYTE *tmp;
- // get the memory needed plus one extra byte
- ACE_NEW_RETURN(tmp, SmiBYTE[ smival.value.string.len + 1], *this);
- ACE_OS::memcpy ( tmp, smival.value.string.ptr,
- (size_t) smival.value.string.len); // len of original
- tmp[ smival.value.string.len ] = c; // assign in byte
- if ( smival.value.string.ptr ) // delete the original
- reset_octet_smi(smival);
-
- smival.value.string.ptr = tmp; // point to one
- smival.value.string.len++; // up the len
- return *this;
-}
-
-
-//================[ compare n elements of an Octet ]==================
-int OctetStr::left_comparison( const long n, const OctetStr &o) const
-{
- long z, w;
-
- // both are empty, they are equal
- if (( smival.value.string.len == 0) &&
- ( o.smival.value.string.len == 0))
- return 0; // equal
-
- // self is empty and param has something
- if (( smival.value.string.len == 0) &&
- ( o.smival.value.string.len >0) &&
- (n>0))
- return -1;
-
- // self has something and param has nothing
- if (( smival.value.string.len > 0) &&
- ( o.smival.value.string.len ==0) &&
- (n>0))
- return 1;
-
- // special case
- if (( smival.value.string.len == 0) &&
- ( o.smival.value.string.len > 0) &&
- ( n == 0))
- return 0;
-
- // pick the Min of n, this and the param len
- // this is the maximum # to iterate a search
- w = smival.value.string.len < o.smival.value.string.len
- ? smival.value.string.len : o.smival.value.string.len;
- if (n<w) w=n;
-
- z = 0;
- while( z < w) {
- if ( smival.value.string.ptr[z] < o.smival.value.string.ptr[z])
- return -1; // less than
- if ( smival.value.string.ptr[z] > o.smival.value.string.ptr[z])
- return 1; // greater than
- z++;
- }
-
- if (( z == 0) &&
- ( smival.value.string.len == 0) &&
- ( o.smival.value.string.len > 0))
- return -1;
-
- if (( z == 0) &&
- ( o.smival.value.string.len == 0) &&
- ( smival.value.string.len > 0))
- return 1;
-
- return 0;
-}
-
-//================[ return the length of the oid ]=======================
-size_t OctetStr::length() const
-{
- return (size_t) smival.value.string.len;
-}
-
-//================[ operator[]: access as if array ]==================
-SmiBYTE& OctetStr::operator[]( int position)
-{
- return smival.value.string.ptr[position];
-}
-
-//===============[ reuturns pointer to internal data ]===============
-SmiBYTE * OctetStr::data() const
-{
- return smival.value.string.ptr;
-}
-
-//================[ returns validity ]================================
-int OctetStr::valid() const
-{
- return validity;
-}
-
-//================[ clone() ]=========================================
-SnmpSyntax * OctetStr::clone() const
-{
- OctetStr *tmp = new OctetStr(*this);
- return ( SnmpSyntax *) tmp;
-}
-
-//================[ ASCII format return ]=============================
-char * OctetStr::to_string()
-{
- for ( unsigned long i=0; i < smival.value.string.len; i++) {
- if (( smival.value.string.ptr[i] != '\r')&&
- ( smival.value.string.ptr[i] != '\n')&&
- (isprint((int) (smival.value.string.ptr[i]))==0))
- return(to_string_hex());
- }
-
- if ( output_buffer != 0)
- delete [] output_buffer;
-
- ACE_NEW_RETURN(output_buffer, char[smival.value.string.len + 1], "");
- if (smival.value.string.len)
- ACE_OS::memcpy(output_buffer, smival.value.string.ptr,
- (int) smival.value.string.len);
- output_buffer[smival.value.string.len] = '\0';
- return output_buffer;
-}
-
-
-//================[ general Value = operator ]========================
-SnmpSyntax& OctetStr::operator=( SnmpSyntax &val)
-{
- // protect against assignment from self
- if ( this == &val )
- return *this;
-
- // blow away the old value
- validity=0;
- if (smival.value.string.ptr) {
- reset_octet_smi(smival);
- }
- smival.value.string.len = 0;
- if (val.valid()){
- switch (val.get_syntax()) {
- case sNMP_SYNTAX_OCTETS:
- case sNMP_SYNTAX_IPADDR:
- set_data( ((OctetStr &)val).smival.value.string.ptr,
- ((OctetStr &)val).smival.value.string.len);
- break;
- }
- }
- return *this;
-}
-
-//================[ format the output into hex ]========================
-char *OctetStr::to_string_hex()
-{
- int cnt;
- char char_buf[80]; // holds ASCII representation of data
- char *buf_ptr; // pointer into ASCII listing
- char *line_ptr; // pointer into Hex listing
- int storageNeeded; // how much space do we need ?
- int local_len = (int) smival.value.string.len;
- SmiBYTE *bytes = smival.value.string.ptr;
-
-
- storageNeeded = (int) ((smival.value.string.len/16)+1) * 72 + 1;
-
- if ( output_buffer != 0)
- delete [] output_buffer;
-
- ACE_NEW_RETURN(output_buffer, char[storageNeeded], "");
-
- line_ptr = output_buffer;
-
- /*----------------------------------------*/
- /* processing loop for entire data buffer */
- /*----------------------------------------*/
- while (local_len > 0) {
- cnt = 16; /* print 16 bytes per line */
- buf_ptr = char_buf;
- sprintf(line_ptr, " ");
- line_ptr += 2; /* indent */
-
- /*-----------------------*/
- /* process a single line */
- /*-----------------------*/
- while (cnt-- > 0 && local_len-- > 0) {
- sprintf(line_ptr, "%2.2X ", *bytes);
-
- line_ptr +=3; /* the display of a byte always 3 chars long */
- if (isprint(*bytes))
- sprintf(buf_ptr, "%c", *bytes);
- else
- sprintf(buf_ptr, ".");
- bytes++;
- buf_ptr++;
- }
- cnt++;
-
- /*----------------------------------------------------------*/
- /* this is to make sure that the ASCII displays line up for */
- /* incomplete lines of hex */
- /*----------------------------------------------------------*/
- while (cnt-- > 0) {
- sprintf(line_ptr," ");
- line_ptr += 3;
- }
-
- /*------------------------------------------*/
- /* append the ASCII display to the Hex line */
- /*------------------------------------------*/
-
-// TODO: verify ACE_OS:: on NT works like this or not
-#if defined(__unix)
- char *fmt = " %s\n";
-#endif // __unix
-
-#if defined(_WIN32)
- char *fmt = " %s\r\n";
-#endif // _WIN32
-
- ACE_OS::sprintf(line_ptr, fmt, char_buf);
- line_ptr += 3 + strlen(char_buf);
- }
-
- return output_buffer;
-}
diff --git a/ASNMP/asnmp/octet.h b/ASNMP/asnmp/octet.h
deleted file mode 100644
index 28b3d9fda21..00000000000
--- a/ASNMP/asnmp/octet.h
+++ /dev/null
@@ -1,150 +0,0 @@
-/* -*-C++-*- */
-// $Id$
-#ifndef OCTET_CLS_
-#define OCTET_CLS_
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// octet.h
-//
-// = DESCRIPTION
-// This class is fully contained and does not rely on or any other
-// SNMP libraries. This class is portable across any platform
-// which supports C++.
-//
-// = AUTHOR
-// Peter E Mellquist / design/original code
-// Michael R. MacFaden / modified for ACE, added suboid(),collapse ctor's
-//
-// ============================================================================
-/*===================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
-=====================================================================*/
-
-//------------------------------------------------------------------------
-#include "asnmp/smival.h"
-
-class ACE_Export OctetStr: public SnmpSyntax
- // = TITLE
- // Implement RFC1155 Octet SMI data object
-
-{
-public:
- OctetStr( const char *string = "", long size = -1);
- // construct octet from byte buffer, assume c style string if size == -1
-
- OctetStr ( const OctetStr &octet);
- // constructor using another octet object
-
- ~OctetStr();
- // destructor
-
- SmiUINT32 get_syntax();
- // syntax type
-
- void set_data( const SmiBYTE* string, long int size = -1);
- // set octet from byte buffer, assume c style string if size == -1
-
- OctetStr& operator=( const char *string);
- // assignment to a string operator overloaded
-
- OctetStr& operator=( const OctetStr &octet);
- // assignment to another oid object overloaded
-
- friend int operator==( const OctetStr &lhs, const OctetStr &rhs);
- // equivlence operator overloaded
-
- friend int operator!=( const OctetStr &lhs, const OctetStr &rhs);
- // not equivlence operator overloaded
-
- friend int operator<( const OctetStr &lhs, const OctetStr &rhs);
- // less than < overloaded
-
- friend int operator<=( const OctetStr &lhs,const OctetStr &rhs);
- // less than <= overloaded
-
- friend int operator>( const OctetStr &lhs, const OctetStr &rhs);
- // greater than > overloaded
-
- friend int operator>=( const OctetStr &lhs, const OctetStr &rhs);
- // greater than >= overloaded
-
- friend int operator==( const OctetStr &lhs,const char *rhs);
- // equivlence operator overloaded
-
- friend int operator!=( const OctetStr &lhs,const char *rhs);
- // not equivlence operator overloaded
-
- friend int operator<( const OctetStr &lhs,const char *rhs);
- // less than < operator overloaded
-
- friend int operator<=( const OctetStr &lhs,char *rhs);
- // less than <= operator overloaded
-
- friend int operator>( const OctetStr &lhs,const char *rhs);
- // greater than > operator overloaded
-
- friend int operator>=( const OctetStr &lhs,const char *rhs);
- // greater than >= operator overloaded
-
- OctetStr& operator+=( const char *a);
- // append operator, appends a string
-
- OctetStr& operator+=( const char c);
- // appends an int
-
- OctetStr& operator+=( const OctetStr& octetstr);
- // append one octetStr to another
-
- SmiBYTE& operator[]( int position);
- // for non const [], allows reading and writing
-
- int left_comparison( const long n, const OctetStr &o) const;
- // compare the n leftmost bytes (left-to-right)
- // returns 0, equal
- // returns -1, <
- // returns 1 , >
-
- size_t length() const ;
- // return the len of the oid
-
- int valid() const;
- // returns validity
-
- SmiBYTE *data() const;
- // returns pointer to internal data
-
- char *to_string();
- // get a printable ASCII value
-
- char *to_string_hex();
- // get an ASCII formattted hex dump of the contents
-
- SnmpSyntax *clone() const;
- // create a new instance of this Value
-
- SnmpSyntax& operator=( SnmpSyntax &val);
- // copy an instance of this Value
-
-protected:
- //----[ instance variables ]
- char *output_buffer; // formatted Octet value
- int validity; // validity boolean
-};
-
-#endif // OCTET_CLS_
diff --git a/ASNMP/asnmp/oid.cpp b/ASNMP/asnmp/oid.cpp
deleted file mode 100644
index d0bbcd3c4aa..00000000000
--- a/ASNMP/asnmp/oid.cpp
+++ /dev/null
@@ -1,800 +0,0 @@
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// oid.cpp
-//
-// = DESCRIPTION
-// This module contains the implementation of the oid class. This
-// includes all protected and public member functions. The oid class
-// may be compiled stand alone without the use of any other library.
-//
-// = AUTHOR
-// Peter E Mellquist
-// Michael R MacFaden mrm@cisco.com - rework & ACE port
-// ============================================================================
-/*===================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS" without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
-=====================================================================*/
-
-//---------[ external C libaries used ]--------------------------------
-
-#include "asnmp/oid.h" // include def for oid class
-
-ACE_RCSID(asnmp, oid, "$Id$")
-
-enum Defs {SNMPBUFFSIZE=300,
- SNMPCHARSIZE=15}; // max oid value (4294967295UL)
-
-#define NO_MEM_STR "ERROR: Oid::to_string: memory allocation failure"
-
-//=============[Oid::get_syntax(void)]====================================
-SmiUINT32 Oid::get_syntax()
-{
- return sNMP_SYNTAX_OID;
-}
-
-
-//=============[Oid::Oid( const char *dotted_string ]=====================
-// constructor using a dotted string
-//
-// do a string to oid using the string passed in
-Oid::Oid( const char * dotted_oid_string, size_t size)
-{
- // can't init enum SmiValue so just memset it clean
- set_null();
-
- size_t z;
- if ((z = ACE_OS::strlen(dotted_oid_string)) == 0) {
- set_invalid();
- return;
- }
-
- if (size == (unsigned int)-1)
- size = z;
- if (size > z)
- size = z;
-
- char *ptr = (char *)dotted_oid_string;;
- if (size < z) {
- // create new buffer if needed
- ACE_NEW(ptr, char [size]);
-
- // sz should be in StrToOid?
- ACE_OS::memcpy( (void *)ptr, dotted_oid_string, size);
- }
-
- size_t byte_counter;
- if (StrToOid( (char *) ptr, &smival.value.oid, byte_counter) < 0)
- set_invalid();
- if (ptr != dotted_oid_string)
- delete [] ptr;
-}
-
-
-//=============[Oid::Oid( const Oid &oid) ]================================
-// constructor using another oid object
-//
-// do an oid copy using the oid object passed in
-Oid::Oid ( const Oid &oid)
-{
- set_null();
-
- // allocate some memory for the oid
- // in this case the size to allocate is the same
- // size as the source oid
- if (oid.smival.value.oid.len) {
- ACE_NEW(smival.value.oid.ptr, SmiUINT32[ oid.smival.value.oid.len]);
- size_t byte_counter;
- OidCopy( (SmiLPOID) &(oid.smival.value.oid),(SmiLPOID)
- &smival.value.oid, byte_counter);
- }
-}
-
-
-//=============[Oid::Oid( const unsigned long *raw_oid, int oid_len) ]====
-// constructor using raw numeric form
-//
-// copy the integer values into the private member
-Oid::Oid(const unsigned long *raw_oid, size_t oid_len)
-{
- set_null();
-
- smival.syntax = sNMP_SYNTAX_OID;
- set_invalid();
-
- if (raw_oid && oid_len > 0) {
- ACE_NEW(smival.value.oid.ptr, SmiUINT32[ oid_len]);
- smival.value.oid.len = oid_len;
- for (size_t i=0; i < oid_len; i++)
- smival.value.oid.ptr[i] = raw_oid[i];
- }
-}
-
-//=============[Oid::~Oid]==============================================
-// destructor
-//
-// free up the descriptor space
-Oid::~Oid()
-{
- // free up the octet deep memory
- if ( smival.value.oid.ptr ) {
- set_invalid();
- }
-
- // free up the output string
- if ( iv_str != 0)
- delete [] iv_str;
-}
-
-
-//=============[Oid::operator = const char * dotted_string ]==============
-// assignment to a string operator overloaded
-//
-// free the existing oid
-// create the new oid from the string
-// return this object
-void Oid::set_data( const char *dotted_oid_string)
-{
- // delete the old value
- if ( smival.value.oid.ptr ) {
- set_invalid();
- }
-
- // assign the new value
- size_t byte_counter;
- if (StrToOid( (char *) dotted_oid_string, &smival.value.oid, byte_counter) <0)
- set_invalid();
-}
-
-
-//=============[Oid:: operator = const Oid &oid ]==========================
-// assignment to another oid object overloaded
-//
-// free the existing oid
-// create a new one from the object passed in
-// TODO: measure perf vs memory of no realloc in case where len >= oid.len
-Oid& Oid::operator=( const Oid &oid)
-{
- // protect against assignment from self
- if ( this == &oid)
- return *this;
-
- set_invalid();
-
- // check for zero len on source
- if ( oid.smival.value.oid.len == 0)
- return *this;
-
- init_value((const SmiLPOID) &(oid.smival.value.oid),
- oid.smival.value.oid.len);
- return *this;
-}
-
-// assign this object the oid, set to invalid if copy fails
-void Oid::init_value(const SmiLPOID srcOid, size_t len)
-{
- // allocate some memory for the oid
- ACE_NEW(smival.value.oid.ptr, SmiUINT32[ len]);
- size_t byte_counter;
- OidCopy( srcOid, (SmiLPOID) &smival.value.oid, byte_counter);
-}
-
-void Oid::init_value(const unsigned long *raw_oid, size_t oid_len)
-{
- if (smival.value.oid.ptr)
- delete [] smival.value.oid.ptr;
-
- ACE_NEW(smival.value.oid.ptr, SmiUINT32[ oid_len]);
- ACE_OS::memcpy((SmiLPBYTE) smival.value.oid.ptr,
- (SmiLPBYTE) raw_oid,
- (size_t) (oid_len * sizeof(SmiUINT32)));
- smival.value.oid.len = oid_len;
-}
-
-//==============[Oid:: operator += const char *a ]=========================
-// append operator, appends a string
-//
-// allocate some space for a max oid string
-// extract current string into space
-// concat new string
-// free up existing oid
-// make a new oid from string
-// delete allocated space
-Oid& Oid::operator+=( const char *a)
-{
- unsigned long n;
-
- if (!a)
- return *this;
-
- if ( *a=='.')
- a++;
- size_t sz = ACE_OS::strlen(a);
-
- if (valid()) {
- n = (smival.value.oid.len *SNMPCHARSIZE) + smival.value.oid.len + 1 + sz;
- char *ptr;
- ACE_NEW_RETURN(ptr, char[ n], *this);
- size_t byte_counter;
- if (OidToStr(&smival.value.oid, n,ptr, byte_counter) > 0) {
- delete [] ptr;
- set_invalid();
- return *this;
- }
-
- if (ACE_OS::strlen(ptr))
- ACE_OS::strcat(ptr,".");
- ACE_OS::strcat(ptr,a);
- if ( smival.value.oid.len !=0) {
- set_invalid();
- delete [] smival.value.oid.ptr;
- smival.value.oid.len = 0;
- }
-
- if (StrToOid( (char *) ptr, &smival.value.oid, byte_counter) < 0) {
- set_invalid();
- }
- delete [] ptr;
- }
- else {
- size_t byte_counter;
- if (StrToOid( (char *) a, &smival.value.oid, byte_counter) < 0) {
- set_invalid();
- }
- }
-
- return *this;
-}
-
-//=============[ int operator == oid,oid ]=================================
-// equivlence operator overloaded
-int operator==( const Oid &lhs, const Oid &rhs)
-{
- // ensure same len, then use left_comparison
- if (rhs.length() != lhs.length())
- return 0;
- if( lhs.left_comparison( rhs.length(), rhs) == 0)
- return 1;
- else
- return 0;
-}
-
-//==============[ operator!=( Oid &x,Oid &y) ]=============================
-//not equivlence operator overloaded
-int operator!=( const Oid &lhs,const Oid &rhs)
-{
- return (!(lhs == rhs));
-}
-
-//==============[ operator<( Oid &x,Oid &y) ]=============================
-// less than < overloaded
-int operator<( const Oid &lhs,const Oid &rhs)
-{
- int result;
-
- // call left_comparison with the current
- // Oidx, Oidy and len of Oidx
- if ((result = lhs.left_comparison( rhs.length(), rhs)) < 0)
- return 1;
- else if (result > 0)
- return 0;
-
- else{
- // if here, equivalent substrings, call the shorter one <
- if (lhs.length() < rhs.length())
- return 1;
- else
- return 0;
- }
-}
-
-//==============[ operator<=( Oid &x,Oid &y) ]=============================
-// less than <= overloaded
-int operator<=( const Oid &x,const Oid &y)
-{
- if ( (x < y) || (x == y) )
- return 1;
- else
- return 0;
-}
-
-//==============[ operator>( Oid &x,Oid &y) ]=============================
-// greater than > overloaded
-int operator>( const Oid &x,const Oid &y)
-{
- // just invert existing <=
- if (!(x<=y))
- return 1;
- else
- return 0;
-}
-
-//==============[ operator>=( Oid &x,Oid &y) ]=============================
-// greater than >= overloaded
-int operator>=( const Oid &x,const Oid &y)
-{
- // just invert existing <
- if (!(x<y))
- return 1;
- else
- return 0;
-}
-
-//===============[Oid::oidval ]=============================================
-// return the WinSnmp oid part
-SmiLPOID Oid::oidval()
-{
- return (SmiLPOID) &smival.value.oid;
-}
-
-//===============[Oid::set_data ]==---=====================================
-// copy data from raw form...
-void Oid::set_data( const unsigned long *raw_oid, const size_t oid_len)
-{
- if (smival.value.oid.len < oid_len) {
- if ( smival.value.oid.ptr) {
- set_invalid();
- }
- }
- init_value(raw_oid, oid_len);
-}
-
-
-//===============[Oid::len ]================================================
-// return the len of the oid
-size_t Oid::length() const
-{
- return smival.value.oid.len;
-}
-
-//===============[Oid::trim( unsigned int) ]============================
-// trim off the n leftmost values of an oid
-// Note!, does not adjust actual space for
-// speed
-void Oid::trim( const size_t n)
-{
- // verify that n is legal
- if ((n<=smival.value.oid.len)&&(n>0)) {
- smival.value.oid.len -= n;
-
- if (smival.value.oid.len == 0) {
- set_invalid();
- }
- }
-}
-
-//===============[Oid::set_invalid() ]====================
-// make this object invalid by resetting all values
-void Oid::set_invalid() {
- delete [] smival.value.oid.ptr;
- smival.value.oid.ptr = 0;
- smival.value.oid.len = 0;
- delete [] iv_str;
- iv_str = 0;
-}
-
-//===============[Oid::set_null() ]====================
-void Oid::set_null() {
- smival.syntax = sNMP_SYNTAX_OID;
- smival.value.oid.ptr = 0;
- smival.value.oid.len = 0;
- iv_str = 0;
-}
-
-//===============[Oid::operator += const unsigned int) ]====================
-// append operator, appends an int
-//
-// allocate some space for a max oid string
-// extract current string into space
-// concat new string
-// free up existing oid
-// make a new oid from string
-// delete allocated space
-Oid& Oid::operator+=( const unsigned long i)
-{
- unsigned long n = (smival.value.oid.len * SNMPCHARSIZE)
- + ( smival.value.oid.len -1) + 1 + 4;
- char buffer[SNMPBUFFSIZE];
-
- // two cases: null oid, existing oid
- if (valid()) {
- // allocate some temporary space
- char *ptr;
- ACE_NEW_RETURN(ptr, char[ n], *this);
- size_t byte_counter;
- if (OidToStr(&smival.value.oid, n, ptr, byte_counter) < 0) {
- set_invalid();
- delete [] ptr;
- return *this;
- }
-
- if (ACE_OS::strlen(ptr))
- ACE_OS::strcat(ptr,".");
-
- if (ACE_OS::sprintf( buffer,"%u",i) != -1) {
- ACE_OS::strcat(ptr, buffer);
- if ( smival.value.oid.ptr ) {
- set_invalid();
- }
- if (StrToOid( (char *) ptr, &smival.value.oid, byte_counter) < 0) {
- set_invalid();
- }
- delete [] ptr;
- }
- }
- else {
- init_value((const unsigned long *)&i, (size_t)1);
- }
-
- return *this;
-}
-
-//===============[Oid::operator += const Oid) ]========================
-// append operator, appends an Oid
-//
-// allocate some space for a max oid string
-// extract current string into space
-// concat new string
-// free up existing oid
-// make a new oid from string
-// delete allocated space
-Oid& Oid::operator+=( const Oid &o)
-{
- SmiLPUINT32 new_oid;
-
- if (o.smival.value.oid.len == 0)
- return *this;
-
- ACE_NEW_RETURN(new_oid,
- SmiUINT32[ smival.value.oid.len + o.smival.value.oid.len], *this);
- if (smival.value.oid.ptr) {
- ACE_OS::memcpy((SmiLPBYTE) new_oid,
- (SmiLPBYTE) smival.value.oid.ptr,
- (size_t) (smival.value.oid.len*sizeof(SmiUINT32)));
-
- delete [] smival.value.oid.ptr;
- }
-
- // out with the old, in with the new...
- smival.value.oid.ptr = new_oid;
-
- ACE_OS::memcpy((SmiLPBYTE) &new_oid[smival.value.oid.len],
- (SmiLPBYTE) o.smival.value.oid.ptr,
- (size_t) (o.smival.value.oid.len*sizeof(SmiUINT32)));
-
- smival.value.oid.len += o.smival.value.oid.len;
- return *this;
-}
-
-// return string portion of the oid
-//
-char * Oid::to_string()
-{
- unsigned long n;
- if (!valid())
- return ""; // be consistent with other classes
-
- // the worst case char len of an oid can be..
- // oid.len*3 + dots in between if each oid is XXXX
- // so.. size = (len*4) + (len-1) + 1 , extra for a null
-
- n = (smival.value.oid.len *SNMPCHARSIZE) + ( smival.value.oid.len -1) + 1 ;
- if (n == 0)
- n = 1; // need at least 1 byte for a null string
-
- // adjust the len of output array in case size was adjusted
- if ( iv_str != 0)
- delete [] iv_str;
- // allocate some space for the output string
- ACE_NEW_RETURN(iv_str, char[ n], "");
-
- // convert to an output string
- size_t how_many;
- if ( valid() && iv_str != 0)
- if (OidToStr(&smival.value.oid,n,iv_str, how_many) < 0)
- return "ERROR: Oid::OidToStr failed";
- return iv_str;
-}
-
-//==============[Oid::suboid( unsigned int start, n) ]=============
-int Oid::suboid(Oid& new_oid, size_t start, size_t how_many)
-{
- if (how_many == 0)
- return 0;
- else
- if (how_many == (size_t)-1)
- how_many = length();
- else
- if (how_many > length())
- how_many = length();
-
- // reset new_oid
- new_oid.set_invalid();
-
- size_t new_size = how_many - start;
- if (new_size == 0)
- new_size++;
- new_oid.smival.value.oid.len = new_size;
- ACE_NEW_RETURN(new_oid.smival.value.oid.ptr,
- SmiUINT32 [ new_oid.smival.value.oid.len], -1);
- // copy source to destination
- ACE_OS::memcpy( (SmiLPBYTE) new_oid.smival.value.oid.ptr,
- (SmiLPBYTE) (smival.value.oid.ptr + start),
- new_size * sizeof(SmiLPBYTE));
- return 0;
-}
-
-
-//=============[Oid::StrToOid( char *string, SmiLPOID dst) ]==============
-// convert a string to an oid
-int Oid::StrToOid( const char *string, SmiLPOID dstOid, size_t& how_many)
-{
- size_t index = 0;
- size_t number = 0;
-
- // make a temp buffer to copy the data into first
- SmiLPUINT32 temp;
- unsigned long nz;
-
- if (string && *string) {
- nz = ACE_OS::strlen( string);
- }
- else {
- dstOid->len = 0;
- dstOid->ptr = 0;
- return -1;
- }
-
- ACE_NEW_RETURN(temp, SmiUINT32[ nz], -1);
- while (*string!=0 && index<nz) {
- // init the number for each token
- number = 0;
- // skip over the dot
- if (*string=='.')
- string++;
-
- // grab a digit token and convert it to a long int
- while (isdigit(*string))
- number=number*10 + *(string++)-'0';
-
- // check for invalid chars
- if (*string!=0 && *string!='.') {
- // Error: Invalid character in string
- delete [] temp;
- return -1;
- }
-
- // stuff the value into the array
- temp[index] = number;
- index++; // bump the counter
- }
-
-
- // get some space for the real oid
- ACE_NEW_RETURN(dstOid->ptr, SmiUINT32[ index], -1);
- // TODO: make tmp autoptr type delete [] temp to prevent leak
-
- // copy in the temp data
- ACE_OS::memcpy((SmiLPBYTE) dstOid->ptr, (SmiLPBYTE) temp,
- (size_t) (index*sizeof(SmiUINT32)));
-
- // set the len of the oid
- dstOid->len = index;
-
- // free up temp data
- delete [] temp;
-
- how_many = index;
- return 0;
-}
-
-
-//===============[Oid::OidCopy( source, destination) ]====================
-// Copy an oid, return bytes copied
-int Oid::OidCopy( SmiLPOID srcOid, SmiLPOID dstOid, size_t& how_many_bytes)
-{
- // check source len ! zero
- if (srcOid->len == 0)
- return -1;
-
- // copy source to destination
- ACE_OS::memcpy((SmiLPBYTE) dstOid->ptr,
- (SmiLPBYTE) srcOid->ptr,
- (size_t) (srcOid->len * sizeof(SmiUINT32)));
-
- //set the new len
- dstOid->len = srcOid->len;
- how_many_bytes = srcOid->len;
-
- return 0;
-}
-
-
-//===============[Oid::left_comparison( n, Oid) ]=================================
-// compare the n leftmost values of two oids ( left-to_right )
-//
-// self == Oid then return 0, they are equal
-// self < Oid then return -1, <
-// self > Oid then return 1, >
-int Oid::left_comparison( const unsigned long n, const Oid &o) const
-{
- unsigned long z;
- unsigned long len = n;
- int reduced_len = 0;
-
- // 1st case they both are null
- if (( len==0)&&( this->smival.value.oid.len==0))
- return 0; // equal
-
- // verify that n is valid, must be >= 0
- if ( len <=0)
- return 1; // ! equal
-
- // only compare for the minimal length
- if (len > this->smival.value.oid.len) {
- len = this->smival.value.oid.len;
- reduced_len = 1;
- }
- if (len > o.smival.value.oid.len) {
- len = o.smival.value.oid.len;
- reduced_len = 1;
- }
-
- z = 0;
- while(z < len) {
- if ( this->smival.value.oid.ptr[z] < o.smival.value.oid.ptr[z])
- return -1; // less than
- if ( this->smival.value.oid.ptr[z] > o.smival.value.oid.ptr[z])
- return 1; // greater than
- z++;
- }
-
- // if we truncated the len then these may not be equal
- if (reduced_len) {
- if (this->smival.value.oid.len < o.smival.value.oid.len)
- return -1;
- if (this->smival.value.oid.len > o.smival.value.oid.len)
- return 1;
- }
- return 0; // equal
-
-}
-
-
-//===============[Oid::left_comparison( n, Oid) ]=================================
-// compare the n rightmost bytes (right-to-left)
-// returns 0, equal
-// returns -1, <
-// returns 1 , >
-int Oid::right_comparison( const unsigned long n, const Oid &o) const
-{
- // oid to compare must have at least the same number
- // of sub-ids to comparison else the argument Oid is
- // less than THIS
- if ( o.length() < n)
- return -1;
-
- // also can't compare argument oid for sub-ids which
- // THIS does not have
- if ( this->length() < n)
- return -1;
-
- int start = (int) this->length();
- int end = (int) start - (int) n;
- for ( int z=start;z< end;z--)
- {
- if ( o.smival.value.oid.ptr[z] < this->smival.value.oid.ptr[z])
- return -1;
- if ( o.smival.value.oid.ptr[z] > this->smival.value.oid.ptr[z])
- return 1;
- }
-
- return 0; // they are equal
-
-}
-
-
-//================[ Oid::valid() ]========================================
-// is the Oid object valid
-// returns validity
-int Oid::valid() const
-{
- return ( smival.value.oid.ptr ? 1 : 0 );
-}
-
-//================[Oid::OidToStr ]=========================================
-// convert an oid to a string
-int Oid::OidToStr( SmiLPOID srcOid, unsigned long size,
- char *string, size_t& how_many_bytes)
-{
- unsigned long index = 0;
- unsigned totLen = 0;
- char szNumber[SNMPBUFFSIZE];
-
- // init the string
- string[totLen] = 0;
-
- // verify there is something to copy
- if (srcOid->len == 0)
- return -1;
-
- // loop through and build up a string
- for (index=0; index < srcOid->len; index++) {
-
- // convert data element to a string
- if (ACE_OS::sprintf( szNumber,"%u", srcOid->ptr[index]) == -1)
- return -1;
-
- // verify len is not over
- if (totLen + ACE_OS::strlen(szNumber) + 1 >= size)
- return -2;
-
- // if not at end, pad with a dot
- if (totLen!=0)
- string[totLen++] = '.';
-
- // copy the string token into the main string
- ACE_OS::strcpy(string + totLen, szNumber);
-
- // adjust the total len
- totLen += ACE_OS::strlen(szNumber);
- }
-
- how_many_bytes = totLen + 1;
- return 0;
-}
-
-
-//================[ general Value = operator ]========================
-SnmpSyntax& Oid::operator=( SnmpSyntax &val)
-{
- // protect against assignment from self
- if ( this == &val )
- return *this;
-
- // blow away old value
- smival.value.oid.len = 0;
- if (smival.value.oid.ptr) {
- set_invalid();
- }
-
- // assign new value
- if (val.valid()) {
- switch (val.get_syntax()) {
- case sNMP_SYNTAX_OID:
- set_data( ((Oid &)val).smival.value.oid.ptr,
- (unsigned int)((Oid &)val).smival.value.oid.len);
- break;
- }
- }
- return *this;
-}
-
-//================[ [] operator ]=====================================
-unsigned long& Oid::operator[](size_t position)
-{
- return smival.value.oid.ptr[position];
-}
-
-//================[ clone ]===========================================
-SnmpSyntax *Oid::clone() const
-{
- return (SnmpSyntax *) new Oid(*this);
-}
diff --git a/ASNMP/asnmp/oid.h b/ASNMP/asnmp/oid.h
deleted file mode 100644
index 16020e374c0..00000000000
--- a/ASNMP/asnmp/oid.h
+++ /dev/null
@@ -1,170 +0,0 @@
-/* -*-C++-*- */
-// $Id$
-#ifndef OID_CLS_
-#define OID_CLS_
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// oid.h
-//
-// = DESCRIPTION
-// This class is fully contained and does not rely on or any other
-// SNMP libraries. This class is portable across any platform
-// which supports C++. Ported to ACE by Mike MacFaden mrm@cisco.com
-// and modified for MT. Some API cleanup: collapse constructors,
-// add suboid() method remove unnecessary overload, and update a few
-// names and types to improve clarity.
-//
-// = AUTHOR
-// Peter E Mellquist
-//
-// ============================================================================
-/*===================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
-=====================================================================*/
-
-//----------[ extern C libraries Needed ]---------------------------------
-#include "ace/OS.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-# pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-#include "asnmp/smival.h" // derived class for all values
-
-class ACE_Export Oid: public SnmpSyntax
- // = TITLE
- // Implement RFC 1155 Object Identifier (OID) datatype
-{
-public:
- Oid( const char * dotted_oid_string = "", size_t size = unsigned(-1) );
- // constructor using a dotted string
-
- Oid ( const Oid &oid);
- // constructor using another oid object
-
- Oid(const unsigned long *raw_oid, size_t oid_len);
- // constructor from raw form
-
- ~Oid();
- // destructor
-
- SmiUINT32 get_syntax();
- // syntax type
-
- Oid& operator=( const Oid &oid);
- // assignment to another oid object overloaded
-
- friend int operator==( const Oid &lhs,const Oid &rhs);
- // equal operator overloaded
-
- friend int operator!=( const Oid &lhs,const Oid &rhs);
- // not equal operator overloaded
-
- friend int operator<( const Oid &lhs,const Oid &rhs);
- // less than < overloaded
-
- friend int operator<=( const Oid &lhs,const Oid &rhs);
- // less than <= overloaded
-
- friend int operator>( const Oid &lhs,const Oid &rhs);
- // greater than > overloaded
-
- friend int operator>=( const Oid &lhs,const Oid &rhs);
- // greater than >= overloaded
-
- Oid& operator+=( const char *a);
- // append operator, appends a string
-
- Oid& operator+=( const unsigned long i);
- // appends an int
-
- Oid& operator+=( const Oid &o);
- // appends an Oid
-
- unsigned long & operator[]( size_t position);
- // allows element access
-
- SmiLPOID oidval();
- // return the WinSnmp oid part
-
- void set_data( const char *dotted_oid_string);
- // reset the data from raw 1 byte format
-
- void set_data( const unsigned long *raw_oid, const size_t oid_len);
- // reset the data from raw 4byte integer format
-
- size_t length() const;
- // return the len of the oid
-
- void trim( const size_t how_many = 1);
- // trim off the n rightmost values of an oid
-
- int suboid(Oid& oid, size_t start = 0, size_t how_many = -1);
- // the equivalent of a substr(new_str, 0, 1)
-
- int left_comparison( const unsigned long n, const Oid &o) const;
- // compare the n leftmost bytes (left-to-right)
- // returns 0, equal
- // returns -1, <
- // returns 1 , >
-
-
- int right_comparison( const unsigned long n, const Oid &o) const;
- // compare the n rightmost bytes (right-to-left)
- // returns 0, equal
- // returns -1, <
- // returns 1 , >
-
- int valid() const;
- // is the Oid object valid
-
- char *to_string();
- // return dotted string value from the right
- // where the user specifies how many positions to print
-
- SnmpSyntax *clone() const;
- // create a new instance of this Value
-
- SnmpSyntax& operator=( SnmpSyntax &val);
- // copy an instance of this Value
-
-protected:
- char *iv_str;
- // used for returning oid string
-
- int StrToOid( const char *string, SmiLPOID dstOid, size_t& how_many_bytes);
- // convert a string to an smi oid
-
- int OidCopy( SmiLPOID srcOid, SmiLPOID dstOid, size_t& how_many_bytes);
- // clone an smi oid
-
- int OidToStr(SmiLPOID srcOid, SmiUINT32 size, char *string, size_t& how_many_bytes);
- // convert an smi oid to its string representation
-
- private:
- void set_invalid();
- // release memory, re-init data members
-
- void set_null();
- // initialize object data members
- void init_value( const SmiLPOID srcOid, size_t len);
- void init_value(const unsigned long *raw_oid, size_t oid_len);
-};
-
-#endif //OID_CLS_
diff --git a/ASNMP/asnmp/oid_def.h b/ASNMP/asnmp/oid_def.h
deleted file mode 100644
index bdf46ec4f88..00000000000
--- a/ASNMP/asnmp/oid_def.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* -*-C++-*- */
-// $Id$
-#ifndef OID_DEF
-#define OID_DEF
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// address.cpp
-//
-// = DESCRIPTION
-// Well known Oids defined in RFC 1215
-//
-// = AUTHOR
-// Peter E Mellquist
-//
-// ============================================================================
-/*===================================================================
-
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
-=====================================================================*/
-
-// SMI trap oid def
-class snmpTrapsOid: public Oid {
- public:
- snmpTrapsOid (void):Oid("1.3.6.1.6.3.1.1.5"){};
-};
-
-// SMI Enterprose Oid
-class snmpTrapEnterpriseOid: public Oid {
- public:
- snmpTrapEnterpriseOid(void):Oid("1.3.6.1.6.3.1.1.4.3.0"){};
-};
-
-// SMI Cold Start Oid
-class coldStartOid: public snmpTrapsOid {
- public:
- coldStartOid( void){*this+=".1";};
-};
-
-// SMI WarmStart Oid
-class warmStartOid: public snmpTrapsOid {
- public:
- warmStartOid( void){*this+=".2";};
-};
-
-// SMI LinkDown Oid
-class linkDownOid: public snmpTrapsOid {
- public:
- linkDownOid( void){*this+=".3";};
-};
-
-
-// SMI LinkUp Oid
-class linkUpOid: public snmpTrapsOid {
- public:
- linkUpOid( void){*this+=".4";};
-};
-
-// SMI Authentication Failure Oid
-class authenticationFailureOid: public snmpTrapsOid {
- public:
- authenticationFailureOid( void){*this+=".5";};
-};
-
-// SMI egpneighborloss Oid
-class egpNeighborLossOid: public snmpTrapsOid {
- public:
- egpNeighborLossOid( void){*this+=".6";};
-};
-
-
-#endif // OID_DEF
diff --git a/ASNMP/asnmp/pdu.cpp b/ASNMP/asnmp/pdu.cpp
deleted file mode 100644
index 6ac3acc04d5..00000000000
--- a/ASNMP/asnmp/pdu.cpp
+++ /dev/null
@@ -1,496 +0,0 @@
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// pdu.cpp
-//
-// = DESCRIPTION
-// Pdu class implementation. Encapsulation of an SMI Protocol
-// Data Unit (PDU) in C++.
-//
-// = AUTHOR
-// Peter E Mellquist
-// Michael R MacFaden mrm@cisco.com - rework & ACE port
-// ============================================================================
-/*===================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
-=====================================================================*/
-
-#include "asnmp/snmp.h"
-#include "asnmp/pdu.h" // include Pdu class definition
-
-ACE_RCSID(asnmp, pdu, "$Id$")
-
-//=====================[ constructor no args ]=========================
-Pdu::Pdu( void): vb_count_(0), error_status_(0), error_index_(0),
-validity_(0), request_id_(0), pdu_type_(0), notify_timestamp_(0),
-output_(0)
-{
-}
-
-//=====================[ constructor with vbs_ and count ]==============
-Pdu::Pdu( Vb* pvbs, const int pvb_count): vb_count_(0), error_index_(0),
-validity_(0), request_id_(0), pdu_type_(0), notify_timestamp_(0),
-output_(0)
-{
- int z; // looping variable
-
- // zero is ok
- if ( pvb_count == 0) {
- validity_ = 1;
- return;
- }
-
- // check for over then max
- if ( pvb_count > MAX_VBS) {
- validity_ = 0;
- return;
- }
-
- // loop through and assign internal vbs_
- for (z = 0;z < pvb_count; z++) {
- validity_ = 0;
- ACE_NEW(vbs_[z], Vb( pvbs[z]));
- validity_ = 1;
- }
-
- // assign the vb count
- vb_count_ = pvb_count;
-
- validity_ = 1;
-}
-
-//=====================[ constructor with another Pdu instance ]========
-Pdu::Pdu( const Pdu &pdu): vb_count_(0),
-error_index_(0), validity_(0), request_id_(0), pdu_type_(0),
-notify_timestamp_(0), output_(0)
-{
- *this = pdu;
- return;
-}
-
-//=====================[ destructor ]====================================
-Pdu::~Pdu()
-{
- delete_all_vbs();
- delete [] output_;
-}
-
-
-//=====================[ assignment to another Pdu object overloaded ]===
-Pdu& Pdu::operator=( const Pdu &pdu)
-{
- int z; // looping variable
-
- // Initialize all mv's
- error_status_ = pdu.error_status_;
- error_index_ = pdu.error_index_;
- request_id_ = pdu.request_id_;
- pdu_type_ = pdu.pdu_type_;
- notify_id_ = pdu.notify_id_;
- notify_timestamp_ = pdu.notify_timestamp_;
- notify_enterprise_ = pdu.notify_enterprise_;
- validity_ = 1;
-
- // free up old vbs_
- for ( z = 0;z < vb_count_; z++)
- delete vbs_[z];
- vb_count_ = 0;
-
- // check for zero case
- if ( pdu.vb_count_ == 0) {
- return *this;
- }
-
- // loop through and fill em up
- for (z = 0; z < pdu.vb_count_; z++) {
- validity_ = 0;
- ACE_NEW_RETURN(vbs_[z], Vb ( *(pdu.vbs_[z])), *this);
- validity_ = 1;
- }
-
- vb_count_ = pdu.vb_count_;
- return *this;
-}
-
-// append operator, appends a string
-Pdu& Pdu::operator+=( Vb &vb)
-{
-
- // do we have room?
- if ( vb_count_ + 1 > MAX_VBS)
- return *this;
-
- // add the new one
- validity_ = 0;
- ACE_NEW_RETURN(vbs_[vb_count_], Vb (vb), *this);
- // set up validity_
- validity_ = 1;
-
- // up the vb count
- vb_count_++;
-
- // return self reference
- return *this;
-
-}
-
-// return fomatted version of this object
-char * Pdu::to_string()
-{
- // determine how big a buffer and allocate it
- const int HEADER_STR = 100;
- unsigned size = HEADER_STR; // header takes up this much room
- int z;
-
- for ( z = 0; z < vb_count_; z++)
- size += ACE_OS::strlen(vbs_[z]->to_string());
-
- ACE_NEW_RETURN(output_, char[size], "");
-
- // print pdu header info
- sprintf(output_, "pdu: valid: %d type:%d, req:%d, cnt: %d, err stat: %d \
- err idx: %d\n", validity_, pdu_type_, (int) request_id_,
- vb_count_, error_status_, error_index_ );
-
- // now append vb pairs in this object
- for ( z = 0; z < vb_count_; z++) {
- ACE_OS::strcat(output_, vbs_[z]->to_string());
- ACE_OS::strcat(output_, "\n\t");
- }
-
- return output_;
-}
-
-
-//=====================[ extract Vbs from Pdu ]==========================
-// how do you know that the caler has enough memory???
-// should I self allocate this in here and require the
-// caller then to free it up at soem later time
-int Pdu::get_vblist( Vb* pvbs, const int pvb_count)
-{
- if ((!pvbs) || ( pvb_count < 0) || ( pvb_count > vb_count_))
- return 0;
-
- // loop through all vbs_ and assign to params
- int z;
- for (z = 0; z < pvb_count; z++)
- pvbs[z] = *vbs_[z];
-
- return 1;
-
-}
-
-//=====================[ deposit Vbs ]===================================
-int Pdu::set_vblist( Vb* pvbs, const int pvb_count)
-{
-
- // if invalid then don't destroy
- if ((!pvbs) || ( pvb_count < 0) || ( pvb_count > MAX_VBS))
- return 0;
-
- // free up current vbs_
- int z;
- for ( z = 0; z < vb_count_; z++)
- delete vbs_[z];
- vb_count_ = 0;
-
- // check for zero case
- if ( pvb_count == 0) {
- validity_ = 1;
- error_status_ = 0;
- error_index_ = 0;
- request_id_ = 0;
- return 0;
- }
-
-
- // loop through all vbs_ and reassign them
- for ( z = 0; z < pvb_count; z++) {
- validity_ = 0;
- ACE_NEW_RETURN(vbs_[z], Vb (pvbs[z]), 0);
- validity_ = 1;
- }
-
- vb_count_ = pvb_count;
-
- // clear error status and index since no longer valid
- // request id may still apply so don't reassign it
- error_status_ = 0;
- error_index_ = 0;
- validity_ = 1;
-
- return 1;
-}
-
-//===================[ get a particular vb ]=============================
-// here the caller has already instantiated a vb object
-// index is zero based
-int Pdu::get_vb( Vb &vb, const int index) const
-{
- // can't have an index less than 0
- if ( index < 0)
- return 0;
-
- // can't ask for something not there
- if ( index > (vb_count_ - 1))
- return 0;
-
- // asssign it
- vb = *vbs_[index];
-
- return 1;
-}
-
-//===================[ set a particular vb ]=============================
-int Pdu::set_vb( Vb &vb, const int index)
-{
- // can't set a vb at index less than 0
- if ( index < 0)
- return 0;
-
- // can't ask for something not there
- if ( index > (vb_count_ - 1))
- return 0;
-
- // delete what is there
- delete vbs_[index];
-
- // assign it
- validity_ = 0;
- ACE_NEW_RETURN(vbs_[index], Vb (vb), 0);
- validity_ = 1;
-
- return 1;
-
-}
-
-//=====================[ return number of vbs_ ]==========================
-int Pdu::get_vb_count() const
-{
- return vb_count_;
-}
-
-//=====================[ return the error status ]=======================
-int Pdu::get_error_status() const
-{
- return error_status_;
-}
-
-char *Pdu::agent_error_reason()
-{
- int pdu_err = get_error_status();
- if (pdu_err == 0) // any real error?
- return "not in error state";
-
- int n_vbs = get_vb_count();
- Vb bad;
- get_vb(bad, get_error_index() -1); // not zero based??
- char *pmsg = Snmp::error_string(get_error_status());
- char *id = bad.to_string_oid();
- char *val = bad.to_string_value();
- const int HDR_SZ = 100;
-
- if (!output_) {
- int size = ACE_OS::strlen(pmsg) + ACE_OS::strlen(id) +
- ACE_OS::strlen(val);
- ACE_NEW_RETURN(output_, char[size + HDR_SZ], "");
- }
-
- ACE_OS::sprintf(output_,
-"FAIL PDU REPORT: pdu id: %d vb cnt: %d vb idx: %d \n\
-msg: %s vb oid: %s value: %s",
- get_request_id(), n_vbs, get_error_index(), pmsg, id, val);
-
- return output_;
-}
-
-//=====================[ set the error status ]==========================
-// friend
-void set_error_status( Pdu *pdu, const int status)
-{
- if (pdu)
- pdu->error_status_ = status;
-}
-
-//=====================[ return the error index ]========================
-int Pdu::get_error_index() const
-{
- return error_index_;
-}
-
-//=====================[ set the error index ]===========================
-// friend
-void set_error_index( Pdu *pdu, const int index)
-{
- if (pdu)
- pdu->error_index_ = index;
-}
-
-//=====================[ clear error status ]=============================
-void clear_error_status( Pdu *pdu)
-{
- if (pdu)
- pdu->error_status_ = 0;
-}
-
-//=====================[ clear error index ]==============================
-void clear_error_index( Pdu *pdu)
-{
- if (pdu)
- pdu->error_index_ = 0;
-}
-
-//=====================[ return the request id ]==========================
-unsigned long Pdu::get_request_id() const
-{
- return request_id_;
-}
-
-//=====================[ set the request id ]=============================
-// friend function
-void set_request_id( Pdu *pdu, const unsigned long rid)
-{
- if (pdu)
- pdu->request_id_ = rid;
-}
-
-//=====================[ returns validity_ of Pdu instance ]===============
-int Pdu::valid() const
-{
- return validity_;
-}
-
-//=====================[ get the pdu type ]===============================
-unsigned short Pdu::get_type()const
-{
- return pdu_type_;
-}
-
-// set the pdu type
-void Pdu::set_type( unsigned short type)
-{
- pdu_type_ = type;
-}
-
-
-// trim off the last vb
-int Pdu::trim(const int p)
-{
- int lp = p;
-
- // verify that lp is legal
- if ( lp < 0 || lp > vb_count_)
- return 0;
-
- while ( lp != 0) {
- if ( vb_count_ > 0) {
- delete vbs_[vb_count_ - 1];
- vb_count_--;
- }
- lp--;
- }
- return 1;
-}
-
-
-
-// delete a Vb anywhere within the Pdu
-int Pdu::delete_vb( const int p)
-{
- // position has to be in range
- if (( p < 0) || ( p > (vb_count_ - 1)))
- return 0;
-
- // safe to remove it
- delete vbs_[ p];
-
- for ( int z=p;z < (vb_count_-1);z++) {
- vbs_[z] = vbs_[z+1];
- }
- vb_count_--;
-
- return 1;
-}
-
-void Pdu::delete_all_vbs()
-{
- for ( int z = 0; z < vb_count_; z++)
- delete vbs_[z];
- vb_count_ = 0;
-}
-
-
-// set notify timestamp
-void Pdu::set_notify_timestamp( const TimeTicks & timestamp)
-{
- notify_timestamp_ = timestamp;
-}
-
-
-// get notify timestamp
-void Pdu::get_notify_timestamp( TimeTicks & timestamp) const
-{
- timestamp = notify_timestamp_;
-}
-
-// set the notify id
-void Pdu::set_notify_id( const Oid id)
-{
- notify_id_ = id;
-}
-
-// get the notify id
-void Pdu::get_notify_id( Oid &id) const
-{
- id = notify_id_;
-}
-
-// set the notify enterprise
-void Pdu::set_notify_enterprise( const Oid &enterprise)
-{
- notify_enterprise_ = enterprise;
-}
-
-// get the notify enterprise
-void Pdu::get_notify_enterprise( Oid & enterprise) const
-{
- enterprise = notify_enterprise_;
-}
-
-// ------ class VbIter -------------------
-VbIter::VbIter(Pdu& pdu): idx_(-1), pdu_(&pdu)
-{
-}
-
-// returns 1 if ok, else 0 if none left
-int VbIter::next(Vb& vb)
-{
- if (idx_ == -1) {
- idx_ = 0;
- pdu_->get_vb(vb, idx_++);
- return 1;
- }
- else
- if (idx_ < pdu_->get_vb_count()) {
- pdu_->get_vb(vb, idx_++);
- return 1;
- }
- return 0; // non left
-}
diff --git a/ASNMP/asnmp/pdu.h b/ASNMP/asnmp/pdu.h
deleted file mode 100644
index e748ac5b528..00000000000
--- a/ASNMP/asnmp/pdu.h
+++ /dev/null
@@ -1,213 +0,0 @@
-/* -*-C++-*- */
-// $Id$
-#ifndef PDU_CLS_
-#define PDU_CLS_
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// pdu.h
-//
-// = DESCRIPTION
-// Pdu class definition. Encapsulation of an SMI Protocol
-// Data Unit (PDU) aka Packet in C++.
-//
-// = AUTHOR
-// Peter E Mellquist original code
-// Michael MacFaden mrm@cisco.com ACE port, add iterator class for pdus
-// ============================================================================
-/*===================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
-=====================================================================*/
-
-// TODO: this needs to be moved into the CLASS and modifyable at runtime
-// TODO: define an iterator object to traverse the vbs in a pdu
-
-#define MAX_VBS 25
-#include "asnmp/vb.h" // include Vb class definition
-
-class ACE_Export Pdu
- // = TITLE
- // Protocol Data Unit (PDU) concrete class. An abstraction of the
- // data packet used to by two SNMP sessions to communicate.
-{
-public:
- Pdu( void);
- // constructor no args
-
- Pdu( Vb* pvbs, const int pvb_count);
- // constructor with vbs and count
-
- Pdu( const Pdu &pdu);
- // constructor with another Pdu instance
-
- ~Pdu();
- // destructor
-
- Pdu& operator=( const Pdu &pdu);
- // assignment to another Pdu object overloaded
-
- Pdu& operator+=( Vb &vb);
- // append a vb to the pdu
-
- // TODO: add Pdu& operator-=(const Vb &vb);
-
- int get_vblist( Vb* pvbs, const int pvb_count);
- // extract all Vbs from Pdu
-
- int set_vblist( Vb* pvbs, const int pvb_count);
- // deposit all Vbs to Pdu
-
- int get_vb( Vb &vb, const int index = 0) const;
- // get a particular vb
- // where 0 is the first vb
-
- int set_vb( Vb &vb, const int index);
- // set a particular vb
- // where 0 is the first vb
-
- int get_vb_count() const;
- // return number of vbs
-
- int get_error_status() const;
- // return the error status
-
- char *agent_error_reason();
- // return the complete error info from this pdu
-
- friend void set_error_status( Pdu *pdu, const int status);
- // set the error status
-
- int get_error_index() const;
- // return the error index
-
- friend void set_error_index( Pdu *pdu, const int index);
- // set the error index
-
- friend void clear_error_status( Pdu *pdu);
- // clear error status
-
- friend void clear_error_index( Pdu *pdu);
- // clear error index
-
- unsigned long get_request_id() const;
- // return the request id
-
- friend void set_request_id( Pdu *pdu, const unsigned long rid);
- // set the request id
-
- unsigned short get_type() const;
- // get the pdu type
-
- void set_type( unsigned short type);
- // set the pdu type
-
- int valid() const;
- // returns validity of Pdu instance
-
- int trim(const int count=1);
- // trim off count vbs from the end of the vb list
-
- int delete_vb( const int position);
- // delete a Vb anywhere within the Pdu
-
- void delete_all_vbs();
- // delete_all vbs in pdu
-
- void set_notify_timestamp( const TimeTicks & timestamp);
- // set notify timestamp
-
- void get_notify_timestamp( TimeTicks & timestamp) const;
- // get notify timestamp
-
- void set_notify_id( const Oid id);
- // set the notify id
-
- void get_notify_id( Oid &id) const;
- // get the notify id
-
- void set_notify_enterprise( const Oid &enterprise);
- // set the notify enterprise
-
- void get_notify_enterprise( Oid & enterprise) const;
- // get the notify enterprise
-
- char *to_string();
- // return fomatted version of this object
-
-
- protected:
- Vb *vbs_[MAX_VBS];
- // pointer to array of Vbs
-
- int vb_count_;
- // count of Vbs
-
- int error_status_;
- // SMI error status
-
- int error_index_;
- // SMI error index
-
- int validity_;
- // valid boolean status of object construction
- unsigned long request_id_;
- // SMI request id
-
- unsigned short pdu_type_;
- // derived at run time based on request type
-
- TimeTicks notify_timestamp_;
- // a timestamp associated with an infor
- // for notify Pdu objects only
- // traps & notifies
-
- Oid notify_id_;
- // an id
-
- Oid notify_enterprise_;
-
- private:
- char *output_;
- // buffer for to_string()
-};
-
-
-class VbIter
- // = TITLE
- // Utility class to iterate once through a PDU varbind list
-{
- public:
- VbIter(Pdu& pdu);
- // default constructor
-
- int next(Vb& vb);
- // returns 1 if ok, else 0 if none left
-
- private:
- VbIter(const VbIter&);
- // disallow copy constructor use
-
- int idx_;
- // current object in list
-
- Pdu *pdu_;
- // ptr to pdu being interated over
-};
-
-#endif //PDU_CLS_
-
diff --git a/ASNMP/asnmp/sagent.cpp b/ASNMP/asnmp/sagent.cpp
deleted file mode 100644
index fc56a2c728f..00000000000
--- a/ASNMP/asnmp/sagent.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// sagent.cpp
-//
-// = DESCRIPTION
-// SNMP agent class definition. The sagent class provides an object oriented
-// approach for creating SNMP Agents. The sagent class is an encapsulation
-// of SNMP sessions, gets, sets, etc.
-//
-// = AUTHOR
-// Michael R. MacFaden
-//
-// ============================================================================
-#include "ace/Reactor.h"
-#include "ace/SOCK_Dgram.h"
-
-#include "asnmp/oid.h" // snmp++ oid class
-#include "asnmp/vb.h" // snbmp++ vb class
-#include "asnmp/target.h" // snmp++ target class
-#include "asnmp/pdu.h" // snmp++ pdu class
-#include "asnmp/snmperrs.h" // error macros and strings
-#include "asnmp/address.h" // snmp++ address class defs
-#include "asnmp/snmp.h" // manager snmp interface
-#include "asnmp/sagent.h" // agent interface
-#include "asnmp/transaction.h" // convert from wire to API
-
-ACE_RCSID(asnmp, sagent, "$Id$")
-
-sagent::sagent(unsigned short port): Snmp(port)
-{
- ACE_TRACE("sagent::sagent(short)");
-}
-
-sagent::~sagent()
-{
- ACE_TRACE("sagent::~sagent");
-}
-
-int sagent::handle_input(ACE_HANDLE fd)
-{
- ACE_TRACE("sagent::handle_input");
-
- transaction tr(iv_snmp_session_); // this section needs a better design
- tr.handle_input(fd);
- char rcv_com_str[MAX_COMM_STR_LEN];
- if (tr.result(pdu_, rcv_com_str) < 0)
- return 0;
- OctetStr community(rcv_com_str);
- const ACE_INET_Addr &ta = tr.get_from_addr();
- char buf_tmp[MAXHOSTNAMELEN + 1];
- ta.addr_to_string (buf_tmp, MAXHOSTNAMELEN);
- UdpAddress ra(buf_tmp);
- tgt_.set_address(ra);
-
-
- // process msg here by calling subclass's implementation
- switch (pdu_.get_type()){
- case sNMP_PDU_GET:
- tgt_.set_read_community(community);
- this->handle_get(pdu_, tgt_);
- break;
-
- case sNMP_PDU_GETNEXT:
- tgt_.set_read_community(community);
- this->handle_get_next(pdu_, tgt_);
- break;
-
- case sNMP_PDU_SET:
- tgt_.set_write_community(community);
- this->handle_set(pdu_, tgt_);
- break;
-
- default:
- ACE_ASSERT(0);
- }
- return 0;
-}
-
-ACE_HANDLE sagent::get_handle() const
-{
- ACE_TRACE("sagent::get_handle");
- return iv_snmp_session_.get_handle();
-}
-
-int sagent::respond(Pdu& pdu,UdpTarget& tgt)
-{
- pdu.set_type(sNMP_PDU_RESPONSE);
- transaction tr(pdu, tgt, iv_snmp_session_);
- tr.send();
- return 0;
-}
diff --git a/ASNMP/asnmp/sagent.h b/ASNMP/asnmp/sagent.h
deleted file mode 100644
index e97d7839be5..00000000000
--- a/ASNMP/asnmp/sagent.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* -*-C++-*- */
-// $Id$
-#ifndef SAGENT_CLS_
-#define SAGENT_CLS_
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// sagent.h
-//
-// = DESCRIPTION
-// SNMP agent class defintion. The sagent class provides an object oriented
-// approach for creating SNMP Agents. The sagent class is an encapsulation of SNMP
-// sessions, gets, sets, etc.
-//
-// = AUTHOR
-// Michael R. MacFaden
-//
-// ============================================================================
-#include "ace/Reactor.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-# pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-#include "ace/SOCK_Dgram.h"
-
-#include "asnmp/oid.h" // snmp++ oid class
-#include "asnmp/vb.h" // snbmp++ vb class
-#include "asnmp/target.h" // snmp++ target class
-#include "asnmp/pdu.h" // snmp++ pdu class
-#include "asnmp/snmperrs.h" // error macros and strings
-#include "asnmp/address.h" // snmp++ address class defs
-#include "asnmp/snmp.h" // snmp interface
-
-// sagent - supports Version 1 operations in blocking mode
-
-#define DEF_AGENT_PORT (161)
-
-class ACE_Export sagent : public ACE_Event_Handler, Snmp
- // = TITLE
- // Concrete class sagent defines the session and interface to
- // communicate with another SNMP Version 1 manager
-{
- public:
-
-
- // override the next three methods (callbacks) to implment your agent
- //
-
- virtual int handle_get( Pdu &pdu, UdpTarget &target) = 0;
- // retrieve data from a peer agent for a given list of oid values
-
- virtual int handle_get_next( Pdu &pdu, UdpTarget &target) = 0;
- // retrieve data lexically adjacent to the oids specified in the pdu
- // from the peer agent
-
- virtual int handle_set( Pdu &pdu, UdpTarget &target) = 0;
- // set data in the agent from the list of oids in the pdu
-
- virtual int handle_input(ACE_HANDLE);
- // new pdu received from mgr (reactor calls this)
-
- virtual ACE_HANDLE get_handle() const;
- // retrieve io descriptor (reactor uses this)
-
- int respond(Pdu& pdu, UdpTarget& tgt);
- // send a response pdu to the mgr
-
- protected:
- sagent(unsigned short port = DEF_AGENT_PORT);
- virtual ~sagent();
-
-private:
- sagent(const sagent&);
- Pdu pdu_; // current input pdu
- UdpTarget tgt_; // addr & com strs
-};
-
-#endif //SAGENT_CLS_
-
diff --git a/ASNMP/asnmp/smi.h b/ASNMP/asnmp/smi.h
deleted file mode 100644
index 09b3927b220..00000000000
--- a/ASNMP/asnmp/smi.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/* -*-C++-*- */
-// $Id$
-#ifndef SMIDEF_
-#define SMIDEF_
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// smi.h
-//
-// = DESCRIPTION
-// Address class definition. Encapsulates various network
-// addresses into easy to use, safe and portable classes.
-//
-// = AUTHOR
-// ??
-//
-// ============================================================================
-/*===================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
-
-=====================================================================*/
-
-#include "ace/OS.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-# pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-//----------[ ASN/BER Base Types ]-----------------------------------------
-// Basic Encoding Rules (BER)
-// (used in forming SYNTAXes and certain SNMP types/values)
-#define aSN_UNIVERSAL (0x00)
-#define aSN_APPLICATION (0x40)
-#define aSN_CONTEXT (0x80)
-#define aSN_PRIVATE (0xC0)
-#define aSN_PRIMITIVE (0x00)
-#define aSN_CONSTRUCTOR (0x20)
-
-//------[ SNMP ObjectSyntax Values ]---------------------------------------
-#define sNMP_SYNTAX_SEQUENCE (aSN_CONTEXT | aSN_CONSTRUCTOR | 0x10)
-
-
-//-------------------------------------------------------------------------
-// These values are used in the "syntax" member
-// of the smiVALUE structure which follows.
-// Note: UInt32 is indistinguishable from Gauge32 per SNMPv2 Draft Standard
-// NsapAddr is obsoleted as unique SMI type per SNMPv2 Draft Standard
-#define sNMP_SYNTAX_INT (aSN_UNIVERSAL | aSN_PRIMITIVE | 0x02)
-#define sNMP_SYNTAX_BITS (aSN_UNIVERSAL | aSN_PRIMITIVE | 0x03)
-#define sNMP_SYNTAX_OCTETS (aSN_UNIVERSAL | aSN_PRIMITIVE | 0x04)
-#define sNMP_SYNTAX_NULL (aSN_UNIVERSAL | aSN_PRIMITIVE | 0x05)
-#define sNMP_SYNTAX_OID (aSN_UNIVERSAL | aSN_PRIMITIVE | 0x06)
-#define sNMP_SYNTAX_INT32 sNMP_SYNTAX_INT
-#define sNMP_SYNTAX_IPADDR (aSN_APPLICATION | aSN_PRIMITIVE | 0x00)
-#define sNMP_SYNTAX_CNTR32 (aSN_APPLICATION | aSN_PRIMITIVE | 0x01)
-#define sNMP_SYNTAX_GAUGE32 (aSN_APPLICATION | aSN_PRIMITIVE | 0x02)
-#define sNMP_SYNTAX_TIMETICKS (aSN_APPLICATION | aSN_PRIMITIVE | 0x03)
-#define sNMP_SYNTAX_OPAQUE (aSN_APPLICATION | aSN_PRIMITIVE | 0x04)
-#define sNMP_SYNTAX_CNTR64 (aSN_APPLICATION | aSN_PRIMITIVE | 0x06)
-#define sNMP_SYNTAX_UINT32 (aSN_APPLICATION | aSN_PRIMITIVE | 0x07)
-
-//-------------------------------------------------------------------------
-
-//---------------[ Exception conditions for SNMPv2 ]-----------------------
-// support SNMP v2
-#define sNMP_SYNTAX_NOSUCHOBJECT (aSN_CONTEXT | aSN_PRIMITIVE | 0x00)
-#define sNMP_SYNTAX_NOSUCHINSTANCE (aSN_CONTEXT | aSN_PRIMITIVE | 0x01)
-#define sNMP_SYNTAX_ENDOFMIBVIEW (aSN_CONTEXT | aSN_PRIMITIVE | 0x02)
-
-
-//--------------[ different types of PDU's ]-------------------------------
-#define sNMP_PDU_GET (aSN_CONTEXT | aSN_CONSTRUCTOR | 0x0)
-#define sNMP_PDU_GETNEXT (aSN_CONTEXT | aSN_CONSTRUCTOR | 0x1)
-#define sNMP_PDU_RESPONSE (aSN_CONTEXT | aSN_CONSTRUCTOR | 0x2)
-#define sNMP_PDU_SET (aSN_CONTEXT | aSN_CONSTRUCTOR | 0x3)
-#define sNMP_PDU_V1TRAP (aSN_CONTEXT | aSN_CONSTRUCTOR | 0x4)
-#define sNMP_PDU_GETBULK (aSN_CONTEXT | aSN_CONSTRUCTOR | 0x5)
-#define sNMP_PDU_INFORM (aSN_CONTEXT | aSN_CONSTRUCTOR | 0x6)
-#define sNMP_PDU_TRAP (aSN_CONTEXT | aSN_CONSTRUCTOR | 0x7)
-
-
-//------[ smi typedefs ]---------------------------------------------------
-// SNMP-related types from RFC1442 (SMI)
-
-typedef unsigned char SmiBYTE, *SmiLPBYTE;
-
-//-------------------------------------------------------------------------
-// SNMP-related types from RFC1442 (SMI)
-
-// int
-typedef long SmiINT, *SmiLPINT;
-
-// int 32
-typedef SmiINT SmiINT32, *SmiLPINT32;
-
-// unit32
-typedef unsigned long SmiUINT32, *SmiLPUINT32;
-
-// octet struct
-typedef struct {
- SmiUINT32 len;
- SmiLPBYTE ptr;} SmiOCTETS, *SmiLPOCTETS;
-
-// bits
-typedef SmiOCTETS SmiBITS, *SmiLPBITS;
-
-// SMI oid struct
-typedef struct {
- SmiUINT32 len;
- SmiLPUINT32 ptr;} SmiOID, *SmiLPOID;
-
-// ipaddr
-typedef SmiOCTETS SmiIPADDR, *SmiLPIPADDR;
-
-// 32bit counter
-typedef SmiUINT32 SmiCNTR32, *SmiLPCNTR32;
-
-// gauge
-typedef SmiUINT32 SmiGAUGE32, *SmiLPGAUGE32;
-
-// timeticks
-typedef SmiUINT32 SmiTIMETICKS, *SmiLPTIMETICKS;
-
-// opaque
-typedef SmiOCTETS SmiOPAQUE, *SmiLPOPAQUE;
-
-// nsapaddr
-typedef SmiOCTETS SmiNSAPADDR, *SmiLPNSAPADDR;
-
-// 64 bit counter
-typedef struct {
- SmiUINT32 hipart;
- SmiUINT32 lopart;
-} SmiCNTR64, *SmiLPCNTR64;
-
-#endif // SMIDEF_
-
-
diff --git a/ASNMP/asnmp/smival.h b/ASNMP/asnmp/smival.h
deleted file mode 100644
index 6e7c8c4c1b9..00000000000
--- a/ASNMP/asnmp/smival.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* -*-C++-*- */
-// $Id$
-#ifndef SMIVALUE_
-#define SMIVALUE_
-// ============================================================================
-//
-// = LIBRARY
-// tests
-//
-// = FILENAME
-// smival.h
-//
-// = DESCRIPTION
-// SMIValue class definition. Superclass for the various types
-// of SNMP values (Address, Oid, Octet, etc.). Provides
-// only a few functions, most info is in subclass.
-//
-// = AUTHOR
-// Jeff Meyer
-//
-// ============================================================================
-/*===================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
-=====================================================================*/
-
-//----[ includes ]-----------------------------------------------------
-#include "asnmp/smi.h"
-
-//----[ macros ]-------------------------------------------------------
-
-//======================================================================
-// SMI value structure conforming with SMI RFC
-//
-typedef struct { /* smiVALUE portion of VarBind */
- SmiUINT32 syntax; /* Insert SNMP_SYNTAX_<type> */
- union {
- SmiINT sNumber; /* SNMP_SYNTAX_INT
- SNMP_SYNTAX_INT32 */
- SmiUINT32 uNumber; /* SNMP_SYNTAX_UINT32
- SNMP_SYNTAX_CNTR32
- SNMP_SYNTAX_GAUGE32
- SNMP_SYNTAX_TIMETICKS */
- SmiCNTR64 hNumber; /* SNMP_SYNTAX_CNTR64 */
- SmiOCTETS string; /* SNMP_SYNTAX_OCTETS
- SNMP_SYNTAX_BITS
- SNMP_SYNTAX_OPAQUE
- SNMP_SYNTAX_IPADDR
- SNMP_SYNTAX_NSAPADDR */
- SmiOID oid; /* SNMP_SYNTAX_OID */
- SmiBYTE empty; /* SNMP_SYNTAX_NULL
- SNMP_SYNTAX_NOSUCHOBJECT
- SNMP_SYNTAX_NOSUCHINSTANCE
- SNMP_SYNTAX_ENDOFMIBVIEW */
- } value;
-} SmiVALUE, *SmiLPVALUE;
-
-// An "abstract" (pure virtual) class that serves as the base class
-// for all specific SNMP syntax types.
-//
-class ACE_Export SnmpSyntax {
-
-public:
- virtual char * to_string() = 0;
- // virtual function for getting a printable ASCII value for any SNMP Value
-
- virtual SmiUINT32 get_syntax() = 0;
- // return the current syntax
-
- virtual SnmpSyntax * clone() const = 0;
- // virtual clone operation for creating a new Value from an existing
- // value. The caller MUST use the delete operation on the return
- // value when done.
-
- virtual ~SnmpSyntax() {};
- // virtual destructor to ensure deletion of derived classes...
-
- virtual SnmpSyntax& operator=( SnmpSyntax &/*val*/)
- {
- return *this;
- }
- // overloaded assignment operator
- // This should be pure virtual, but WinNT compiler
- // complains about unresolved reference at link time.
-
- virtual int valid() const = 0;
- // return validity of value object.
-
-protected:
- SmiVALUE smival;
-};
-
-#endif // SMIVALUE_
diff --git a/ASNMP/asnmp/snmp.cpp b/ASNMP/asnmp/snmp.cpp
deleted file mode 100644
index f6ad69fb25a..00000000000
--- a/ASNMP/asnmp/snmp.cpp
+++ /dev/null
@@ -1,283 +0,0 @@
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// snmp.cpp
-//
-// = DESCRIPTION
-// The basic SNMPv1 API - blocking version using UDP/IPv4 transport
-// and addressing.
-//
-// = AUTHOR
-// Peter E Mellquist class design/orig code
-// Michael R MacFaden mrm@cisco.com / rework API, use ACE facilities
-// ============================================================================
-/*===================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
-=====================================================================*/
-
-
-#define INCLUDE_SNMP_ERR_STRINGS_
-
-//----[ snmp++ includes ]----------------------------------------------
-#include "asnmp/snmp.h" // class def for this module
-#include "asnmp/oid.h" // class def for oids
-#include "asnmp/enttraps.h" // class def for well known trap oids
-#include "asnmp/vb.h" // class def for vbs
-#include "asnmp/address.h" // class def for addresses
-#include "asnmp/wpdu.h" // adapter to cmu_library / wire protocol
-#include "asnmp/transaction.h" // synchronous transaction processor
-
-ACE_RCSID(asnmp, snmp, "$Id$")
-
-const coldStartOid coldStart;
-const warmStartOid warmStart;
-const linkDownOid linkDown;
-const linkUpOid linkUp;
-const authenticationFailureOid authenticationFailure;
-const egpNeighborLossOid egpNeighborLoss;
-const snmpTrapEnterpriseOid snmpTrapEnterprise;
-
-char Snmp::host_name_[MAXHOSTNAMELEN] = "";
-
-Snmp::Snmp(unsigned short port): result_(0), construct_status_(SNMP_CLASS_ERROR), last_transaction_status_(0)
-{
- ACE_TRACE("Snmp::Snmp");
-
- ACE_INET_Addr addr(port); // any port,address is ok
- if (iv_snmp_session_.open(addr) < 0) {
- last_transaction_status_ = errno; // open udp/ipv4 socket
- ACE_DEBUG((LM_DEBUG, "Snmp::snmp::open port %d failed", port));
- return;
- }
-
- // initial request id randomly generated then monotonically incremented
- req_id_ = (unsigned) ACE_OS::time(0);
-
- construct_status_ = SNMP_CLASS_SUCCESS;
- return;
-}
-
-Snmp::~Snmp()
-{
- ACE_TRACE("Snmp::~Snmp");
- iv_snmp_session_.close();
-}
-
-int Snmp::valid() const
-{
- return construct_status_;
-}
-
-// given error code, return string definition
-// class version
-// static
-char * Snmp::error_string(int last_transaction_status_)
-{
- ACE_TRACE("Snmp::error_string");
-
- return ((last_transaction_status_ < 0) ?
- ((last_transaction_status_ < MAX_NEG_ERROR)?
- nErrs[ abs(MAX_NEG_ERROR) + 1] : nErrs[abs(last_transaction_status_)]):
- ((last_transaction_status_ > MAX_POS_ERROR)?
- pErrs[MAX_POS_ERROR+1] : pErrs[last_transaction_status_]));
-}
-
-// instance version
-char * Snmp::error_string()
-{
- return Snmp::error_string(last_transaction_status_);
-}
-
-void Snmp::check_default_port(UdpTarget& target, unsigned short port)
-{
- UdpAddress tmp;
- target.get_address(tmp);
- if (tmp.get_port() == 0) {
- tmp.set_port(port);
- target.set_address(tmp);
- }
-}
-
-int Snmp::run_transaction(Pdu& pdu, UdpTarget& target)
-{
- int rc, done = 0;
-
- // 1. set unique id to match this packet on return
- size_t hold_req_id = req_id_++;
- set_request_id(&pdu, hold_req_id);
-
- // 2. write request to agent
- transaction trans(pdu, target, iv_snmp_session_);
-
- // this call blocks while it attempts to retrieve agent response
- while (!done) {
- if ((rc = trans.run()) < 0) {
- last_transaction_status_ = rc;
- return rc;
- }
- else {
- trans.result(pdu);
- // verify this is the pdu we are after
- if (pdu.get_request_id() == hold_req_id)
- done = 1 ;
- }
- }
- return 0;
-}
-
-int Snmp::run_transaction(Pdu& pdu, UdpTarget& target, Snmp_Result * cb)
-{
- if (!cb)
- return run_transaction(pdu, target);
-
- // 1. set unique id to match this packet on return
- hold_req_id_ = req_id_++;
- set_request_id(&pdu, hold_req_id_);
- pdu_ = &pdu;
- result_ = cb;
-
- // 2. write request to agent
- transaction * trans = new transaction(pdu, target, iv_snmp_session_);
- return trans->run(this);
-}
-
-void Snmp::result(transaction *t, int rc)
-{
- t->result(*pdu_);
- // verify this is the pdu we are after
- if (pdu_->get_request_id() == hold_req_id_)
- {
- last_transaction_status_ = rc;
- delete t;
- result_->result(this, rc);
- }
- else
- {
- rc = t->run(this);
- if (rc < 0)
- {
- delete t;
- result_->result(this, rc);
- }
- }
-}
-
-int Snmp::validate_args(const Pdu& pdu, const UdpTarget& target) const
-{
- // 0. check object status
- if (construct_status_ != SNMP_CLASS_SUCCESS)
- return construct_status_;
-
- // 1. check args passed
- if ( !pdu.valid() || !target.valid() )
- return SNMP_INVALID_ARGS;
- return 0;
-}
-
-// SYNC API: write request to wire then wait for reply or timeout
-int Snmp::get( Pdu &pdu, UdpTarget &target, Snmp_Result * cb)
-{
- ACE_TRACE("Snmp::get");
- int rc;
- if ((rc = validate_args(pdu, target)) != 0)
- return rc;
-
- pdu.set_type( sNMP_PDU_GET);
- check_default_port(target);
- return run_transaction(pdu, target, cb);
-}
-
-int Snmp::get_next( Pdu &pdu, UdpTarget &target, Snmp_Result * cb)
-{
- ACE_TRACE("Snmp::get_next");
- int rc;
- if ((rc = validate_args(pdu, target)) != 0)
- return rc;
-
- pdu.set_type( sNMP_PDU_GETNEXT);
- check_default_port(target);
- return run_transaction(pdu, target, cb);
-}
-
-int Snmp::set( Pdu &pdu, UdpTarget &target, Snmp_Result * cb)
-{
- ACE_TRACE("Snmp::set");
- int rc;
- if ((rc = validate_args(pdu, target)) != 0)
- return rc;
-
- pdu.set_type( sNMP_PDU_SET);
- check_default_port(target);
- return run_transaction(pdu, target, cb);
-}
-
-// one way, best of luck, non-confirmed alert
-int Snmp::trap( Pdu &pdu, UdpTarget &target)
-{
- ACE_TRACE("Snmp::trap");
- int rc;
- if ((rc = validate_args(pdu, target)) != 0)
- return rc;
-
- pdu.set_type( sNMP_PDU_V1TRAP);
- check_default_port(target, DEF_TRAP_PORT);
-
- // 2. write request to agent
- transaction trans(pdu, target, iv_snmp_session_);
- if (trans.send() > 0) // expect number of bytes sent on
- return 0;
-
- last_transaction_status_ = SNMP_CLASS_INTERNAL_ERROR;
- return -1;
-}
-
-// Allow host name to be overriden. Supplying a null pointer or zero
-// length string removes the override.
-void Snmp::override_host_name(const char* name)
-{
- if (name)
- {
- ACE_OS::strncpy(host_name_, name, MAXHOSTNAMELEN);
- host_name_[MAXHOSTNAMELEN-1] = 0;
- }
- else {
- host_name_[0] = 0;
- }
-}
-
-// Returns the current host name in the supplied string.
-void Snmp::get_host_name(char* name, int len)
-{
- if (name)
- {
- if (ACE_OS::strlen(host_name_) > 0)
- {
- ACE_OS::strncpy(name, host_name_, len);
- name[len-1] = 0;
- }
- else
- {
- if (ACE_OS::hostname(name, len-1) == -1)
- name[0] = 0;
- }
- }
-}
-
-Snmp_Result::~Snmp_Result() {}
diff --git a/ASNMP/asnmp/snmp.h b/ASNMP/asnmp/snmp.h
deleted file mode 100644
index d57a9711324..00000000000
--- a/ASNMP/asnmp/snmp.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/* -*-C++-*- */
-// $Id$
-#ifndef SNMP_CLS_
-#define SNMP_CLS_
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// snmp.h
-//
-// = DESCRIPTION
-// SNMP class defintion. The Snmp class provides an object oriented
-// approach to SNMP. The SNMP class is an encapsulation of SNMP
-// sessions, gets, sets, etc. The class manages all SNMP
-// resources and provides complete retry and timeout capability.
-//
-// = AUTHOR
-// Peter E Mellquist design, first implementation
-// Michael R. MacFaden port to ACE / use Reactor pattern
-//
-// ============================================================================
-/*===================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
-=====================================================================*/
-
-#include "ace/Reactor.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-# pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-#include "ace/SOCK_Dgram.h"
-
-#include "asnmp/oid.h" // snmp++ oid class
-#include "asnmp/vb.h" // snbmp++ vb class
-#include "asnmp/target.h" // snmp++ target class
-#include "asnmp/pdu.h" // snmp++ pdu class
-#include "asnmp/snmperrs.h" // error macros and strings
-#include "asnmp/address.h" // snmp++ address class defs
-#include "asnmp/transaction_result.h"
-
-class Snmp;
-class ACE_Export Snmp_Result
-{
- public:
- virtual ~Snmp_Result();
- virtual void result(Snmp *snmp, int result) = 0;
-};
-
-// Snmp session class - supports Version 1 operations in blocking mode
-class ACE_Export Snmp : public transaction_result
- // = TITLE
- // Concrete class Snmp defined the session and interface to
- // communicate with another SNMP Version 1 agent
-{
- Snmp_Result * result_;
- Pdu * pdu_;
- unsigned hold_req_id_;
- public:
- Snmp(unsigned short port = INADDR_ANY);
- virtual ~Snmp();
-
- int get( Pdu &pdu, UdpTarget &target, Snmp_Result * cb = 0);
- // retrieve data from a peer agent for a given list of oid values
- // default port 161
-
- int get_next( Pdu &pdu, UdpTarget &target, Snmp_Result * cb = 0);
- // retrieve data lexically adjacent to the oids specified in the pdu
- // from the peer agent
- // default port 161
-
- int set( Pdu &pdu, UdpTarget &target, Snmp_Result * cb = 0);
- // set data in the agent from the list of oids in the pdu
- // default port 161
-
- int trap( Pdu &pdu, UdpTarget &target);
- // send an SNMPv1 trap (unreliable) to a remote system (def port 162)
-
- int valid() const;
- // status of object after construction
-
- static char * error_string(int code);
- // given error code, return string reason
-
- char * error_string();
- // retrieve a reason string if any of the above commands fail
-
- void result(transaction * t, int rc);
- // for async transaction results
-
- static void override_host_name(const char* name);
- // allow the host name to be overriden
-
- static void get_host_name(char* name, int len);
- // returns the overriden host name
-
- protected:
- void check_default_port(UdpTarget& target,unsigned short port=DEF_AGENT_PORT);
- int run_transaction(Pdu& pdu, UdpTarget& target);
- int run_transaction(Pdu& pdu, UdpTarget& target, Snmp_Result * cb);
- int validate_args(const Pdu& pdu, const UdpTarget& target) const;
-
- Snmp(const Snmp&);
-
- ACE_SOCK_Dgram iv_snmp_session_;
- // io object
-
- int construct_status_;
- // status of construction
-
- int last_transaction_status_;
- // result code from last transaction
-
- unsigned req_id_;
- // transaction request id
-
- static char host_name_[MAXHOSTNAMELEN];
-};
-
-#endif //SNMP_CLS_
diff --git a/ASNMP/asnmp/snmperrs.h b/ASNMP/asnmp/snmperrs.h
deleted file mode 100644
index bd7a5e9df56..00000000000
--- a/ASNMP/asnmp/snmperrs.h
+++ /dev/null
@@ -1,214 +0,0 @@
-/* -*-C++-*- */
-// $Id$
-#ifndef SNMPERRS_H_
-#define SNMPERRS_H_
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// snmperrs.h
-//
-// = DESCRIPTION
-// Definition of error macros and error strings
-//
-// = AUTHOR
-// Jeff Meyer
-//
-// ============================================================================
-/*===================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
-============================================================================*/
-
-
-//-------[ Positive ASNMP Error Return Codes ]------------------------------
-// These values are error status values from RFC 1905
-//
-// The values can be returned via Pdu::get_error_status()
-//
-#define SNMP_ERROR_SUCCESS 0 // Success Status
-#define SNMP_ERROR_TOO_BIG 1 // Pdu encoding too big
-#define SNMP_ERROR_NO_SUCH_NAME 2 // No such VB name, see error index
-#define SNMP_ERROR_BAD_VALUE 3 // Bad Vb
-#define SNMP_ERROR_READ_ONLY 4 // VB is read only, see error index
-#define SNMP_ERROR_GENERAL_VB_ERR 5 // General VB error, see error index
-#define SNMP_ERROR_NO_ACCESS 6 // No access to MIBs data
-#define SNMP_ERROR_WRONG_TYPE 7 // Requested type was incorrect
-#define SNMP_ERROR_WRONG_LENGTH 8 // Request Pdu has inccorect length
-#define SNMP_ERROR_WRONG_ENCODING 9 // Request Pdu has wrong encoding
-#define SNMP_ERROR_WRONG_VALUE 10 // Request Pdu has wrong value
-#define SNMP_ERROR_NO_CREATION 11 // Unable to create object specified
-#define SNMP_ERROR_INCONSIST_VAL 12 // Inconsistent value in request
-#define SNMP_ERROR_RESOURCE_UNAVAIL 13 // Resources unavailable
-#define SNMP_ERROR_COMITFAIL 14 // Unable to comit
-#define SNMP_ERROR_UNDO_FAIL 15 // Unable to undo
-#define SNMP_ERROR_AUTH_ERR 16 // Authentication failure
-#define SNMP_ERROR_NOT_WRITEABLE 17 // Mib Object not writeable
-#define SNMP_ERROR_INCONSIS_NAME 18 // Inconsistent naming used
-
-
-//-------[ Negative ASNMP Result/Error Return Codes ]-------------------
-
-// General
-#define SNMP_CLASS_SUCCESS 0 // success
-#define SNMP_CLASS_ERROR -1 // general error
-#define SNMP_CLASS_RESOURCE_UNAVAIL -2 // e.g., malloc failed
-#define SNMP_CLASS_INTERNAL_ERROR -3 // unexpected / internal error
-#define SNMP_CLASS_UNSUPPORTED -4 // unsupported function
-
-// Callback reasons:
-#define SNMP_CLASS_TIMEOUT -5 // outstanding request timed out
-#define SNMP_CLASS_ASYNC_RESPONSE -6 // received response for outstd request
-#define SNMP_CLASS_NOTIFICATION -7 // received notification (trap/inform)
-#define SNMP_CLASS_SESSION_DESTROYED -8 // snmp::destroyed with oustanding reqs pending
-
-// Snmp Class:
-#define SNMP_CLASS_INVALID -10 // snmp::mf called on invalid instance
-#define SNMP_CLASS_INVALID_PDU -11 // invalid pdu passed to mf
-#define SNMP_CLASS_INVALID_TARGET -12 // invalid target passed to mf
-#define SNMP_CLASS_INVALID_CALLBACK -13 // invalid callback to mf
-#define SNMP_CLASS_INVALID_REQID -14 // invalid request id to cancel
-#define SNMP_CLASS_INVALID_NOTIFYID -15 // missing trap/inform oid
-#define SNMP_CLASS_INVALID_OPERATION -16 // snmp operation not allowed for specified target
-#define SNMP_CLASS_INVALID_OID -17 // invalid oid passed to mf
-#define SNMP_CLASS_INVALID_ADDRESS -18 // invalid address passed to mf
-#define SNMP_CLASS_ERR_STATUS_SET -19 // agent returned response pdu with error_status set
-
-// Transport Errors:
-#define SNMP_CLASS_TL_UNSUPPORTED -20 // transport unsupported
-#define SNMP_CLASS_TL_IN_USE -21 // transport in use
-#define SNMP_CLASS_TL_FAILED -22 // transport operation failed
-
-// extras
-#define SNMP_CLASS_SHUTDOWN -23 // used for back door shutdown
-#define SNMP_INVALID_ARGS -24 // invalid args passed
-
-#ifdef INCLUDE_SNMP_ERR_STRINGS_
-
-// ASCII strings returned through Snmp::error() function. NOTE: altering
-// the strings in this header file will not affect the return values of
-// Snmp::error(), unless you rebuild the ASNMP library from source.
-
-#define MAX_POS_ERROR SNMP_ERROR_INCONSIS_NAME
-#define MAX_NEG_ERROR SNMP_CLASS_SHUTDOWN
-
-static char * pErrs[] = {
- "Success", // 0
- "SNMP: Response PDU Too Big", // 1
- "SNMP: Variable does not exist", // 2
- "SNMP: Cannot modify variable: Bad Value", // 3
- "SNMP: Cannot modify object, Read Only", // 4
- "SNMP: Cannot perform operation, General Error", // 5
- "SNMP: Cannot access variable, No Access", // 6
- "SNMP: Cannot create/modify variable, Wrong Type", // 7
- "SNMP: Cannot create/set variable, Wrong Length", // 8
- "SNMP: Cannot create/set variable, Wrong Encoding", // 9
- "SNMP: Cannot create/set variable, Wrong Value", // 10
- "SNMP: Cannot create variable, Creation Not Allowed", // 11
- "SNMP: Cannot create/set variable, Inconsistent Value", // 12
- "SNMP: Cannot create/set variable, Resource Unavailable", // 13
- "SNMP: Cannot create/set variable, Commit Failed", // 14
- "SNMP: Cannot create/set variable, Undo Failed", // 15
- "SNMP: Cannot perform operation, Authorization Error", // 16
- "SNMP: Cannot create/set variable, Not Writable", // 17
- "SNMP: Cannot create variable, Inconsistent Name", // 18
-};
-
-
-static char * nErrs[] = {
- // General:
- // 0 SNMP_CLASS_SUCCESS
- "ASNMP: Success",
-
- // 1 SNMP_CLASS_ERROR
- "ASNMP: Operation failed",
-
- // 2 SNMP_CLASS_RESOURCE_UNAVAIL
- "ASNMP: Resource unavailable",
-
- // 3 SNMP_CLASS_INTERNAL_ERROR
- "ASNMP: Internal error",
-
- // 4 SNMP_CLASS_UNSUPPORTED
- "ASNMP: Unsupported function",
-
- // Callback reasons:
- // 5 SNMP_CLASS_TIMEOUT
- "ASNMP: SNMP request timed out",
-
- // 6 SNMP_CLASS_ASYNC_RESPONSE
- "ASNMP: Received SNMP Response",
-
- // 7 SNMP_CLASS_NOTIFICATION
- "ASNMP: Received SNMP Notification (trap or inform)",
-
- // 8 SNMP_CLASS_SESSION_DESTROYED
- "ASNMP: Closing session with outstanding requests",
-
- // 9 reserved for future
- "Unknown error code",
-
- // Snmp Class errors:
- // 10 SNMP_CLASS_INVALID
- "ASNMP: Class not valid",
-
- // 11 SNMP_CLASS_INVALID_PDU
- "ASNMP: Invalid Pdu",
-
- // 12 SNMP_CLASS_INVALID_TARGET
- "ASNMP: Invalid Target",
-
- // 13 SNMP_CLASS_INVALID_CALLBACK
- "ASNMP: Invalid (null) Callback Function",
-
- // 14 SNMP_CLASS_INVALID_REQID
- "ASNMP: Invalid Request Id",
-
- // 15 SNMP_CLASS_INVALID_NOTIFYID
- "ASNMP: Invalid Notification Id",
-
- // 16 SNMP_CLASS_INVALID_OPERATION
- "ASNMP: SNMP Operation not supported on specified Target",
-
- // 17 SNMP_CLASS_INVALID_OID
- "ASNMP: Invalid Object Identifier",
-
- // 18 SNMP_CLASS_INVALID_ADDRESS
- "ASNMP: Invalid Address",
-
- // 19 SNMP_CLASS_ERR_STATUS_SET
- "ASNMP: Agent indicates error in SNMP request",
-
- // Transport Errors:
- // 20 SNMP_CLASS_TL_UNSUPPORTED
- "ASNMP: Transport is not supported",
-
- // 21 SNMP_CLASS_TL_IN_USE
- "ASNMP: Transport is in use",
-
- // 22 SNMP_CLASS_TL_FAILED
- "ASNMP: Transport operation failed",
-
- // 23 SNMP_CLASS_SHUTDOWN
- "ASNMP: Blocked Mode Shutdown",
-
- // unknown error code
- "Unknown error code",
-};
-
-#endif //INCLUDE_SNMP_ERR_STRINGS_
-
-#endif //SNMPERRS_H_
diff --git a/ASNMP/asnmp/target.cpp b/ASNMP/asnmp/target.cpp
deleted file mode 100644
index c9e27865f31..00000000000
--- a/ASNMP/asnmp/target.cpp
+++ /dev/null
@@ -1,324 +0,0 @@
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// target.cpp
-//
-// = DESCRIPTION
-// Target class defines target SNMP agents.
-//
-// = AUTHOR
-// Peter E Mellquist
-// Michael R MacFaden mrm@cisco.com - rework & ACE port
-// ============================================================================
-/*===================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
- =====================================================================*/
-
-#include "asnmp/target.h"
-
-ACE_RCSID(asnmp, target, "$Id$")
-
-//----------------------------------------------------------------------
-//--------[ Class default values ]----------------------
-//----------------------------------------------------------------------
-u_long SnmpTarget::default_timeout_ = DEF_TIMEOUT;
-int SnmpTarget::default_retries_ = DEF_RETRIES;
-u_long SnmpTarget::default_max_pdu_size_ = DEF_MAX_SNMP_PACKET;
-snmp_version SnmpTarget::default_version_ = version1;
-
-OctetStr UdpTarget::default_rd_community_(READ_COMM_STR);
-OctetStr UdpTarget::default_wr_community_(WRITE_COMM_STR);
-
-//----------------------------------------------------------------------
-//--------[ Abstract SnmpTarget Member Functions ]----------------------
-//----------------------------------------------------------------------
-SnmpTarget::SnmpTarget():
- validity_(0), timeout_(default_timeout_), retries_(default_retries_),
- max_pdu_size_(default_max_pdu_size_), version_(default_version_)
-{
-}
-
-// return validity of target
-int SnmpTarget::valid() const
-{
- return validity_;
-}
-
-// allow destruction of derived classes
-SnmpTarget::~SnmpTarget()
-{
-}
-
-// set the timeout
-void SnmpTarget::set_timeout( const u_long t)
-{
- timeout_ = t;
-}
-
-// change the default timeout
-void SnmpTarget::set_default_timeout( const u_long t)
-{
- default_timeout_ = t;
-}
-
-// set the retry value
-void SnmpTarget::set_retry( const int r)
-{
- retries_ = r;
-}
-
-// change the default retries
-void SnmpTarget::set_default_retry( const int r)
-{
- default_retries_ = r;
-}
-
-void SnmpTarget:: set_max_pdu_size(const u_long max_pdu_sz)
-{
- max_pdu_size_ = max_pdu_sz;
-}
-
-
-void SnmpTarget::set_default_max_pdu_size(const u_long max_pdu_sz)
-{
- default_max_pdu_size_ = max_pdu_sz;
-}
-
-void SnmpTarget::set_version( const snmp_version v)
-{
- version_ = v;
-}
-
-void SnmpTarget::set_default_version( const snmp_version v)
-{
- default_version_ = v;
-}
-
-snmp_version SnmpTarget::get_version() const
-{
- return version_;
-}
-
-snmp_version SnmpTarget::get_default_version() const
-{
- return default_version_;
-}
-
-u_long SnmpTarget::get_max_pdu_size() const
-{
- return max_pdu_size_;
-}
-
-// get the retry value
-int SnmpTarget::get_retry() const
-{
- return retries_;
-}
-
-// get the retry value
-int SnmpTarget::get_default_retry() const
-{
- return default_retries_;
-}
-
-// get the timeout
-u_long SnmpTarget::get_timeout() const
-{
- return timeout_;
-}
-
-SnmpTarget& SnmpTarget::operator=(const SnmpTarget& lhs)
-{
- if (this == &lhs)
- return *this;
-
- validity_ = lhs.validity_;
- timeout_ = lhs.timeout_;
- retries_ = lhs.retries_;
- max_pdu_size_ =lhs.max_pdu_size_;
- version_ = lhs.version_;
- return *this;
-}
-
-int operator==(const SnmpTarget& lhs, const SnmpTarget& rhs)
-{
- if (lhs == rhs)
- return 1;
-
- if (lhs.timeout_ != rhs.timeout_)
- return 0;
-
- if (lhs.retries_ != rhs.retries_)
- return 0;
-
- if (lhs.max_pdu_size_ != rhs.max_pdu_size_)
- return 0;
-
- if (lhs.version_ != rhs.version_)
- return 0;
-
- return 1;
-}
-
-
-//----------------------------------------------------------------------
-//--------[ IpTarget Member Functions ]----------------------------------
-//----------------------------------------------------------------------
-
-
-//---------[ UdpTarget::UdpTarget( void) ]----------------------------------
-
-UdpTarget::UdpTarget()
-{
- validity_ = 0;
- read_community_ = default_rd_community_; // assign by init fails
- write_community_ = default_wr_community_;
-}
-
-UdpTarget::UdpTarget(const UdpAddress& udp) : udp_address_(udp)
-{
- if (udp_address_.valid())
- validity_ = 1;
- read_community_ = default_rd_community_;
- write_community_ = default_wr_community_;
-}
-
-// - copy constructor can be synthesised by compiler
-
-//-----------[ UdpTarget::~UdpTarget() ]--------------------------------
-UdpTarget::~UdpTarget()
-{
-}
-
-//-----------[ UdpTarget::clone() ]--------------------------------
-SnmpTarget * UdpTarget::clone() const
-{
- return (SnmpTarget *) new UdpTarget(*this);
-}
-
-
-void UdpTarget::set_default_read_community(const OctetStr& rd_community)
-{
- default_rd_community_ = rd_community;
-}
-
-void UdpTarget::set_default_write_community(const OctetStr& wr_community)
-{
- default_wr_community_ = wr_community;
-}
-
-
-// get the read community name as an u_char and len
-void UdpTarget::get_read_community( OctetStr& read_community_oct) const
-{
- read_community_oct = read_community_;
-}
-
-//---------[ UdpTarget::set_getcommunity ]---------------------------------
-// set the read community name
-void UdpTarget::set_read_community( const OctetStr& new_read_community)
-{
- read_community_ = new_read_community;
-}
-
-//---------[ UdpTarget::get_writecommunity ]----------------------------
-// get the write community
-void UdpTarget::get_write_community( OctetStr &write_community_oct) const
-{
- write_community_oct = write_community_;
-}
-
-//-----------[ UdpTarget::set_writecommunity ]---------------------------
-// set the write community
-void UdpTarget::set_write_community( const OctetStr& write_community_oct)
-{
- write_community_ = write_community_oct;
-}
-
-//------------[ Address& UdpTarget::get_address() ]---------------------
-// get the address
-void UdpTarget::get_address( UdpAddress &address) const
-{
- address = udp_address_;
- return;
-}
-
-//-------------[ UdpTarget::set_address ]--------------------------------
-// set the address
-int UdpTarget::set_address( UdpAddress &udp_address)
-{
- udp_address_ = udp_address;
- if ( udp_address_.valid())
- validity_ = 1;
- else
- validity_ = 0;
-
- return validity_;
-}
-
-// overloaded assignment
-UdpTarget& UdpTarget::operator=( const UdpTarget& lhs)
-{
- if (this == &lhs)
- return *this;
-
- // assign base part
- *((SnmpTarget *) this) = *((SnmpTarget *)&lhs);
-
- udp_address_ = lhs.udp_address_;
- read_community_ = lhs.read_community_;
- write_community_ = lhs.write_community_;
- validity_ = lhs.validity_;
-
- return *this;
-}
-
-char *UdpTarget::to_string()
-{
- sprintf(output_buffer_,"UdpTarget: [ valid: %d addr: %s rd: %s wr: %s \
-ver: %d, timeout: %d, retries: %d max_pdu_size: %d]",
- valid(), udp_address_.to_string(), read_community_.to_string(),
- write_community_.to_string(), version_, (int) timeout_,
- retries_, max_pdu_size_);
- return output_buffer_;
-}
-
-//=============[ int operator == UdpTarget, UdpTarget ]===============
-// equivlence operator overloaded
-int operator==( const UdpTarget &lhs,const UdpTarget &rhs)
-{
- // need to compare all the members of a UdpTarget
- if ( lhs.read_community_ != rhs.read_community_)
- return 0; // !=
-
- if ( lhs.write_community_ != rhs.write_community_)
- return 0; // !=
-
- if ( lhs.udp_address_ != rhs.udp_address_)
- return 0;
-
- if ( lhs.timeout_ != rhs.timeout_)
- return 0;
-
- if ( lhs.retries_ != rhs.retries_)
- return 0;
-
- return 1; // they are equal
-}
diff --git a/ASNMP/asnmp/target.h b/ASNMP/asnmp/target.h
deleted file mode 100644
index 7dfc14ab5d8..00000000000
--- a/ASNMP/asnmp/target.h
+++ /dev/null
@@ -1,252 +0,0 @@
-/* -*-C++-*- */
-// $Id$
-#ifndef TARGET_
-#define TARGET_
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// target.h
-//
-// = DESCRIPTION
-//
-// = AUTHOR
-// Peter E Mellquist
-// Michael R. MacFaden (ported to ACE)
-// ============================================================================
-/*===================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS" without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
-=====================================================================*/
-
-//----[ includes ]------------------------------------------------
-#include "ace/INET_Addr.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-# pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-#include "asnmp/address.h"
-#include "asnmp/oid.h"
-#include "asnmp/octet.h"
-
-//----[ enumerated types for SNMP versions ]-------------------------
-enum snmp_version {
- version1, // 0
- version2c, // 1 (Cisco IOS does not have IOS v2c agent available yet)
- version3 // 2 (IETF working on this version)
-};
-
-// targets contain the following default properties
-enum ASNMP_Defs {
- DEF_TIMEOUT = 1, // unit: seconds
- DEF_RETRIES = 1, // no retry default
- DEF_MAX_SNMP_PACKET = 1430, // maximum pdu len on the wire (eth mtu-ip hdr)
- // split bigger pdus (not implemented yet)
- DEF_AGENT_PORT = 161, // port # for SNMP agent
- DEF_TRAP_PORT = 162, // port # for SNMP trap receiver
- DEF_VERSION = version1, // default SNMP version
- MAX_COMM_STR_LEN = 255, // max value this impl will accept from client
- MAX_TARGET_STRING_REP = 2048 // max value this impl will accept from client
-};
-
-#define READ_COMM_STR "public"
-#define WRITE_COMM_STR "private"
-
-// Abstract class used to provide a virtual interface into Targets
-//
-class ACE_Export SnmpTarget
- // = TITLE
- // Abstract Base class SnmpTarget is used to Collect all transmission
- // details to communicate with an SNMP
-{
- public:
-
- virtual ~SnmpTarget();
- // allow destruction of derived classes
-
- int valid() const;
- // return validity of target
-
- void set_retry( const int r);
- // set the retry value
-
- void set_timeout( const unsigned long t);
- // set the object's timeout (in seconds)
-
- void set_version( const snmp_version v);
- // set the instance version
-
- void set_max_pdu_size(const unsigned long max_pdu_sz);
- // all classes constructed will have this write community string
-
- void set_default_timeout( const unsigned long t);
- // change the "class" default default timeout (in seconds)
-
- void set_default_retry( const int r);
- // change the default send retries
-
- void set_default_max_pdu_size(const unsigned long max_pdu_sz);
- // all classes constructed will have this write community string
-
- void set_default_version( const snmp_version v);
- // change class default
-
- // *** get methods ***
-
- int get_default_retry() const;
- // get the retry value
-
- unsigned long get_timeout() const;
- // get the timeout (seconds)
-
- unsigned long get_max_pdu_size() const;
- // get instance max buffer size
-
- void get_default_max_pdu_size(const unsigned long max_pdu_sz);
- // all classes constructed will have this write community string
-
- snmp_version get_version() const;
- // get the version
-
- snmp_version get_default_version() const;
-
- int get_retry() const;
- // return send retry number for this instancd
-
- virtual SnmpTarget *clone() const = 0;
- // virtual clone operation for creating a new SnmpTarget from an existing
- // SnmpTarget. The caller MUST use the delete operation on the return
- // value when done.
-
- friend int operator==(const SnmpTarget& lhs, const SnmpTarget& rhs);
- // manipulate the base part
-
- SnmpTarget& operator=(const SnmpTarget& lhs);
-
- protected:
- SnmpTarget();
- // SnmpTarget(const SnmpTarget &);
-
- int validity_;
- // used by derived class instances
-
- unsigned long timeout_;
- // instance value xmit timeout in milli secs
-
- int retries_;
- // instance value number of retries
-
- unsigned max_pdu_size_;
- // size of pdu
-
- snmp_version version_;
- // instance value the snmp version
-
- // class wide default values
- static unsigned long default_timeout_;
- // xmit timeout in secs
-
- static int default_retries_;
- // number of retries
-
- static unsigned long default_max_pdu_size_;
- static snmp_version default_version_;
- // snmp protocol version
-};
-
-//----[ UdpTarget class ]----------------------------------------------
-// UDP/IP transport using "community string" based agents (targets)
-//
-class ACE_Export UdpTarget: public SnmpTarget
- // = TITLE
- // Concrete class UdpTarget contains all Details for communicating
- // with a SNMPv1 agent over UDP/IPv4 transport
-{
- public:
- UdpTarget();
-
- UdpTarget( const UdpAddress& udp);
- // constructor with only address
- // assumes default as public, public
- // can be constructed with IP address object
-
- UdpTarget( ACE_INET_Addr& ace_inet_addr);
- // can be constructed with Udp address object TODO: merge addresses
-
- ~UdpTarget();
- // destructor
-
- // ** set ***
-
- void set_read_community( const OctetStr& new_read_community);
- // set the read community using an OctetStr
-
- void set_write_community( const OctetStr& write_community);
- // set the write community using an OctetStr
-
- int set_address( UdpAddress &udp_address);
- // set the address
-
- // ** get ***
-
- void get_read_community( OctetStr& read_community_oct) const;
- // get the read community as an Octet Str object
-
- void get_write_community( OctetStr &write_community_oct) const;
- // get the write community as an OctetStr
-
- void get_address( UdpAddress& address) const;
- // get the address
-
- void set_default_read_community(const OctetStr& rd_community);
- // all classes constructed will have this read community string
-
- void set_default_write_community(const OctetStr& wr_community);
- // all classes constructed will have this write community string
-
- void get_default_read_community(OctetStr& rd_community) const;
- // all classes constructed will have this read community string
-
- void get_default_write_community(OctetStr& wr_community) const;
- // all classes constructed will have this write community string
-
- UdpTarget& operator=( const UdpTarget& target);
- // overloaded assignment
-
- friend int operator==( const UdpTarget &lhs, const UdpTarget &rhs);
- // compare two C targets
-
- char *to_string();
- // string representation of object
-
- SnmpTarget *clone() const;
- // clone from existing UdpTarget
-
- protected:
- static OctetStr default_rd_community_;
- static OctetStr default_wr_community_;
- OctetStr read_community_;
- OctetStr write_community_;
- UdpAddress udp_address_;
- snmp_version version_;
-
- char output_buffer_[MAX_TARGET_STRING_REP];
- // to_string() rep of data
-};
-
-
-#endif //TARGET_
diff --git a/ASNMP/asnmp/timetick.cpp b/ASNMP/asnmp/timetick.cpp
deleted file mode 100644
index 06fd025797f..00000000000
--- a/ASNMP/asnmp/timetick.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// timetick.cpp
-//
-// = DESCRIPTION
-// Class implentation for SMI Timeticks class.
-//
-// = AUTHOR
-// Peter E Mellquist
-// Michael R MacFaden mrm@cisco.com - rework & ACE port
-// ============================================================================
-/*===================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
-=====================================================================*/
-
-#include "asnmp/timetick.h" // include header file for timetick class
-
-ACE_RCSID(asnmp, timetick, "$Id$")
-
-// constructor with a value
-TimeTicks::TimeTicks( const unsigned long i):SnmpUInt32(i)
-{
- smival.syntax = sNMP_SYNTAX_TIMETICKS;
-}
-
-// copy constructor
-TimeTicks::TimeTicks( const TimeTicks &t)
-{
- smival.value.uNumber = t.smival.value.uNumber;
- smival.syntax = sNMP_SYNTAX_TIMETICKS;
-}
-
-// destructor
-TimeTicks::~TimeTicks()
-{
-}
-
-// syntax type
-SmiUINT32 TimeTicks::get_syntax()
-{
- return sNMP_SYNTAX_TIMETICKS;
-}
-
-// create a new instance of this Value
-SnmpSyntax *TimeTicks::clone() const
-{
- return (SnmpSyntax *) new TimeTicks(*this);
-}
-
-// overloaded assignement from ulong
-TimeTicks& TimeTicks::operator=( const unsigned long int i)
-{
- smival.value.uNumber =i; return *this;
-}
-
-// overloaded assignment from TimeTicks
-TimeTicks& TimeTicks::operator=( const TimeTicks &uli)
-{
- this->smival.value.uNumber = uli.smival.value.uNumber; return *this;
-}
-
-// general assignment from any Value
-SnmpSyntax& TimeTicks::operator=( SnmpSyntax &in_val)
-{
- if ( this == &in_val ) // handle assignement from itself
- return *this;
-
- valid_flag = 0; // will get set true if really valid
- if (in_val.valid()) {
- switch (in_val.get_syntax()) {
- case sNMP_SYNTAX_UINT32:
- // case sNMP_SYNTAX_GAUGE32: .. indistinquishable from UINT32
- case sNMP_SYNTAX_CNTR32:
- case sNMP_SYNTAX_TIMETICKS:
- case sNMP_SYNTAX_INT32: // implied cast int -> uint
- this->smival.value.uNumber =
- ((TimeTicks &)in_val).smival.value.uNumber;
- valid_flag = 1;
- break;
- }
- }
- return *this;
-}
-
-// otherwise, behave like an unsigned long
-TimeTicks::operator unsigned long()
-{
- return smival.value.uNumber;
-}
-
-
-// ASCII format return
-char * TimeTicks::to_string()
- /* Should do something nicer like days:hours:minutes... */
-{
- unsigned long tt, hseconds, seconds, minutes, hours, days;
- tt = this->smival.value.uNumber;
-
- // days
- days = tt / 8640000;
- tt %= 8640000;
-
- // hours
- hours = tt / 360000;
- tt %= 360000;
-
- // minutes
- minutes = tt / 6000;
- tt %= 6000;
-
- seconds = tt / 100;
- tt %= 100;
-
- hseconds = tt;
-
- if ( days ==0)
- sprintf( output_buffer,"%ld:%02ld:%02ld.%02ld", hours, minutes,seconds,hseconds);
- else if ( days==1)
- sprintf( output_buffer,"1 day %ld:%02ld:%02ld.%02ld", hours, minutes,seconds,hseconds);
- else
- sprintf( output_buffer,"%ld days, %ld:%02ld:%02ld.%02ld", days,hours, minutes,seconds,hseconds);
-
- return output_buffer;
-}
diff --git a/ASNMP/asnmp/timetick.h b/ASNMP/asnmp/timetick.h
deleted file mode 100644
index 8e4609c124b..00000000000
--- a/ASNMP/asnmp/timetick.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* -*-C++-*- */
-// $Id$
-#ifndef TIMETICKS_
-#define TIMETICKS_
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// timetick.h
-//
-// = DESCRIPTION
-// Class definition for SMI Timeticks class.
-//
-// = AUTHOR
-// Michael R. MacFaden <mrm@cisco.com>
-//
-// ============================================================================
-/*===================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
-=====================================================================*/
-
-#include "asnmp/integer.h"
-
-#define TICKOUTBUF 30 // max formatted time string
-
-//------------[ TimeTicks Class ]-----------------------------------
-// The timeticks class allows all the functionality of unsigned
-// integers but is recognized as a distinct SMI type. TimeTicks
-// objects may be get or set into Vb objects.
-//
-class ACE_Export TimeTicks: public SnmpUInt32
- // = TITLE
- // Define RFC1155 TimeTicks Data object
-
-{
-
- public:
- TimeTicks( const unsigned long i = 0);
-
- TimeTicks( const TimeTicks &t);
- // copy constructor
-
- ~TimeTicks();
- // destructor
-
- SmiUINT32 get_syntax();
- // syntax type
-
- char *to_string();
- // get a printable ASCII value
-
- SnmpSyntax *clone() const;
- // create a new instance of this Value
-
- SnmpSyntax& operator=(SnmpSyntax &val);
- // copy an instance of this Value
-
- TimeTicks& operator=( const TimeTicks &uli);
- // overloaded assignment
-
- TimeTicks& operator=( const unsigned long int i);
- // overloaded assignment
-
- operator unsigned long();
- // otherwise, behave like an unsigned long
-
- protected:
- char output_buffer[TICKOUTBUF];
- // for storing printed form
-};
-#endif // TIMETICKS_
diff --git a/ASNMP/asnmp/transaction.cpp b/ASNMP/asnmp/transaction.cpp
deleted file mode 100644
index 4c22b0f51e4..00000000000
--- a/ASNMP/asnmp/transaction.cpp
+++ /dev/null
@@ -1,202 +0,0 @@
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// transaction.cpp
-//
-// = DESCRIPTION
-// implements blocking SNMPv1 API using a simple state machine
-// transactions over UDP/IP networks
-//
-// = AUTHOR
-// Michael R MacFaden mrm@cisco.com - remove v2c, async, rework for ACE
-// ============================================================================
-
-#include "ace/Reactor.h"
-#include "asnmp/transaction.h"
-
-ACE_RCSID(asnmp, transaction, "$Id$")
-
-// pre: pdu, target report valid() == 1
-// post: pdu sent out over the wire
-inline void reset_receive_buffer(iovec& io)
-{
- io.iov_base = 0;
- io.iov_len = 0;
-}
-
-transaction::transaction(const Pdu& pdu, const UdpTarget& target,
- ACE_SOCK_Dgram& io):
- result_(0),
- wp_(pdu,target), params_(target), session_(io)
-{
- // last step, convert address (get ride of this once we have merged address
- UdpAddress udp;
- target.get_address(udp);
- // via string conversion "dotted-quad:port"
- ACE_INET_Addr tmp(udp);
- addr_ = tmp;
- reset_receive_buffer(receive_iovec_);
-}
-
-transaction::~transaction()
-{
- ACE_Reactor::instance()->remove_handler(this, READ_MASK | DONT_CALL);
- ACE_Reactor::instance()->cancel_timer(this);
-
- delete [] receive_iovec_.iov_base;
-}
-
-// implement state machine, send, wait (timeout/results) return
-int transaction::run()
-{
- int rc, done = 0;
- int retry_counter = 0;
- ACE_Time_Value to(params_.get_timeout(), 0); // seconds
- ACE_Reactor reactor;
-
- // 1. register io port for read access
- if (reactor.register_handler(session_.get_handle(), this,
- ACE_Event_Handler::READ_MASK) == -1)
- return SNMP_CLASS_INTERNAL_ERROR;
-
- // register a time handler and a socket with this
-
- while (!done) {
-
- if ((rc = send()) < 0) // send pkt to agent
- return rc;
- else {
- if (retry_counter++ > params_.get_retry())
- return SNMP_CLASS_TIMEOUT;
- }
-
- // 2. wait for events (timeout, returned msg)
- if (( rc = reactor.handle_events (to)) == 1) // one handler registered
- return 0;
- else {
- if (rc == 0) {
- to.set(params_.get_timeout(), 0);
- }
- else
- return SNMP_CLASS_INTERNAL_ERROR;
- }
- }
- return SNMP_CLASS_INTERNAL_ERROR;
-}
-
-// implement state machine, send, wait (timeout/results) return
-int transaction::run(transaction_result * r)
-{
- result_ = r;
- int rc;
-
- // 1. register io port for read access
- ACE_Reactor * reactor = ACE_Reactor::instance();
- if (reactor->register_handler(session_.get_handle(),
- this,
- READ_MASK) == -1)
- return SNMP_CLASS_INTERNAL_ERROR;
-
- retry_counter_ = 0;
-
- // register a time handler and a socket with this
- ACE_Time_Value to = params_.get_timeout();
- if (reactor->schedule_timer(this, 0, to, to) < 0)
- return SNMP_CLASS_INTERNAL_ERROR;
-
- if ((rc = send()) < 0) // send pkt to agent
- return rc;
- return 0;
-}
-
-// got back response from SNMPv1 agent - process it
-int transaction::handle_input (ACE_HANDLE)
-{
- // OS allocates iovec_.iov_base ptr and len
- delete [] receive_iovec_.iov_base;
- reset_receive_buffer(receive_iovec_);
- int rc = session_.recv(&receive_iovec_, receive_addr_, 0);
- if (rc == -1) {
- delete [] receive_iovec_.iov_base;
- reset_receive_buffer(receive_iovec_);
- if (result_)
- result_->result(this, SNMP_CLASS_RESOURCE_UNAVAIL);
- return SNMP_CLASS_RESOURCE_UNAVAIL;
- }
- if (result_)
- {
- result_->result(this, rc);
- return 0;
- }
- return rc;
-}
-
-int transaction::handle_timeout(const ACE_Time_Value &,
- const void *)
-{
- int rc;
- if ((rc = send()) < 0) // send pkt to agent
- result_->result(this, 0);
- else
- if (retry_counter_++ > params_.get_retry())
- result_->result(this, SNMP_CLASS_TIMEOUT);
-
- return 0;
-}
-
-
-const ACE_INET_Addr& transaction::get_from_addr() const
-{
- return receive_addr_;
-}
-
-
-// return pdu to caller
-int transaction::result(Pdu& pdu, char *comm_str, ACE_INET_Addr *from)
-{
- // TODO: check to see the sender matches the receiver address..
-
- // remove any vbs existing in this pdu
- pdu.delete_all_vbs();
-
- // any data to return?
- if (receive_iovec_.iov_len == 0)
- return -1;
-
- wpdu tmp(receive_iovec_);
-
- snmp_version ver;
-
- // return comm str and from address of incomming pdu if requested
- int rc = tmp.get_pdu(pdu, ver);
- if (comm_str)
- ACE_OS::strcpy(comm_str, (char *)tmp.get_community());
- if (from)
- *from = receive_addr_;
- return rc;
-}
-
-transaction::transaction(ACE_SOCK_Dgram& io)
-: result_(0), session_(io)
-{
- reset_receive_buffer(receive_iovec_);
-}
-
-
-int transaction::send()
-{
- iovec io = wp_.get_buffer();
- if (io.iov_len == 0) {
- // NO DATA ?
- return -1;
- }
- ssize_t rc = session_.send (io.iov_base, io.iov_len, addr_ , 0);
- return rc;
-}
-
-transaction_result::~transaction_result() {}
diff --git a/ASNMP/asnmp/transaction.h b/ASNMP/asnmp/transaction.h
deleted file mode 100644
index 4ded5f34e1b..00000000000
--- a/ASNMP/asnmp/transaction.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* -*-C++-*- */
-// $Id$
-#ifndef TRANSACTION_
-#define TRANSACTION_
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// transaction.h
-//
-// = DESCRIPTION
-//
-// = AUTHOR
-// Michael R. MacFaden port to ACE / use Reactor pattern
-//
-// ============================================================================
-
-#include "ace/Event_Handler.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-# pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-#include "asnmp/target.h"
-#include "asnmp/pdu.h"
-#include "asnmp/transaction_result.h"
-#include "asnmp/wpdu.h" // cmu adapter class
-#include "ace/SOCK_Dgram.h"
-
-class ACE_Export transaction : public ACE_Event_Handler
- // = TITLE
- // Used to manage the details of a particular transaction betwen
- // two SNMP agents. Uses SnmpTarget class to implement retry/timeout
-
-{
- int retry_counter_;
- transaction_result * result_;
-
- public:
- transaction(const Pdu& pdu, const UdpTarget& target, ACE_SOCK_Dgram& io);
- transaction(ACE_SOCK_Dgram& io);
- // constructor
- ~transaction();
- // destructor
-
- int run();
- int run(transaction_result *r); // Async interface, with callback object
- // begin polling for values
-
- int result(Pdu& pdu, char *comm_str = 0, ACE_INET_Addr *from_addr = 0);
- // return pdu with result from agent after run() is completed rc = 0
- // optionally get community str
-
- virtual int handle_input (ACE_HANDLE fd);
- // called by reactor when data is ready to be read in from OS memory
- virtual int handle_timeout (const ACE_Time_Value &, const void *);
- // used for resend in asynchronous run()
-
- int send();
- // transmit buffer command to network...
-
- const ACE_INET_Addr& get_from_addr() const;
- // pre: handle_input called
- // retrieve the sender's from address from the last pkt
-
- private:
- transaction(const transaction&);
- // disallow copy construction
-
- wpdu wp_; // wire pdu
- UdpTarget params_; // params
- ACE_INET_Addr addr_; // to address
- ACE_SOCK_Dgram session_; // io object
- iovec receive_iovec_; // receive buffer
- ACE_INET_Addr receive_addr_; // from address
-};
-
-#endif // TRANSACTION_
diff --git a/ASNMP/asnmp/transaction_result.h b/ASNMP/asnmp/transaction_result.h
deleted file mode 100644
index 1c0472675ea..00000000000
--- a/ASNMP/asnmp/transaction_result.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* -*-C++-*- */
-// $Id$
-#ifndef TRANSACTION_RESULT_H_
-#define TRANSACTION_RESULT_H_
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// transaction_result.h
-//
-// = DESCRIPTION
-// An object respresenting a request/reply operation between mgr/agent
-//
-// = AUTHOR
-// Michael R. MacFaden
-//
-// ============================================================================
-
-class transaction;
-class ACE_Export transaction_result
-{
- public:
- virtual ~transaction_result();
- virtual void result(transaction * trans, int) = 0;
-};
-
-#endif
diff --git a/ASNMP/asnmp/vb.cpp b/ASNMP/asnmp/vb.cpp
deleted file mode 100644
index ff9c22bb773..00000000000
--- a/ASNMP/asnmp/vb.cpp
+++ /dev/null
@@ -1,396 +0,0 @@
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// vb.h
-//
-// = DESCRIPTION
-// The Vb class is an encapsulation of the snmp variable binding.
-// This module contains the class definition for the variable binding (VB)
-// class. The VB class is an encapsulation of a SNMP VB. A VB object is
-// composed of one SNMP++ Oid and one SMI value. The Vb class utilizes Oid
-// objects and thus requires the Oid class. To use this class,
-// set oid, value then call valid() to be sure object was constructed correctly.
-//
-// = AUTHOR
-// Peter E Mellquist
-// Michael R MacFaden mrm@cisco.com - rework & ACE port
-// ============================================================================
-/*===================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
-=====================================================================*/
-
-#include "asnmp/oid.h" // include oid class defs
-#include "asnmp/vb.h" // include vb class defs
-#include "asnmp/snmperrs.h" // error codes
-
-ACE_RCSID(asnmp, vb, "$Id$")
-
-//---------------[ Vb::Vb( void) ]--------------------------------------
-// constructor with no arguments
-// makes an vb, unitialized
-Vb::Vb( void): output_(0), iv_vb_value_(0),
- exception_status_(SNMP_CLASS_SUCCESS)
-{
-}
-
-//---------------[ Vb::Vb( const Oid &oid) ]-----------------------------
-// constructor to initialize the oid
-// makes a vb with oid portion initialized
-Vb::Vb( const Oid &oid): output_(0), iv_vb_oid_(oid), iv_vb_value_(0),
- exception_status_(SNMP_CLASS_SUCCESS)
-{
-}
-
-//---------------[ Vb::Vb( const Oid &oid, const SmiSyntax &val) ]-------
-Vb::Vb( const Oid &oid, const SnmpSyntax &val, const SmiUINT32 status):
- output_(0), iv_vb_oid_(oid), iv_vb_value_(0), exception_status_(status)
-{
- // iv_vb_value_ = recast_smi_object(val); // allocate and construct object
- iv_vb_value_ = val.clone();
-}
-
-//---------------[ Vb::Vb( const Vb &vb) ]-----------------------------
-// copy constructor
-Vb::Vb( const Vb &vb): output_(0), iv_vb_value_(0)
-{
- *this = vb;
-}
-
-//---------------[ Vb::~Vb() ]------------------------------------------
-// destructor
-// if the vb has a oid or an octect string then
-// the associated memory needs to be freed
-Vb::~Vb()
-{
- free_vb();
- delete [] output_; // formatting buffer if it exists
-}
-
-
-//--------------[ Vb::valid() ]-----------------------------------------
-// returns validity of a Vb object
-// must have a valid oid and value
-int Vb::valid() const
-{
- if ( iv_vb_oid_.valid() && (iv_vb_value_ && iv_vb_value_->valid()) )
- return 1;
- else
- return 0;
-}
-
-
-//---------------[ Vb& Vb::operator=( const Vb &vb) ]--------------------
-// overloaded assignment allows assigning one Vb to another
-// this involves deep memory thus target vb needs to be freed
-// before assigning source
-Vb& Vb::operator=( const Vb &vb)
-{
- free_vb(); // free up target to begin with
-
- //-----[ reassign the Oid portion 1st ]
- vb.get_oid( iv_vb_oid_);
-
- //-----[ next set the vb value portion ]
- if (vb.iv_vb_value_ == 0) {
- iv_vb_value_ = 0;
- }
- else {
- iv_vb_value_ = vb.iv_vb_value_->clone();
- }
- exception_status_ = vb.exception_status_;
-
- return *this; // return self reference
-}
-
- // set a Vb null, if its not already
-void Vb::set_null()
-{
- free_vb();
-}
-
-//---------------[ Vb::set_oid( const Oid oid ) ]-----------------------
-// set value oid only with another oid
-void Vb::set_oid( const Oid& oid)
-{
- iv_vb_oid_ = oid;
-}
-
-//---------------[ Vb::get_oid( Oid &oid) ]-----------------------------
-// get oid portion
-void Vb::get_oid( Oid &oid) const
-{
- oid = iv_vb_oid_;
-}
-
-//----------------[ void Vb::free_vb() ]--------------------------------
-// protected method to free memory
-// this methos is used to free memory when assigning new vbs
-// or destructing
-// in the case of oids and octets, we need to do a deep free
-void Vb::free_vb()
-{
- if (iv_vb_value_)
- delete iv_vb_value_;
- exception_status_ = SNMP_CLASS_SUCCESS;
- iv_vb_value_ = 0;
-}
-
-void Vb::set_value( const SnmpInt32& i)
-{
- free_vb();
- iv_vb_value_ = (SnmpSyntax *)new SnmpInt32(i);
-}
-
-void Vb::set_value( const SnmpUInt32& u)
-{
- free_vb();
- iv_vb_value_ = (SnmpSyntax *)new SnmpUInt32(u);
-}
-
-void Vb::set_value( const Gauge32& g)
-{
- free_vb();
- iv_vb_value_ = (SnmpSyntax *)new Gauge32(g);
-}
-
-void Vb::set_value( const Counter32& c)
-{
- free_vb();
- iv_vb_value_ = (SnmpSyntax *)new Counter32(c);
-}
-
-void Vb::set_value( const Counter64& c)
-{
- free_vb();
- iv_vb_value_ = (SnmpSyntax *)new Counter64(c);
-}
-
-void Vb::set_value( const TimeTicks& t)
-{
- free_vb();
- iv_vb_value_ = (SnmpSyntax *)new TimeTicks(t);
-}
-
-void Vb::set_value( const OctetStr& s)
-{
- free_vb();
- iv_vb_value_ = (SnmpSyntax *)new OctetStr(s);
-}
-
-void Vb::set_value( const Oid& o)
-{
- free_vb();
- iv_vb_value_ = (SnmpSyntax *)new Oid(o);
-}
-
-void Vb::set_value ( const SnmpSyntax &val)
-{
- free_vb();
- iv_vb_value_ = val.clone();
-}
-
-int Vb::get_value( SnmpInt32 &i)
-{
- if (iv_vb_value_ &&
- iv_vb_value_->valid() &&
- (iv_vb_value_->get_syntax() == sNMP_SYNTAX_INT32 )) {
- i = *((SnmpInt32 *) iv_vb_value_);
- return SNMP_CLASS_SUCCESS;
- }
- else
- return SNMP_CLASS_INVALID;
-}
-
-int Vb::get_value( SnmpUInt32 &u)
-{
- if (iv_vb_value_ && iv_vb_value_->valid())
- {
- SmiUINT32 syntax = iv_vb_value_->get_syntax();
- if (syntax == sNMP_SYNTAX_GAUGE32 ||
- syntax == sNMP_SYNTAX_CNTR32 ||
- syntax == sNMP_SYNTAX_TIMETICKS ||
- syntax == sNMP_SYNTAX_UINT32)
- {
- u = *((SnmpUInt32 *) iv_vb_value_);
- return SNMP_CLASS_SUCCESS;
- }
- }
- return SNMP_CLASS_INVALID;
-}
-
-/* return a uint or a gauge. this is casting, but no semantic difference
- * at this level
- */
-int Vb::get_value( Gauge32 &g)
-{
- if (iv_vb_value_ &&
- iv_vb_value_->valid() &&
- ((iv_vb_value_->get_syntax() == sNMP_SYNTAX_GAUGE32) ||
- iv_vb_value_->get_syntax() == sNMP_SYNTAX_UINT32) ) {
- g = *((Gauge32 *) iv_vb_value_);
- return SNMP_CLASS_SUCCESS;
- }
- else
- return SNMP_CLASS_INVALID;
-}
-
-int Vb::get_value( Counter32 &c)
-{
- if (iv_vb_value_ &&
- iv_vb_value_->valid() &&
- (iv_vb_value_->get_syntax() == sNMP_SYNTAX_CNTR32 )) {
- c = *((Counter32 *) iv_vb_value_);
- return SNMP_CLASS_SUCCESS;
- }
- else
- return SNMP_CLASS_INVALID;
-}
-
-int Vb::get_value( Counter64 &c)
-{
- if (iv_vb_value_ &&
- iv_vb_value_->valid() &&
- (iv_vb_value_->get_syntax() == sNMP_SYNTAX_CNTR64 )) {
- c = *((Counter32 *) iv_vb_value_);
- return SNMP_CLASS_SUCCESS;
- }
- else
- return SNMP_CLASS_INVALID;
-}
-
-int Vb::get_value( TimeTicks &t)
-{
- if (iv_vb_value_ &&
- iv_vb_value_->valid() &&
- (iv_vb_value_->get_syntax() == sNMP_SYNTAX_TIMETICKS )) {
- t = *((TimeTicks *) iv_vb_value_);
- return SNMP_CLASS_SUCCESS;
- }
- else
- return SNMP_CLASS_INVALID;
-}
-
-int Vb::get_value( OctetStr &s)
-{
- if (iv_vb_value_ &&
- iv_vb_value_->valid() &&
- (iv_vb_value_->get_syntax() == sNMP_SYNTAX_OCTETS )) {
- s = *((OctetStr *) iv_vb_value_);
- return SNMP_CLASS_SUCCESS;
- }
- else
- return SNMP_CLASS_INVALID;
-}
-
-int Vb::get_value( Oid &s)
-{
- if (iv_vb_value_ &&
- iv_vb_value_->valid() &&
- (iv_vb_value_->get_syntax() == sNMP_SYNTAX_OID )) {
- s = *((Oid *) iv_vb_value_);
- return SNMP_CLASS_SUCCESS;
- }
- else
- return SNMP_CLASS_INVALID;
-}
-
-
-//---------------[ Vb::get_value( Value &val) ]--------
-int Vb::get_value( SnmpSyntax &val)
-{
- if (iv_vb_value_) {
- val = *iv_vb_value_;
- if (val.valid())
- return SNMP_CLASS_SUCCESS;
- else
- return SNMP_CLASS_INVALID;
- }
- else
- {
-//TM: should set val to be invalid
- return SNMP_CLASS_INVALID;
- }
-}
-
-
-
-//-----[ misc]--------------------------------------------------------
-
-// return the current syntax
-// This method violates Object Orientation but may be useful if
-// the caller has a vb object and does not know what it is.
-// This would be useful in the implementation of a browser.
-SmiUINT32 Vb::get_syntax()
-{
- if ( exception_status_ != SNMP_CLASS_SUCCESS)
- return exception_status_;
- else
- return ( iv_vb_value_ ? iv_vb_value_->get_syntax() : sNMP_SYNTAX_NULL);
-}
-
-// return the printabel value
-char *Vb::to_string_value()
-{
- if (iv_vb_value_)
- return iv_vb_value_->to_string();
- else
- return "";
-}
-
-// return the printable oid
-char *Vb::to_string_oid()
-{
- return iv_vb_oid_.to_string();
-}
-
-// generate string with name/ value format
-char *Vb::to_string()
-{
- int len = ACE_OS::strlen(iv_vb_oid_.to_string());
- char *ptr = "";
- if (iv_vb_value_)
- ptr = iv_vb_value_->to_string();
- len += ACE_OS::strlen(ptr) + 3 + 1; // " / " + null
- ACE_NEW_RETURN(output_, char[len], "");
- ACE_OS::sprintf(output_, "%s / %s", iv_vb_oid_.to_string(), ptr);
- return output_;
-}
-
-// friend function to set exception status
-void set_exception_status( Vb *vb, const SmiUINT32 status)
-{
- vb->exception_status_ = status;
-}
-
-// equivlence operator overloaded
-// hack, by side effect, compare based on string formatting output_
-int operator==( const Vb &lhs, const Vb &rhs)
-{
- if ( lhs.iv_vb_oid_ != rhs.iv_vb_oid_)
- return 0;
-
- if (lhs.iv_vb_value_ != 0 && rhs.iv_vb_value_ != 0) {
- int val = strcmp(lhs.iv_vb_value_->to_string(),
- rhs.iv_vb_value_->to_string());
- return !val;
- }
- else
- return 0;
-}
diff --git a/ASNMP/asnmp/vb.h b/ASNMP/asnmp/vb.h
deleted file mode 100644
index dca6e7ae985..00000000000
--- a/ASNMP/asnmp/vb.h
+++ /dev/null
@@ -1,204 +0,0 @@
-/* -*-C++-*- */
-// $Id$
-#ifndef VB_CLS_
-#define VB_CLS_
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// vb.h
-//
-// = DESCRIPTION
-// This module contains the class definition for the variable binding (VB)
-// class. The VB class is an encapsulation of a SNMP VB. A VB object is
-// composed of one SNMP++ Oid and one SMI value. The Vb class utilizes Oid
-// objects and thus requires the Oid class. To use this class,
-// set oid, value then call valid() to be sure object was constructed correctly.
-//
-// = AUTHOR
-// Peter E Mellquist
-// ============================================================================
-/*===================================================================
- Copyright (c) 1996
- Hewlett-Packard Company
-
- ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
- Permission to use, copy, modify, distribute and/or sell this software
- and/or its documentation is hereby granted without fee. User agrees
- to display the above copyright notice and this license notice in all
- copies of the software and any documentation of the software. User
- agrees to assume all liability for the use of the software; Hewlett-Packard
- makes no representations about the suitability of this software for any
- purpose. It is provided "AS-IS without warranty of any kind,either express
- or implied. User hereby grants a royalty-free license to any and all
- derivatives based upon this software code base.
-=====================================================================*/
-
-//----[ external calls ]----------------------------------------------
-#include "ace/OS.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-# pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-#include "asnmp/smival.h"
-#include "asnmp/snmperrs.h" // V2c error def
-#include "asnmp/oid.h" // oid class def
-#include "asnmp/timetick.h" // time ticks
-#include "asnmp/counter.h" // counter
-#include "asnmp/gauge.h" // gauge class
-#include "asnmp/ctr64.h" // 64 bit counters
-#include "asnmp/octet.h" // octet class
-#include "asnmp/address.h" // address class def
-#include "asnmp/integer.h" // integer class
-
-
-//------------[ VB Class Def ]-------------------------------------
-// The Vb class is the encapsulation of the SNMP variable binding.
-// Variable binding lists in SNMP++ are represented as arrays of
-// Vb objects. Vb objects are passed to and from SNMP objects to
-// provide getting or setting MIB values.
-// The vb class keeps its own memory for objects and does not
-// utilize pointers to external data structures.
-//
-class ACE_Export Vb
- // = TITLE
- // Implement the concrete Variable Bindings aka Varbind
- // composite type. Varbinds hold 1 Oid and 1 Value (Any SMI value)
-{
-public:
- Vb( void);
- // constructor with no arguments
- // makes an vb, unitialized (does not make object valid)
-
- Vb( const Oid &oid);
- // constructor to initialize the oid
- // makes a vb with oid portion initialized (does not make object valid)
-
- Vb( const Oid& vb, const SnmpSyntax &val, const SmiUINT32=SNMP_CLASS_SUCCESS);
- // constructor to initialize the oid
- // makes a vb with oid portion and value portion initialized, (valid)
-
- Vb( const Vb &vb);
- // copy constructor
-
- ~Vb();
- // destructor
- // if the vb has a oid or an octect string then
- // the associated memory needs to be freed
-
- int valid() const;
- // return validity of Vb object (both oid and value set return 1 else 0)
-
- Vb& operator=( const Vb &vb);
- // assignment to another Vb object overloaded
-
- friend int operator==( const Vb &lhs, const Vb &rhs);
- // equivlence operator overloaded
-
- //-----[ set oid / get oid part]------------------------------------------
-
- void set_oid( const Oid& oid);
- // set value oid only with another oid
-
- void get_oid( Oid &oid) const;
- // get oid portion
-
- //-----[ set value part]--------------------------------------------------
-
- void set_null();
- // set a Vb null, if its not already
-
- void set_value( const TimeTicks& ticks);
- // returns 0 on success and a value
-
- void set_value( const Oid& oid);
- // returns 0 on success and a value
-
- void set_value( const Counter32& ctr);
- // returns 0 on success and a value
-
- void set_value( const Counter64& ctr);
- // returns 0 on success and a value
-
- void set_value( const Gauge32& ctr);
- // returns 0 on success and a value
-
- void set_value( const SnmpUInt32& ctr);
- // returns 0 on success and a value
-
- void set_value( const SnmpInt32& ctr);
- // returns 0 on success and a value
-
- void set_value( const OctetStr& oct_str);
- // get an octet string object
-
- //----[ get value ]------------------------------------------------
-
- int get_value( TimeTicks& ticks);
- // returns 0 on success and a value
-
- int get_value( Oid& oid);
- // returns 0 on success and a value
-
- int get_value( Counter32& ctr);
- // returns 0 on success and a value
-
- int get_value( Counter64& ctr);
- // returns 0 on success and a value
-
- int get_value( Gauge32& ctr);
- // returns 0 on success and a value
-
- int get_value( SnmpUInt32& ctr);
- // returns 0 on success and a value
-
- int get_value( SnmpInt32& ctr);
- // returns 0 on success and a value
-
- int get_value( OctetStr& oct_str);
- // get an octet string object
-
- // escape hatch
- void set_value( const SnmpSyntax &val);
- // for other derived types that can be casted
-
- int get_value( SnmpSyntax &val);
- // gets a general value
-
- SmiUINT32 get_syntax();
- // return the current syntax
- // Or.. if a V2 VB exception is present then return the exception value
-
- friend void set_exception_status( Vb *vb, const SmiUINT32 status);
- // set the exception status
-
- char *to_string();
- // return fomatted version of this object
-
- char *to_string_value();
- // returns a formatted version of the value
-
- char *to_string_oid();
- // returns a formatted version of the value
-
-protected:
- char *output_;
- // display vb as [ oid / value ]
-
- Oid iv_vb_oid_;
- // a vb is made up of a oid
-
- SnmpSyntax *iv_vb_value_;
- // and a value...
-
- SmiUINT32 exception_status_;
- // are there any vb exceptions??
-
- void free_vb();
-};
-
-#endif // VB_CLS_
-
diff --git a/ASNMP/asnmp/wpdu.cpp b/ASNMP/asnmp/wpdu.cpp
deleted file mode 100644
index 43c38d9a5e6..00000000000
--- a/ASNMP/asnmp/wpdu.cpp
+++ /dev/null
@@ -1,520 +0,0 @@
-// $Id$
-
-// ============================================================================
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// wpdu.cpp
-//
-// = DESCRIPTION
-// Adapter class. Converts between raw wire format and Pdu objects
-// that can be stuffed out a I/O port or reconstructed
-//
-// = AUTHOR
-// Michael R. MacFaden rework the class api and impl using ACE
-// Peter E Mellquist implementation/code from snmp++ snmpmsg class
-//
-// ============================================================================
-
-#include "asnmp/wpdu.h"
-#include <ace/Log_Msg.h>
-
-#define DEFINE_TRAP_CONSTANTS_
-#include "asnmp/enttraps.h"
-
-ACE_RCSID(asnmp, wpdu, "$Id$")
-
-#define MAX_COMM_STR_LEN 255
-#define V1_COLD_START 0
-#define V1_WARM_START 1
-#define V1_LINK_DOWN 2
-#define V1_LINK_UP 3
-#define V1_AUTH_FAILURE 4
-#define V1_EGP_NEIGHBOR_LOSS 5
-#define V1_ENT_SPECIFIC 6
-
-inline
-void reset_iov(iovec& iov)
-{
- iov.iov_base = 0;
- iov.iov_len = 0;
-}
-
-wpdu::wpdu(const Pdu& pdu, const UdpTarget& target):
- valid_flag_(SNMP_CLASS_INVALID ), comm_len(MAX_COMM_STR_LEN)
-{
- reset_iov(iovec_);
- version_ = target.get_version();
- int status;
- OctetStr comm_str;
-
- community_name[0] = 0;
-
- snmp_pdu *raw_pdu; // create a raw pdu
- raw_pdu = cmu_snmp::pdu_create( (int) pdu.get_type());
- if (!raw_pdu) {
- valid_flag_ = SNMP_CLASS_RESOURCE_UNAVAIL;
- return;
- }
-
- raw_pdu->reqid = pdu.get_request_id();
- raw_pdu->errstat= (unsigned long) pdu.get_error_status();
- raw_pdu->errindex= (unsigned long) pdu.get_error_index();
-
- switch (raw_pdu->command) {
- case sNMP_PDU_GET:
- case sNMP_PDU_GETNEXT:
- target.get_read_community(comm_str);
- break;
-
- case sNMP_PDU_SET:
- target.get_write_community(comm_str);
- break;
-
- case sNMP_PDU_V1TRAP:
- target.get_read_community(comm_str);
- if (set_trap_info(raw_pdu, pdu)) // will free raw_pdu
- return;
- break;
- case sNMP_PDU_RESPONSE:
- break;
-
- default:
- ACE_ASSERT(0);
- return;
- }
-
- if (load_vbs(raw_pdu, pdu)) {
- cmu_snmp::free_pdu( raw_pdu);
- valid_flag_ = SNMP_CLASS_RESOURCE_UNAVAIL;
- return;
- }
-
- // TODO: determine how big raw_pdu serializes out to
- iovec_.iov_len = target.get_max_pdu_size();
- ACE_NEW(iovec_.iov_base, char [iovec_.iov_len]);
-
- // create raw byte stream
- status = cmu_snmp::build( raw_pdu,
- (unsigned char *)iovec_.iov_base,
- (int *) &iovec_.iov_len,
- target.get_version(),
- comm_str.data(), comm_str.length());
- if ( status != 0) {
- valid_flag_ = SNMP_ERROR_WRONG_ENCODING;
- cmu_snmp::free_pdu( raw_pdu);
- return;
- }
-
- cmu_snmp::free_pdu( raw_pdu);
- valid_flag_ = SNMP_CLASS_SUCCESS;
-}
-
-int wpdu::set_trap_info(snmp_pdu *raw_pdu, const Pdu& pdu) const
-{
- Oid enterprise;
- Oid trapid; // validate caller has set this correctly
- pdu.get_notify_id( trapid);
- if ( !trapid.valid() || trapid.length() < 2 ) {
- cmu_snmp::free_pdu( raw_pdu);
- return SNMP_CLASS_INVALID_NOTIFYID;
- }
-
-
- raw_pdu->specific_type=0;
-
- // TODO: object should emit numeric instead of this kind of mess...
- if ( trapid == coldStart)
- raw_pdu->trap_type = V1_COLD_START; // cold start
- else if ( trapid == warmStart)
- raw_pdu->trap_type = V1_WARM_START; // warm start
- else if( trapid == linkDown)
- raw_pdu->trap_type = V1_LINK_DOWN; // link down
- else if ( trapid == linkUp)
- raw_pdu->trap_type = V1_LINK_UP; // link up
- else if ( trapid == authenticationFailure )
- raw_pdu->trap_type = V1_AUTH_FAILURE; // authentication failure
- else if ( trapid == egpNeighborLoss)
- raw_pdu->trap_type = V1_EGP_NEIGHBOR_LOSS; // egp neighbor loss
- else {
- raw_pdu->trap_type = V1_ENT_SPECIFIC; // enterprise specific
- // last oid subid is the specific value
- // if 2nd to last subid is "0", remove it
- // enterprise is always the notify oid prefix
- raw_pdu->specific_type = (int) trapid[(int) (trapid.length() - 1)];
- trapid.trim(1);
- if ( trapid[(int)(trapid.length() - 1)] == 0 )
- trapid.trim(1);
- enterprise = trapid;
- }
-
- if ( raw_pdu->trap_type != V1_ENT_SPECIFIC)
- pdu.get_notify_enterprise( enterprise);
- if ( enterprise.length() > 0) {
- // note!! To the contrary, enterprise OID val is
- // copied here and raw_pdu->enterprise is freed in free_pdu
- // as it should be (HDN)
- // these are hooks into an SNMP++ oid
- // and therefor the raw_pdu enterprise
- // should not free them. null them out!!
- SmiLPOID rawOid;
- rawOid = enterprise.oidval();
- // HDN - enterprise is a local object, cannot simply assign pointer
- //raw_pdu->enterprise = rawOid->ptr;
- raw_pdu->enterprise_length = (int) rawOid->len;
- ACE_NEW_RETURN(raw_pdu->enterprise,
- oid[raw_pdu->enterprise_length],-1);
- ACE_OS::memcpy((char *)raw_pdu->enterprise,(char *)rawOid->ptr,
- raw_pdu->enterprise_length * sizeof(oid));
- }
-
- TimeTicks timestamp;
- pdu.get_notify_timestamp( timestamp);
- raw_pdu->time = ( unsigned long) timestamp;
-
- // HDN - set agent addr using the local hostname if possible
- char localHostName[MAXHOSTNAMELEN];
- Snmp::get_host_name(localHostName, MAXHOSTNAMELEN);
- if (ACE_OS::strlen(localHostName) > 0) {
- GenAddress addr(localHostName);
- OctetStr octet;
- addr.to_octet(octet);
- ACE_OS::memcpy(&(raw_pdu->agent_addr.sin_addr),
- octet.data(),
- octet.length());
- }
-
- return 0;
-}
-
-wpdu::wpdu(const iovec& iov): valid_flag_(0),comm_len(MAX_COMM_STR_LEN)
-{
- community_name[0] = 0;
- reset_iov(iovec_);
- version_ = version1; // TODO: figure where this should come from
- ACE_NEW(iovec_.iov_base, char[iov.iov_len]);
- if (!iovec_.iov_base) {
- valid_flag_ = SNMP_CLASS_RESOURCE_UNAVAIL;
- return;
- }
-
- copy_iovec(iovec_, iov);
- valid_flag_ = SNMP_CLASS_SUCCESS;
-}
-
-wpdu::wpdu(): valid_flag_(0), comm_len(MAX_COMM_STR_LEN)
-{
- community_name[0] = 0;
- reset_iov(iovec_);
- version_ = version1; // TODO: figure where this should come from
-}
-
-int wpdu::valid() const
-{
- return (valid_flag_ == SNMP_CLASS_SUCCESS);
-}
-
-int wpdu::load_vbs(snmp_pdu *raw_pdu, const Pdu& pdu)
-{
- int status = 0;
-
- // load up the payload
- // for all Vbs in list, add them to the pdu
- int vb_count;
- Vb tempvb;
- Oid tempoid;
- SmiLPOID smioid;
- SmiVALUE smival;
-
- vb_count = pdu.get_vb_count();
-
- for (int z = 0; z < vb_count; z++) {
- pdu.get_vb( tempvb, z);
- tempvb.get_oid( tempoid);
- smioid = tempoid.oidval();
- // what are we trying to convert here (vb oid part or value part)
- status = convert_vb_to_smival( tempvb, &smival );
- if ( status != SNMP_CLASS_SUCCESS)
- return status;
-
- // add the var to the raw pdu
- cmu_snmp::add_var(raw_pdu, smioid->ptr, (int) smioid->len, &smival);
- free_smival_descriptor( &smival);
- }
-
- return status;
-}
-
-// supports overlapped copies
-// static
-void wpdu::copy_iovec(iovec& dest, const iovec& src)
-{
- if (&dest == &src)
- return;
-
- ACE_OS:: memmove( dest.iov_base, src.iov_base, src.iov_len);
- dest.iov_len = src.iov_len;
-}
-
-int wpdu::convert_vb_to_smival( Vb &tempvb, SmiVALUE *smival )
-{
- smival->syntax = tempvb.get_syntax();
-
- switch ( smival->syntax ) {
-
- case sNMP_SYNTAX_NULL:
- break;
-
- // case sNMP_SYNTAX_INT32:
- case sNMP_SYNTAX_INT:
- {
- SnmpInt32 tmp;
- tempvb.get_value(tmp);
- smival->value.sNumber = tmp;
- }
- break;
-
- // case sNMP_SYNTAX_UINT32:
- case sNMP_SYNTAX_GAUGE32:
- case sNMP_SYNTAX_CNTR32:
- case sNMP_SYNTAX_TIMETICKS:
- {
- SnmpUInt32 tmp;
- tempvb.get_value(tmp);
- smival->value.uNumber = tmp;
- }
- break;
-
- // case Counter64
- case sNMP_SYNTAX_CNTR64:
- {
- Counter64 c64;
- tempvb.get_value(c64);
- smival->value.hNumber.hipart = c64.high();
- smival->value.hNumber.lopart = c64.low();
- }
- break;
-
- // OID syntax
- case sNMP_SYNTAX_OID:
- {
- Oid tmpoid;
- tmpoid.oidval();
- tempvb.get_value(tmpoid);
- SmiLPOID smi = tmpoid.oidval();
- smival->value.oid.len = tmpoid.length();
- ACE_NEW_RETURN(smival->value.oid.ptr,
- SmiUINT32 [smival->value.oid.len], 1);
- ACE_OS::memcpy(smival->value.oid.ptr, smi->ptr,
- smival->value.oid.len *sizeof(SmiUINT32));
- }
- break;
-
- case sNMP_SYNTAX_BITS:
- case sNMP_SYNTAX_OCTETS:
- case sNMP_SYNTAX_IPADDR:
- {
- OctetStr os;
- tempvb.get_value(os);
- smival->value.string.ptr = 0;
- smival->value.string.len = os.length();
- if ( smival->value.string.len > 0 ) {
- ACE_NEW_RETURN(smival->value.string.ptr,
- SmiBYTE [smival->value.string.len], 1);
- if ( smival->value.string.ptr ) {
- for (int i=0; i<(int) smival->value.string.len ; i++)
- smival->value.string.ptr[i] = os[i];
- }
- else {
- smival->syntax = sNMP_SYNTAX_NULL; // invalidate the smival
- return SNMP_CLASS_RESOURCE_UNAVAIL;
- }
- }
- }
- break;
-
- default:
- ACE_DEBUG((LM_DEBUG, "wpdu::convert_vb_to_smival did not convert vb\n"));
- // ACE_ASSERT(0);
- } // switch
-
- return 0;
-}
-
-// free a SMI value
-void wpdu::free_smival_descriptor( SmiVALUE *smival )
-{
- switch ( smival->syntax ) {
- case sNMP_SYNTAX_OCTETS:
- case sNMP_SYNTAX_OPAQUE:
- case sNMP_SYNTAX_IPADDR:
- case sNMP_SYNTAX_BITS: // obsoleted in SNMPv2 Draft Std
- delete [] smival->value.string.ptr;
- break;
-
- case sNMP_SYNTAX_OID:
- delete [] smival->value.oid.ptr;
- break;
- }
- smival->syntax = sNMP_SYNTAX_NULL;
-}
-
-
-wpdu::~wpdu()
-{
- delete [] iovec_.iov_base;
-}
-
-const iovec& wpdu::get_buffer() const
-{
- return iovec_;
-}
-
-// return a pdu from a buffer
-int wpdu::get_pdu(Pdu& pdu, snmp_version& version)
-{
- if (iovec_.iov_len == 0)
- return -1; // NO DATA
-
- snmp_pdu *raw_pdu;
- raw_pdu = cmu_snmp::pdu_create(0);
- if (!raw_pdu) {
- return SNMP_CLASS_RESOURCE_UNAVAIL;
- }
-
- // max value a client can send us - TODO: replace this with an
- // api to get actual string length
- int status = cmu_snmp::parse( raw_pdu, (unsigned char *)iovec_.iov_base,
- community_name, comm_len,
- version, iovec_.iov_len);
- if (status != 0)
- return SNMP_CLASS_INTERNAL_ERROR;
-
- community_name[comm_len] = 0; // set null based on returned length
- set_request_id( &pdu, raw_pdu->reqid);
- set_error_status( &pdu, (int) raw_pdu->errstat);
- set_error_index( &pdu, (int) raw_pdu->errindex);
- pdu.set_type( raw_pdu->command);
-
- if (restore_vbs(pdu, raw_pdu)) {
- cmu_snmp::free_pdu(raw_pdu);
- return SNMP_CLASS_INTERNAL_ERROR;
- }
-
- cmu_snmp::free_pdu(raw_pdu);
- return 0;
-}
-
-int wpdu::restore_vbs(Pdu& pdu, const snmp_pdu *raw_pdu) const
-{
- Vb tempvb;
- Oid tempoid;
- struct variable_list *vp;
-
- for(vp = raw_pdu->variables; vp; vp = vp->next_variable) {
-
- // extract the oid portion
- tempoid.set_data( (unsigned long *)vp->name,
- ( unsigned int) vp->name_length);
- tempvb.set_oid( tempoid);
-
- // extract the value portion
- switch(vp->type) {
-
- // octet string
- case sNMP_SYNTAX_OCTETS:
- case sNMP_SYNTAX_OPAQUE:
- {
- OctetStr octets( (char *) vp->val.string,
- (long) vp->val_len);
- tempvb.set_value( octets);
- }
- break;
-
- // object id
- case sNMP_SYNTAX_OID:
- {
- Oid oid( (unsigned long*) vp->val.objid,
- (int) vp->val_len);
- tempvb.set_value( oid);
- }
- break;
-
- // timeticks
- case sNMP_SYNTAX_TIMETICKS:
- {
- TimeTicks timeticks( (unsigned long) *(vp->val.integer));
- tempvb.set_value( timeticks);
- }
- break;
-
- // 32 bit counter
- case sNMP_SYNTAX_CNTR32:
- {
- Counter32 counter32( (unsigned long) *(vp->val.integer));
- tempvb.set_value( counter32);
- }
- break;
-
- // ip address
- case sNMP_SYNTAX_IPADDR:
- {
- char buffer[20];
- sprintf( buffer,"%d.%d.%d.%d",
- vp->val.string[0],
- vp->val.string[1],
- vp->val.string[2],
- vp->val.string[3]);
- IpAddress ipaddress( buffer);
- tempvb.set_value( ipaddress);
- }
- break;
-
- // 32 bit integer
- case sNMP_SYNTAX_INT:
- {
- SnmpInt32 int32( (long) *(vp->val.integer));
- tempvb.set_value( int32);
- }
- break;
-
- // 32 bit unsigned integer
- case sNMP_SYNTAX_UINT32:
- {
- SnmpUInt32 uint32( (unsigned long) *(vp->val.integer));
- tempvb.set_value( uint32);
- }
- break;
-
- // v2 counter 64's
- case sNMP_SYNTAX_CNTR64:
- break;
-
- case sNMP_SYNTAX_NULL:
- tempvb.set_null();
- break;
-
- // v2 vb exceptions
- case sNMP_SYNTAX_NOSUCHOBJECT:
- case sNMP_SYNTAX_NOSUCHINSTANCE:
- case sNMP_SYNTAX_ENDOFMIBVIEW:
- set_exception_status( &tempvb, vp->type);
- break;
-
- default:
- tempvb.set_null();
-
- } // end switch
-
- // append the vb to the pdu
- pdu += tempvb;
- }
-
- return 0;
-}
-
-const unsigned char *wpdu::get_community() const
-{
- return community_name;
-}
diff --git a/ASNMP/asnmp/wpdu.h b/ASNMP/asnmp/wpdu.h
deleted file mode 100644
index a4d4bb1d0c1..00000000000
--- a/ASNMP/asnmp/wpdu.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* -*-C++-*- */
-// $Id$
-#ifndef WPDU_H_
-#define WPDU_H_
-// ============================================================================
-//
-// = LIBRARY
-// asnmp
-//
-// = FILENAME
-// wpdu.h
-//
-// = DESCRIPTION
-// Adapter class. Converts a Pdu and GenTarget into a format
-// that can be stuffed out a I/O port
-//
-// = AUTHOR
-// Michael R. MacFaden re-worked api, use ACE API
-// Peter E Mellquist wrote original class snmpmsg
-//
-// ============================================================================
-
-#include "ace/OS.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-# pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-#include "asnmp/asn1.h"
-#include "asnmp/pdu.h"
-#include "asnmp/target.h"
-
-// this is an adapter class, it peforms the following transformations
-// PDU / Target -> iovec buffer
-// iovec buffer -> PDU / Target
-struct snmp_pdu;
-class ACE_Export wpdu
- // = TITLE
- // Implement an Adapter pattern between CMU SNMP and HP SNMP++
- //
-{
-public:
-
- wpdu(const Pdu& pdu, const UdpTarget& target);
- // construct CMU data from HP SNMP++ objects
- wpdu(const iovec& buffer);
- // construct HP SNMP++ objects from raw buffer via CMU SNMP datatypes
- wpdu(); // same as using iovec?
-
- ~wpdu();
-
- int valid() const;
- // constructor completed ok? rc = 1 else 0
-
- const iovec& get_buffer() const;
- // return raw data stream via CMU code
-
- int get_pdu(Pdu& pdu, snmp_version& version);
- // return HP SNMP++ pdu
-
- const unsigned char *get_community() const;
- // return community strptr
-
-private:
- int convert_vb_to_smival( Vb &tempvb, SmiVALUE *smival );
- int load_vbs(snmp_pdu *raw_pdu, const Pdu& pdu);
- int restore_vbs(Pdu& pdu, const snmp_pdu *raw_pdu) const;
- void free_smival_descriptor( SmiVALUE *smival );
- static void copy_iovec(iovec& dest, const iovec& src);
- int set_trap_info(snmp_pdu *raw_pdu, const Pdu& pdu) const;
-
- iovec iovec_;
- // raw format
-
- int valid_flag_;
- // object construction state
-
- snmp_version version_;
- // snmp version
-
- unsigned char community_name[MAX_COMM_STR_LEN];
- unsigned long comm_len; // = MAX_COMM_STR_LEN;
-};
-
-#endif // WPDU_H_