#module IPC_BACKTRANSLATE /* ************************************************************************** * Copyright (C) 1993 by * * DIGITAL Equipment Corporation, Maynard, Mass. * * * * This software is furnished under a license and may be used and copied * * only in accordance with the terms of such license and with the * * inclusion of the above copyright notice. This software or any other * * copies thereof may not be provided or otherwise made available to any * * other person. No title to or ownership of the software is hereby * * transferred. * * * * The information in this software is subject to change without notice * * and should not be construed as a commitment by DIGITAL Equipment * * Corporation. * * * * DIGITAL assumes no responsibility for the use or reliability of its * * software on equipment which is not supplied by DIGITAL. * * * ************************************************************************** */ /* * * FACILITY: * * DECnet-Vax OSI IPC Example Programs * * ABSTRACT: * * This program translates between node names and addresses, using * the IPC system service with the IPC$K_FC_BACKTRANSLATE function. * * It is built by IPC_BUILD.COM. (Note: If you build the executables * in the EXAMPLES directory, you may want to set the file protections * to allow non-privileged users to execute them.) * * The program is executed as a foreign command, and expects 2 command line * arguments: * * : The node to look up. This argument is an ascii * string that gets passed as to IPC as the input item * NET$K_TAG_NODENAME. This item code supports the * following formats: * * node address: 63.569 * 569 (defaults to local area) * node number: 65081 * synonym: ITWNDY * fullname: .ZKO.ITWNDY * DNVOSI:.ZKO.ITWNDY * last simplename: ITWNDY * external NSAP: NET$49003FAA00040039FE20 * * * : The numeric value of the item code for the item you * wish to retrieve. All IPC definitions are in the * file SYS$LIBRARY:NET_EXTERNALS.H. The current value * of the supported output item codes are: * * NET$K_TAG_NODESYNONYM 61 (6 char synonym) * NET$K_TAG_NODENAME 23 (External format fullname) * NET$K_TAG_NODENAME_INT 60 (Internal format DNS fullname) * NET$K_TAG_IV_ADDRESS 21 (16 bit Phase IV binary address) * NET$K_TAG_DESTINATIONADDRESS 9 (Binary NSAP) * NET$K_TAG_DESTTOWERSET 12 (Complete binary tower set) * * * Define the foreign command as, for example: * * $ bt :== $sys$common:[syshlp.examples.dnvosi]ipc_backtranslate.exe * * To look up, for example, node FOO:.bar.mynode's nodesynonym: * * $ bt FOO:.bar.mynode 61 * * * * MODIFICATION HISTORY: * * X-1 US Ursula Smith 9-Jun-1994 * Change use of TAG_DESTINATIONTOWERSET to TAG_DESTTOWERSET since * that's what they were getting back anyway. * * X-00 MWD0046 MwD 04-Feb-1992 * Module creation. * */ /* * Include the IPC definitions. */ #include /* * Include the definitions for the IPC example common routines. */ #include "ipc_def.h" #define OUTPUT_LIST_SIZE 1024 /* Must hold ANY output! */ #define TEMPLATE_LIST_SIZE (1 * IPC_K_ITEM_HDR_LENGTH) main( unsigned int argc, char *argv[] ) { struct NET$IPCBDEF Ipcb; void *InList_P, *TempList_P, *OutList_P; int Template_Tag, Node_Length, Sts, Index; unsigned char Output_Buffer[ OUTPUT_LIST_SIZE ]; unsigned short int Item_Tag, Item_Size; void *Item_Data_P; struct IV_addr_type { unsigned int Node_ID : 10; unsigned int Node_Area : 6; } *PhaseIV_Addr_P; /* * Parse command line arguments. */ if( argc != 3 ) { printf( "Usage: $ipc_backtranslate \n" ); printf( "See the comments in IPC_BACKTRANSLATE.C for details.\n" ); exit( 0 ); } else { Template_Tag = atoi( argv[ 2 ] ); Node_Length = strlen( argv[ 1 ] ); } /* * Allocate the item lists. */ OutList_P = item_list__new( OUTPUT_LIST_SIZE ); InList_P = item_list__new( Node_Length + IPC_K_ITEM_HDR_LENGTH ); TempList_P = item_list__new( TEMPLATE_LIST_SIZE ); if( (OutList_P == NULL) || (TempList_P == NULL) || (InList_P == NULL) ) { printf( "Can't allocate VM\n" ); exit( 0 ); } /* * Clear the fields in the IPCB. This is important, since the * $IPC system service will attempt to interpret many/all of the flag * values, and all three item list descriptors, on most calls. */ clear_ipcb( &Ipcb ); /* * Build the input item list containing the argument. */ Sts = item_list__add( InList_P, Node_Length, NET$K_TAG_NODENAME, argv[ 1 ] ); VMS_CHECK( Sts ); /* * Build the template item list requesting whatever was in the * arguement. */ Sts = item_list__add( TempList_P, 0, Template_Tag, NULL ); VMS_CHECK( Sts ); /* * Set up the IPCB descriptor for all 3 item lists. */ item_list__to_desc( InList_P, &Ipcb.IPCB$R_INPUTLSTDESC ); item_list__to_desc( TempList_P, &Ipcb.IPCB$R_TEMPLATELSTDESC ); item_list__to_desc( OutList_P, &Ipcb.IPCB$R_OUTPUTLSTDESC ); /* * Call IPC to (back)translate the node. */ Sts = SYS$IPCW( 0, IPC$K_FC_BACKTRANSLATE, &Ipcb, 0, 0 ); VMS_CHECK( Sts ); IPC_CHECK( Ipcb ); /* * Update the output item list control info from the IPCB, then * read thru it. */ item_list__output( OutList_P, &Ipcb ); while((Sts = item_list__findnext( OutList_P, &Item_Size, &Item_Tag, &Item_Data_P ) == IPC_S_ITEM_SUCCESS)) { printf( "On output, tag %u, length %u, value:\n", Item_Tag, Item_Size ); if( Item_Size != 0 ) { switch( Item_Tag ) { case NET$K_TAG_NODESYNONYM : case NET$K_TAG_NODENAME : memcpy( Output_Buffer, Item_Data_P, Item_Size ); Output_Buffer[ Item_Size ] = 0; printf( "%s\n", Output_Buffer ); break; case NET$K_TAG_IV_ADDRESS : PhaseIV_Addr_P = (struct IV_addr_type *)Item_Data_P; printf( "%u.%u\n", PhaseIV_Addr_P->Node_Area, PhaseIV_Addr_P->Node_ID ); break; default : Index = 0; while( Index < Item_Size ) { printf( "%02x", *( (unsigned char *)Item_Data_P + Index ) ); Index++; } printf( "\n" ); break; } /* Item Tag cases */ } /* Non-0 length */ } /* Next item */ }