ip_hpux.cpp

来自「Pegasus is an open-source implementation」· C++ 代码 · 共 1,169 行 · 第 1/3 页

CPP
1,169
字号
//%2006//////////////////////////////////////////////////////////////////////////// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;// IBM Corp.; EMC Corporation, The Open Group.// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;// EMC Corporation; VERITAS Software Corporation; The Open Group.// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;// EMC Corporation; Symantec Corporation; The Open Group.//// Permission is hereby granted, free of charge, to any person obtaining a copy// of this software and associated documentation files (the "Software"), to// deal in the Software without restriction, including without limitation the// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or// sell copies of the Software, and to permit persons to whom the Software is// furnished to do so, subject to the following conditions:// // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.////==============================================================================//// Author: Christopher Neufeld <neufeld@linuxcare.com>//         David Kennedy       <dkennedy@linuxcare.com>//// Modified By://         David Kennedy       <dkennedy@linuxcare.com>//         Christopher Neufeld <neufeld@linuxcare.com>//         Al Stone, Hewlett-Packard Company <ahs3@fc.hp.com>//         Jim Metcalfe, Hewlett-Packard Company//         Carlos Bonilla, Hewlett-Packard Company//         Mike Glantz, Hewlett-Packard Company <michael_glantz@hp.com>//         Lyle Wilkinson, Hewlett-Packard Company <lyle_wilkinson@hp.com>//              Carol Ann Krug Graves, Hewlett-Packard Company//                (carolann_graves@hp.com)////%/////////////////////////////////////////////////////////////////////////////* ==========================================================================   Includes.   ========================================================================== */#include "IPPlatform.h"#include <errno.h>PEGASUS_USING_STD;PEGASUS_USING_PEGASUS;String IPInterface::_hostname = String::EMPTY;  // Allocate this staticIPInterface::IPInterface(){}IPInterface::~IPInterface(){}/*================================================================================NAME              : getCaptionDESCRIPTION       :ASSUMPTIONS       : PRE-CONDITIONS    :POST-CONDITIONS   : NOTES             : ================================================================================*/Boolean IPInterface::getCaption(String& s) const{  s = _address;  return true;}/*================================================================================NAME              : getDescriptionDESCRIPTION       :ASSUMPTIONS       : PRE-CONDITIONS    :POST-CONDITIONS   : NOTES             : ================================================================================*/Boolean IPInterface::getDescription(String& s) const{  String sn;  if (getSystemName(sn))  {      s = "IP Protocol Endpoint for " + sn + " (" + _address + ")";      return true;  }  else      return false;}/*================================================================================NAME              : getInstallDateDESCRIPTION       : ASSUMPTIONS       : PRE-CONDITIONS    :POST-CONDITIONS   : NOTES             : ================================================================================*/Boolean IPInterface::getInstallDate(CIMDateTime& d) const{  // Not supported. This property is inherited from  // CIM_ManagedSystemElement, but has no useful meaning  // for an IP address.  return false;}/*================================================================================NAME              : getNameDESCRIPTION       : ASSUMPTIONS       : PRE-CONDITIONS    :POST-CONDITIONS   : NOTES             : ================================================================================*/Boolean IPInterface::getName(String& s) const{  s = _protocol + "_" + _simpleIfName;  return true;}/*================================================================================NAME              : getStatusDESCRIPTION       : ASSUMPTIONS       : PRE-CONDITIONS    :POST-CONDITIONS   : NOTES             : ================================================================================*/Boolean IPInterface::getStatus(String& s) const{  // This property is inherited from CIM_ManagedSystemElement,  // is not relevant.  return false;}/*================================================================================NAME              : getSystemNameDESCRIPTION       : Platform-specific routine to get the System NameASSUMPTIONS       : NonePRE-CONDITIONS    :POST-CONDITIONS   : NOTES             : ================================================================================*/Boolean IPInterface::getSystemName(String& s){    struct hostent *he;    char hn[PEGASUS_MAXHOSTNAMELEN + 1];    // fill in hn with what this system thinks is its name    gethostname(hn, sizeof(hn));    hn[sizeof(hn)-1] = 0;    // find out what the nameservices think is its full name    // but if that failed, return what gethostname said    if (he = gethostbyname(hn))    {        s = String(he->h_name);    }    else    {        s = String(hn);    }    return true;}/*================================================================================NAME              : getNameFormatDESCRIPTION       : ASSUMPTIONS       : PRE-CONDITIONS    :POST-CONDITIONS   : NOTES             : ================================================================================*/Boolean IPInterface::getNameFormat(String& s) const{  s = "<Protocol>_<InterfaceName>";  return true;}/*================================================================================NAME              : getProtocolTypeDESCRIPTION       : ASSUMPTIONS       : PRE-CONDITIONS    :POST-CONDITIONS   : NOTES             : ================================================================================*/Boolean IPInterface::getProtocolType(Uint16& i16) const{/*  From the MOF for CIM_ProtocolEndpoint.ProtocolType:   ValueMap {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",     "10", "11", "12", "13", "14", "15", "16", "17", "18",     "19", "20", "21", "22", "23", "24", "25", "26", "27"},  Values {"Unknown", "Other", "IPv4", "IPv6", "IPX",    "AppleTalk", "DECnet", "SNA", "CONP", "CLNP",   "VINES", "XNS", "ATM", "Frame Relay",   "Ethernet", "TokenRing", "FDDI", "Infiniband",    "Fibre Channel", "ISDN BRI Endpoint",    "ISDN B Channel Endpoint", "ISDN D Channel Endpoint",     // 22    "IPv4/v6", "BGP", "OSPF", "MPLS", "UDP", "TCP"},*/  if (String::equal(_protocol,PROTOCOL_IPV4))  {	i16 = 2;  // IPv4	return true;  }  else if (String::equal(_protocol,PROTOCOL_IPV6))  {	i16 = 3;  // IPv6	return true;  }  else return false;}/*================================================================================NAME              : getOtherTypeDesriptionDESCRIPTION       : ASSUMPTIONS       : PRE-CONDITIONS    :POST-CONDITIONS   : NOTES             : ================================================================================*/Boolean IPInterface::getOtherTypeDescription(String& s) const{  // The caller must know to set the value to NULL (XML: no <VALUE> element)  s = String::EMPTY;  return true;}/*================================================================================NAME              : getAddressDESCRIPTION       : ASSUMPTIONS       : PRE-CONDITIONS    :POST-CONDITIONS   : NOTES             : ================================================================================*/Boolean IPInterface::getAddress(String& s) const{  s = _address;  return true;}/*================================================================================NAME              : getSubnetMaskDESCRIPTION       : ASSUMPTIONS       : PRE-CONDITIONS    :POST-CONDITIONS   : NOTES             : ================================================================================*/Boolean IPInterface::getSubnetMask(String& s) const{  s = _subnetMask;  return true;}/*================================================================================NAME              : getAddressTypeDESCRIPTION       : ASSUMPTIONS       : PRE-CONDITIONS    :POST-CONDITIONS   : NOTES             : ================================================================================*/Boolean IPInterface::getAddressType(Uint16& i16) const{  /*      From CIM v2.6.0 MOF for CIM_IPProtocolEndpoint.AddressType:	 ValueMap {"0", "1", "2"},	 Values {"Unknown", "IPv4", "IPv6"} ]  */  if (String::equal(_protocol,PROTOCOL_IPV4))  {	i16 = 1;  // IPv4	return true;  }  else if (String::equal(_protocol,PROTOCOL_IPV6))  {	i16 = 2;  // IPv6	return true;  }  else return false;}/*================================================================================NAME              : getIPVersionSupportDESCRIPTION       : ASSUMPTIONS       : PRE-CONDITIONS    :POST-CONDITIONS   : NOTES             : ================================================================================*/Boolean IPInterface::getIPVersionSupport(Uint16& i16) const{  /*      From CIM v2.6.0 MOF for CIM_IPProtocolEndpoint.IPVersionSupport:	 ValueMap {"0", "1", "2"},	 Values {"Unknown", "IPv4 Only", "IPv6 Only"} ]  */  if (String::equal(_protocol,PROTOCOL_IPV4))  {	i16 = 1;  // IPv4 Only	return true;  }  else if (String::equal(_protocol,PROTOCOL_IPV6))  {	i16 = 2;  // IPv6 Only	return true;  }  else return false;}/*================================================================================NAME              : getFrameTypeDESCRIPTION       : ASSUMPTIONS       : PRE-CONDITIONS    :POST-CONDITIONS   : NOTES             : ================================================================================*/Boolean IPInterface::getFrameType(Uint16& i16) const{  /*     From CIM v2.6.0 MOF for CIM_BindsToLANEndpoint.FrameType        ValueMap {"0", "1", "2", "3", "4"},        Values {"Unknown", "Ethernet", "802.2", "SNAP", "Raw802.3"} ]  */  i16 = 1;  // Ethernet  return true;}/*================================================================================

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?