This guide describes building with Microsoft C++ and with
the gcc compiler from Cygwin.  As developers build with
other Win32 environments, their notes will be included here.

----

Status as of 5-Nov-2001 for Win32 platforms

  -  the client applications work
  -  the core framework of the agent works
  -  the system, snmp, ip, tcp, udp, icmp mibgroups work
  -  the target, agentx, smux, notification groups compile
  -  extending the agent to support enterprise-specific MIBs works
  -  running the agent on a non-standard port works
  -  running the UCD agent instead of the MS supplied one "works"
          (at the loss of most of the functionality)
  -  running the UCD agent as a "subagent" of the MS one does not work
          (i.e. using the SNMP.dll interface)
  -  running the UCD agent as a subagent of an AgentX master "works"
          (bearing in mind this support is alpha-code)

All applications build with both MS VC++ and Cygwin.

Note: The agent cannot be built as an extensible SNMP agent that
will work with Microsoft's agent.

Neither snmpd nor snmptrapd register as NT services.

Snmptrapd does not "share" nor multiplex traps with SNMPTRAP.EXE,
a program that is available from Microsoft or ACE#COMM.

----

The remainder of this guide has the following sections :

Removing agentx from MS VC++ build
Building with MS VC++
Building with OpenSSL with MS VC++
Installing from MS VC++ build
Building with Cygwin
Installing with Cygwin
Build script for use with Cygwin
Acknowledgements

----
Removing agentx from MS VC++ build

Since this was added near the release date, we are compelled
to offer this note.

If you add the agentX modules (default), you will need to
add "-r" to your command invocation for master agent,
otherwise it will not start.

To Remove agentx

 1. Edit win32/*.h.  Remove references to "agentx", "master", 
    and "subagent" from these files.  Undefine the USING lines
    that refer to AGENTX.

 2. Start Visual Studio.  Focus the libucdmibs project.
    Remove all "agentx" related files from the project.

Building with MS VC++
---------------------

The win32 directory contains a Microsoft VC++ (6.0) workspace and
project files to build both static and DLL versions of the UCD SNMP
library and the applications. Until recently it is known to build with
VC++ 5.0 too, unfortunately none of the developers have this version around
anymore.

Building with earlier compiler versions has not been attempted.  Success
stories are welcomed.

A manually generated config.h file has been provided for use with the
win32 build since the basic win32 environment does not support autoconf.
Note: the compiled in MIB path is \usr\mibs which may be changed by
editing win32/config.h.  Note that the install instructions below
should be adjusted when changes are made to paths.

To build the libraries and applications, open the workspace file
"win32\win32.dsw" from VC++.

Note there is a Debug version and Release
version for each subproject.  Due to the way the libraries are
organized, there are exactly two library versions that work :

  1) libsnmp Debug ;  and 2) libsnmp_dll Release

The projects are arranged so that ALL of the usable products,
the .lib, .dll, and .exe files, are written to the win32\bin
directory.  The win32\lib directory is used only to build the
the files in the win32\bin directory.  Once building is completed,
there is no further use for the files in the win32\lib directory.

The Debug product .exe files have "_d" appended to the basename
of the applications.  This is so the Debug and Release versions
of an application can be built and tested separately.


Runtime libraries
-----------------

Note that the library must be built using the same options as the
application which it will be linked with. In particular, the run-time
libraries must match (Project settings, C/C++ tab, 'Code Generation'
category).

For example, linking in an snmplib built to use the Multithreaded DLL
runtime library to an application configured for the Debug
Multithreaded DLL runtime library results in a link error along the
lines of 'defaultlib "MSVCRT" conflicts with use of other libs'.   If
you receive a similar message, check that the projects settings
between library and application match up.

Debug Information
-----------------

Note that VC++ 6.0 has new options for for debugging information -
the 'Program Database'.  This option is set in the Project settings,
C/C++ tab, 'General' category, and is turned on by default during the
conversion of the project files. This option is not for use with a
library, as it embeds debug information into the library that
references an external file that will not be available to the linking
application. If you get an error message along the lines of
'debugging information not available in file vc60.pdb, make sure the
library debug option is set to 'C7 compatible'.

To build the Release versions:
Click Build->Batch Build. Uncheck all Debug and libsnmp versions.
Make sure libsnmp_dll Release and all other Release versions
are checked.  Rebuild All.  If the library DLL link fails, add
missing function names to libsnmp_dll/libsnmp.def.

To build the Debug versions:
Click Build->Batch Build. Uncheck all Release and libsnmp_dll versions.
Make sure libsnmp Debug and all other Debug versions
are checked. Rebuild All.

To build both Debug and Release versions:
Click Build->Batch Build.  Check all versions.  Uncheck
"libsnmp Release" and "libsnmp_dll Debug" versions only.
Then click Release All.

Building with OpenSSL with MS VC++
----------------------------------

OpenSSL is required to support the encryption capabilities in SNMPv3
(and will also support MD5 authentication). The win32 version of OpenSSL
can be built from the source at:

ftp://ftp.openssl.org/source/

Follow the instructions for building on win32 in that package. if you do
not have the M$ assembler installed (MASM) you can get a free one(NASM)
from:

http://www.kernel.org/pub/software/devel/nasm

You will also need to change the win32/config.h file from

---
/* define if you are using the internal MD5 code */
#define USE_INTERNAL_MD5 1
---
to
---
/* define if you are using the internal MD5 code */
#undef USE_INTERNAL_MD5

/* define if you are using OpenSSL */
#define USE_OPENSSL 1
---

now you will need to edit the VC++ Project settings for the libraries
and applications. Change the Settings->Link->'Object/Library Modules' to
include

libeay32.lib

when installing be sure to place libeay32.dll on your search path (e.g.,
usr\bin)

Installing from MS VC++ build
-----------------------------

Create these subdirectories on the root directory of the
volume you wish to hold the UC-Davis SNMP applications :

  usr, usr\bin, usr\mibs, usr\lib, usr\include\ucd-snmp

Copy mibs\*.txt to usr\mibs
Copy win32\bin\*.* to usr\bin
Copy win32\lib\*.* to usr\lib
Copy snmplib\*.h to usr\include\ucd-snmp
Copy win32\config.h to usr\include\ucd-snmp\ucd-snmp-config.h

if using OpenSSL
Copy libeay32.dll to usr\bin
Copy libeay32.lib to usr\lib

Installing is complete.  You may want to create a compressed
archive of the \usr hierarchy.

Building with Cygwin
--------------------

An alternate way to build UCD SNMP for win32 is to use Cygnus's cygwin32
environment.  Information on the Cygnus cygwin32 environment is available
on the web at: http://sources.redhat.com/cygwin/.

Cygwin allows you to compile almost the complete agent and applications.
The following configure options creates a working set of programs:

./configure --with-mib-modules="host agentx smux examples/example" \
 	--with-out-mib-modukes=host/hr_network \
	--with-libs="-lregex -liphlpapi"

This has been tested for Windows 98 and Windows NT 4.0.  In order for
the process part of the host resources MIB to work under NT you will need
to get hold of the PSAPI.DLL. This available under the download section
of www.microsoft.com. The DLL is included with Windoes 2000 and XP,
and is also part of the VC++ distribution.

Acknowledgements
----------------

These people are known to have contributed to one or more of
the Win32 platform ports.  If you have, and your name is not here,
please accept our apologies, and tell us so we can add your name.

David Perkins, Joe Marzot, Wes Hardaker, Niels Baggesen, Dave Shield,
Robert Story, Suvrit Sra, Mike Slifcak.

A very special thank you goes to Latha Prabhu who contributed the complete
MIB-II support, including write support. This has put the Windows port
in the top support class for net-snmp.

Notes on SET support for WIN32 ports
------------------------------------

Requirements:

  Windows NT/2000 or later: Requires Windows NT 4.0 SP4 or later. 
  Windows 95/98/Me: Requires Windows 98 or later. 
  Library: Use Iphlpapi.lib 

Windows support for SET  on following groups:

interfaces:
----------
ifAdminStatus is read-write. Status can be set with either 'up' or
'down'. (IE, 'testing' status is not supported.)


ip group:
--------
Scalar objects: 
ipForwarding:Currently windows supports only ON->OFF (IE,
enable->disable). For any other value, it returns with failure.

ipDefaultTTL: Supports value greater than or equal to 0. 

Table objects:
-------------
1. ipRouteTable:
   ------------
route_write.c implements this.

ipRouteDest: Setting this value, updates row with new ipRouteDest and all other
             entries will be same as old row. 
    EX:
    Consider there is an entry with ipRouteDest = 10.0.0.20
    Request, snmpset localhost private ip.ipRouteTable.ipRouteEntry.ipRouteDest.10.0.0.20 -a 10.0.0.16
    Updates that row with ipRouteDest = 10.0.0.16

ipRouteIfIndex:Write supported.

ipRouteMetric1: Supports value greater than or equal to -1

ipRouteMetric2, ipRouteMetric3, ipRouteMetric4, ipRouteMetric5: Eventhogh call 
               returns with success, windows doesn't change these( as these are 
               not used in windows)

ipRouteNextHop: Write supported.

ipRouteType: Write Supported. If value is 2, IE 'invalid', it deletes the entry.

ipRouteAge: Whenever any row is updated this will be automatically reset.

ipRouteMask: Write Supported.

Creation of ipRouteTable row:
-----------------------------
snmpset request for non existent OID with ipRouteIfIndex, ipRouteMetric1, 
ipRouteNextHop and ipRouteMask varbinds, creates a row.

snmpset with create option is not supported, as row creation requires 
ipRouteIfIndex, ipRouteMetric1, ipRouteNextHop and ipRouteMask  in a single 
request.

Example to create a row:
-----------------------
Consider there is no entry for 10.0.0.18

snmpset localhost private ip.ipRouteTable.ipRouteEntry.ipRouteIfIndex.10.0.0.18 i 2 4.21.1.ipRouteMask.10.0.0.18 a 255.255.255.255 4.21.1.ipRouteNextHop.10.0.0.0 a 10.0.0.0 4.21.1.ipRouteMetric1.10.0.0.18 i 1

If ipRouteIfIndex is valid then creates row with:
ipRouteIfIndex = 2
ipRouteMask = 255.255.255.255
ipRouteNextHop = 10.0.0.0
ipRouteMetric1 = 1

2. ipNetToMediaTable:
--------------------
ipNetToMediaIfIndex: write supported
ipNetToMediaPhysAddress: write supported
ipNetToMediaNetAddress: write supported
ipNetToMediaType: write supported, setting with value 2, deletes the row.

Creation of row:
--------------------
snmpset request for non existent OID with ipNetToMediaPhysAddress varbind
creates a row.

snmpset with create option is not supported, as row creation requires 
ipNetToMediaPhysAddress in a request 
request.

Example to create a row:
-----------------------
Consider there is no entry for 10.0.0.32

snmpset localhost private ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaPhysAddress.2.10.0.0.32 x efcd12130103

If ipNetToMediaIfIndex is valid then creates row with:
ipNetToMediaIfIndex = 2
ipNetToMediaPhysAddress = ef:cd:12:12:01:03
ipNetToMediaNetAddress = 10.0.0.32
ipNetToMediaType = 4

TCP:
---
tcpConnState of tcpConnTable is writable and the only value which may
be set by a management station is deleteTCB(12)
