00001 /*****************************************************************************/ 00002 /* */ 00003 /* XrdMonCtrAdmin.cc */ 00004 /* */ 00005 /* (c) 2005 by the Board of Trustees of the Leland Stanford, Jr., University */ 00006 /* All Rights Reserved */ 00007 /* Produced by Jacek Becla for Stanford University under contract */ 00008 /* DE-AC02-76SF00515 with the Department of Energy */ 00009 /*****************************************************************************/ 00010 00011 // $Id: XrdMonCtrAdmin.cc 24468 2008-06-22 16:47:03Z ganis $ 00012 00013 #include "XrdMon/XrdMonCtrAdmin.hh" 00014 #include "XrdMon/XrdMonErrors.hh" 00015 #include "XrdMon/XrdMonException.hh" 00016 00017 #include "XrdSys/XrdSysHeaders.hh" 00018 00019 #include <netinet/in.h> /* ntohs */ 00020 #include <string.h> 00021 00022 using std::cout; 00023 using std::endl; 00024 00025 void 00026 XrdMonCtrAdmin::doIt(kXR_int16 command, kXR_int16 arg) 00027 { 00028 switch (command) { 00029 case c_shutdown: { 00030 throw XrdMonException(SIG_SHUTDOWNNOW); 00031 } 00032 default: { 00033 cout << "Invalid admin command: " << command << " ignored" << endl; 00034 throw XrdMonException(ERR_UNKNOWN); 00035 } 00036 } 00037 } 00038 00039 void 00040 XrdMonCtrAdmin::decodeAdminPacket(const char* packet, 00041 kXR_int16& command, 00042 kXR_int16& arg) 00043 { 00044 kXR_int16 x16; 00045 int8_t offset = HDRLEN; 00046 memcpy(&x16, packet+offset, sizeof(kXR_int16)); 00047 offset += sizeof(kXR_int16); 00048 command = ntohs(x16); 00049 00050 memcpy(&x16, packet+offset, sizeof(kXR_int16)); 00051 offset += sizeof(kXR_int16); 00052 arg = ntohs(x16); 00053 }