home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Encyclopedia 96-1
/
novell-nsepro-1996-1-cd2.iso
/
download
/
netware
/
opennv.exe
/
NVIPXWS.C
< prev
next >
Wrap
Text File
|
1992-11-03
|
6KB
|
198 lines
/*
** (C) Copyright 1992 Novell, Inc. All rights reserved.
**
** File: nvipxws.c
**
** Description: This demonstrates how to send an alert NMVT to a host
** using the Open NetView IPX socket-based API.
**
** Note: This module must be linked with the NetWare C Interface for
** DOS library, xNIT.LIB and the Novell/Watcom C library, CLIBx.LIB.
**
** $Logfile: G:/cs/nma/vcs/nvipxws.c_v $
** $Revision: 1.2 $
** $Date: 03 Nov 1992 18:28:00 $
** $Author: RWONG $
** $Log: G:/cs/nma/vcs/nvipxws.c_v $
**
** Rev 1.2 03 Nov 1992 18:28:00 RWONG
** Change alert to open failure - token ring lobe.
**
** Rev 1.1 16 Oct 1992 09:23:08 RWONG
** Modified to use nvipx.h
**
** Rev 1.0 13 Oct 1992 12:15:44 RWONG
** Initial revision.
*/
/* many of these are included for function prototypes */
#include <stdlib.h>
#include <stdio.h>
#include <process.h>
#include <string.h>
//#include <nwbindry.h>
#include <sys\types.h>
#include <nit.h>
#include <nxt.h>
#include <cstypes.h>
#include <nmvtdef.h>
#include <nvapi.h>
#include <nvipx.h>
/* forward reference */
void fill_in_msg (void);
/*
** This is the msg data for a fully formatted alert NMVT.
** This is a OPEN FAILURE alert for a TOKEN RING LOBE
**
** Generic Alert Description Code Point
** 3211 - open failure
**
** Probable Causes
** 3702 - token ring lobe
**
** Failure Causes subfields
** 3320, 3711, 3434, F8E0, 33A5
**
** Recommended Action subfields
** 1009, 3301, 2010, 3101, 32C0, 31E0
**
** LAN link connection subsystem data subvector
** supporting data correlation subfield
** 03 - Local individual Mac Address
*/
#define NMVTDATALEN 151
u8_t msg[NMVTDATALEN] = {
0x41,0x03,0x8d,0x00,0x00,0x00,0x00,0x00,0x00,0x8f,0x00,0x00,
0x23,0x10,0x00,0x20,0x11,0x03,0x13,0x00,0x11,0xF0,0xF3,0xF8,
0xF6,0x81,0x81,0x81,0x89,0x82,0xF3,0xF4,0xF5,0xF6,0xF4,0xF6,
0xF7,0x0A,0x0E,0xC9,0xC2,0xD4,0xE3,0xD6,0xD2,0xC5,0xD5,
0x0b,0x92,0x00,0x00,0x01,0x32,0x11,0x00,0x00,0x00,0x00,0x04,
0x93,0x37,0x02,0x47,0x96,0x0C,0x01,0x33,0x20,0x37,0x11,
0x34,0x34,0xF8,0xE0,0x33,0xA5,0x03,0x83,0x21,0x19,0x82,0x00,
0x35,0x00,0x49,0x42,0x4D,0x20,0x54,0x4F,0x4B,0x45,0x4E,0x20,
0x52,0x49,0x4E,0x47,0x20,0x42,0x4F,0x41,0x52,0x44,0x0E,0x81,
0x10,0x09,0x33,0x01,0x20,0x10,0x31,0x01,0x32,0xC0,0x31,0xE0,
0x06,0x82,0x91,0x61,0x01,0xFF,0x06,0x82,0x01,0x07,0x00,0xFF,
0x03,0x83,0x21,0x0A,0x51,0x08,0x03,0x01,0x02,0x03,0x04,0x05,
0x06,0x08,0x01,0x5C,0x09,0x1B,0x0F,0x05,0x2A};
/* Buffer for name of the destination server */
char target_server[49];
/* ECB for the outgoing alert message */
ECB ecbBuf;
/* IPX address of the sending station */
IPXAddress source;
/*
* IPX address of the destination. The reserved field is necessary
* because addr is obtained using the bindery API call FindPropertyValue
* which returns 128 bytes.
*/
struct Dest_s {
IPXAddress addr;
char reserved[116];
} dest;
#define DATABUFLEN (sizeof(NMVTEvt_t) - 1 + NMVTDATALEN)
/* Buffer for the alert and the IPX header */
struct {
IPXHeader hdr;
unsigned char ipxData[DATABUFLEN];
} eventBuf;
void main (void)
{
u8_t flag = 0, more = 0;
u16_t transport;
if (IPXInitialize () != 0)
exit (0);
/* get the source network/node address and local server name */
(void) IPXGetInternetworkAddress ((unsigned char *) &source);
printf ("\r\nEnter target server name: ");
gets (target_server);
/* convert to upper case for bindery comparison */
strupr (target_server);
/*
** Find the file server in the bindery with the given target name
** and get its address.
*/
if (ReadPropertyValue (target_server, OT_FILE_SERVER, "NET_ADDRESS", 1,
(unsigned char *) &dest, &more, &flag) != 0)
{
printf("\r\nUnknown server.\r\n");
exit (0);
}
memset ((char *) &ecbBuf, '\0', sizeof(ECB));
/* fetch the immediate address into the ECB for the target server */
*((unsigned short *)dest.addr.socket) = NVSOCKET;
if (IPXGetLocalTarget ((BYTE *) &dest.addr, (BYTE *)ecbBuf.immediateAddress, (int *)&transport) != 0)
exit (0);
/*
** Fill in remainder of the ECB, the IPX header and the
** message data itself.
*/
fill_in_msg ();
/* send the alert to the CE */
IPXSendPacket (&ecbBuf);
}
void fill_in_msg (void)
{
NMVTEvt_t *eventptr;
eventptr = (NMVTEvt_t *)&(eventBuf.ipxData);
eventptr->PrimType = NM_EVENT_NOTIFICATION;
eventptr->InputType = NVEVENT_NMVT;
eventptr->ServerName[0] = '\0';
eventptr->EventDataCount = 1; /* always 1 data vector */
eventptr->EventData.DataType = NMVT_TYPE; /* data vector type */
eventptr->EventData.Count = 1; /* always 1 */
eventptr->EventData.DataLen = NMVTDATALEN; /* length of the alert NMVT */
(void)memcpy (eventptr->EventData.NMVTData, msg, NMVTDATALEN);
/* finish filling in the ECB */
ecbBuf.fragmentDescriptor[0].address = (void *)&eventBuf;
ecbBuf.fragmentCount = 1;
ecbBuf.fragmentDescriptor[0].size = sizeof(IPXHeader) + DATABUFLEN;
ecbBuf.inUseFlag = 0;
ecbBuf.completionCode = 0;
ecbBuf.ESRAddress = NULL;
ecbBuf.socketNumber = 0;
/* fill in the IPX header */
eventBuf.hdr.packetType = 4; /* IPX */
memcpy (eventBuf.hdr.destination.network, dest.addr.network, 4);
memcpy (eventBuf.hdr.destination.node, dest.addr.node, 6);
*((unsigned short *)eventBuf.hdr.destination.socket) = NVSOCKET;
memcpy (eventBuf.hdr.source.network, source.network, 4);
memcpy (eventBuf.hdr.source.node, source.node, 6);
*((unsigned short *)eventBuf.hdr.source.socket) = 0;
}