示例#1
0
/*
================================================================================
NAME              : _constructKeyBindings
DESCRIPTION       : Constructs an array of keybindings for an IP Interface
ASSUMPTIONS       : None
PRE-CONDITIONS    :
POST-CONDITIONS   :
NOTES             :
PARAMETERS        : className, Process
================================================================================
*/
Array<CIMKeyBinding> BIPTLEpProvider::_constructKeyBindings(
					const CIMNamespaceName &nameSpace,
					const IPInterface &_ipif)
{
#ifdef DEBUG
  cout << "BIPTLEpProvider::_constructKeyBindings()" << endl;
#endif

  Array<CIMKeyBinding> keyBindings;
  String s, sn;
  CIMObjectPath op;

  if (_ipif.getSystemName(sn) == false)
  {
	throw CIMNotSupportedException(
		String("Host-specific module doesn't support Key `") +
		PROPERTY_SYSTEM_NAME.getString() + String("'"));
  }

  // Construct the key bindings
  op = CIMObjectPath(sn, //hostname
		       nameSpace,
		       CLASS_CIM_LAN_ENDPOINT,
                       _constructReference(
		                   CLASS_CIM_LAN_ENDPOINT,
				   sn,_ipif.get_LANInterfaceName()) );

  keyBindings.append(CIMKeyBinding(PROPERTY_ANTECEDENT,
                                   op.toString(),
                                   CIMKeyBinding::REFERENCE));

  if (_ipif.getName(s))
  {
	  op = CIMObjectPath(sn, //hostname
			       nameSpace,
			       CLASS_CIM_IP_PROTOCOL_ENDPOINT,
                               _constructReference(
			                   CLASS_CIM_IP_PROTOCOL_ENDPOINT,
					   sn,s) );

	  keyBindings.append(CIMKeyBinding(PROPERTY_DEPENDENT,
			     op.toString(),
                             CIMKeyBinding::REFERENCE));
  }
  else
  {
	throw CIMNotSupportedException(
		String("Host-specific module doesn't support Key `") +
		PROPERTY_NAME.getString() + String("'"));
  }

#ifdef DEBUG
  cout << "BIPTLEpProvider::_constructKeyBindings() -- done" << endl;
#endif

  return keyBindings;
}
//Virtual destructor.  Making derived classes deallocate properly.
TKSyncherInterface::~TKSyncherInterface(void)
{
	IPInterface notify;
	notify.m_type=notify.DEREGISTER;
	notify.v_strings.push_back(m_source);

	byte buf[4096];
	notify.WriteToBuffer(buf);
	DllInterface::SendData(syncherspace::m_syncher_app,buf);
}
//call to have the source rescan a particular source directory.  effectively recalculating all the sha1's
void TKSyncherInterface::RescanSource(const char* source_name)
{
	if(source_name==NULL)
		return;
	IPInterface notify;
	notify.m_type=notify.SOURCERESCAN;
	notify.v_strings.push_back(string(source_name));  //push_back the source_name so that the syncher can only rescan a certain source

	byte buf[4096];
	notify.WriteToBuffer(buf);
	DllInterface::SendData(syncherspace::m_syncher_app,buf);	
}
//source is the name of the source that you want to subscribe to.  if that source contacts this trapperkeeper, it will only synch if someone is subscribed to that source.
void TKSyncherInterface::Register(Dll* pDll,char *source){
	if(mb_registered)
		return;

	Interface::Register(pDll);
	m_source=source;

	IPInterface notify;
	notify.m_type=notify.REGISTER;
	notify.v_strings.push_back(m_source);

	byte buf[4096];
	notify.WriteToBuffer(buf);
	if(DllInterface::SendData(syncherspace::m_syncher_app,buf))
		mb_registered=true;
}
示例#5
0
/*
================================================================================
NAME              : _constructInstance
DESCRIPTION       : Constructs instance by adding its properties. The
                  : IP Interface argument has already been filled in
                  : with data from an existing IP Interface
ASSUMPTIONS       : None
PRE-CONDITIONS    :
POST-CONDITIONS   :
NOTES             :
PARAMETERS        : className, Process
================================================================================
*/
CIMInstance BIPTLEpProvider::_constructInstance(
    const CIMName &className,
    const CIMNamespaceName &nameSpace,
    const IPInterface &_ipif)
{
#ifdef DEBUG
  cout << "BIPTLEpProvider::_constructInstance()" << endl;
#endif

  String s;
  Uint16 i16;
  CIMDateTime d;

  CIMInstance inst(className);

  // Set path

  inst.setPath(CIMObjectPath(String::EMPTY, // hostname
                             nameSpace,
                             CLASS_PG_BINDS_IP_TO_LAN_ENDPOINT,
                             _constructKeyBindings(nameSpace, _ipif)));

// ======================================================
// The following properties are in CIM_ServiceAccessPoint
// ======================================================

  // The keys for this class are:
  // CIM_LANEndpoint REF Antecedent
  // CIM_IPProtocolEndpoint REF Dependent

  // Rather than rebuilding the key properties, we will reuse
  // the values that were inserted for us in the ObjectPath,
  // trusting that this was done correctly

  // Get the keys
  Array<CIMKeyBinding> key = inst.getPath().getKeyBindings();
  // loop through keys, inserting them as properties
  // luckily, all keys for this class are strings, so no
  // need to check key type
  for (Uint32 i=0; i<key.size(); i++)
  {
    // add a property created from the name and value
    inst.addProperty(CIMProperty(key[i].getName(),key[i].getValue()));
  }

// CIM_BindsToLANEndpoint

//   uint16 FrameType
  if (_ipif.getFrameType(i16))
    inst.addProperty(CIMProperty(PROPERTY_FRAME_TYPE,i16));

#ifdef DEBUG
  cout << "BIPTLEpProvider::_constructInstance() -- done" << endl;
#endif

  return inst;
}
示例#6
0
/*
================================================================================
NAME              : _constructKeyBindings
DESCRIPTION       : Constructs an array of keybindings for an IP Interface
ASSUMPTIONS       : None
PRE-CONDITIONS    :
POST-CONDITIONS   :
NOTES             :
PARAMETERS        : IP Interface
================================================================================
*/
Array<CIMKeyBinding> IPPEpProvider::_constructKeyBindings(
					const IPInterface& _ipif)
{
#ifdef DEBUG
  cout << "IPPEpProvider::_constructKeyBindings()" << endl;
#endif

  Array<CIMKeyBinding> keyBindings;
  String s;


  // Construct the key bindings
  keyBindings.append(CIMKeyBinding(PROPERTY_SYSTEM_CREATION_CLASS_NAME,
	    	                CLASS_CIM_UNITARY_COMPUTER_SYSTEM.getString(),
                                CIMKeyBinding::STRING));

  keyBindings.append(CIMKeyBinding(PROPERTY_CREATION_CLASS_NAME,
		                CLASS_CIM_IP_PROTOCOL_ENDPOINT.getString(),
                                CIMKeyBinding::STRING));

  if (_ipif.getSystemName(s))
	keyBindings.append(CIMKeyBinding(PROPERTY_SYSTEM_NAME,
                                s, CIMKeyBinding::STRING));
  else
	throw CIMNotSupportedException(
		String("Host-specific module doesn't support Key `") +
		PROPERTY_SYSTEM_NAME.getString() + String("'"));

  if (_ipif.getName(s))
	keyBindings.append(CIMKeyBinding(PROPERTY_NAME,
                                s, CIMKeyBinding::STRING));
  else
	throw CIMNotSupportedException(
		String("Host-specific module doesn't support Key `") +
		PROPERTY_NAME.getString() + String("'"));

#ifdef DEBUG
  cout << "IPPEpProvider::_constructKeyBindings() -- done" << endl;
#endif

  return keyBindings;
}
//Called by the 'system' when dll data has arrived.
bool TKSyncherInterface::InterfaceReceivedData(AppID from_app_id, void* input_data, void* output_data){
	if(from_app_id.m_app_id!=syncherspace::m_syncher_app.m_app_id || !mb_registered)  //only care if it is from the syncher
		return false;

	IPInterface message;
	message.ReadFromBuffer((byte*)input_data);
	if(message.v_strings.size()<1)
		return false;

	//make sure the source name matches this one.
	if(stricmp(message.v_strings[0].c_str(),m_source.c_str())!=0)
		return false;

	if(message.m_type==message.CURRENTMAP ){
		UINT tmp;
		m_current_map.ReadFromBuffer(message.GetData(tmp));
		return true;
	}

	if(message.m_type==message.ISCHANGING){
		mb_changing=true;
	}

	if(message.m_type==message.MAPDONECHANGING && message.v_strings.size()==2){
		MapFinishedChanging((char*)message.v_strings[1].c_str());
		mb_changing=false;
		return true;
	}

	if(message.m_type==message.MAPHASCHANGED && message.v_strings.size()==2){
		MapHasChanged((char*)message.v_strings[1].c_str());
		return true;
	}

	return false;
}
示例#8
0
/*
================================================================================
NAME              : _constructInstance
DESCRIPTION       : Constructs instance by adding its properties. The
                  : IP Interface argument has already been filled in
                  : with data from an existing IP Interface
ASSUMPTIONS       : None
PRE-CONDITIONS    :
POST-CONDITIONS   :
NOTES             :
PARAMETERS        : className, nameSpace, IP Interface
================================================================================
*/
CIMInstance IPPEpProvider::_constructInstance(
    const CIMName &className,
    const CIMNamespaceName &nameSpace,
    const IPInterface &_ipif)
{
#ifdef DEBUG
  cout << "IPPEpProvider::_constructInstance()" << endl;
#endif

  String s;
  Uint16 i16;
  CIMDateTime d;

  CIMInstance inst(className);

  // Set path

  inst.setPath(CIMObjectPath(String::EMPTY, // hostname
                             nameSpace,
                             CLASS_CIM_IP_PROTOCOL_ENDPOINT,
                             _constructKeyBindings(_ipif)));

// CIM_ManagedElement

//   string Caption
  if (_ipif.getCaption(s))
    inst.addProperty(CIMProperty(PROPERTY_CAPTION,s));

//   string Description
  if (_ipif.getDescription(s))
    inst.addProperty(CIMProperty(PROPERTY_DESCRIPTION,s));

// CIM_ManagedSystemElement

//   datetime InstallDate
  if (_ipif.getInstallDate(d))
    inst.addProperty(CIMProperty(PROPERTY_INSTALL_DATE,d));

//   string Name    // Overridden in CIM_ServiceAccessPoint

//   string Status
  if (_ipif.getStatus(s))
    inst.addProperty(CIMProperty(PROPERTY_STATUS,s));

// CIM_LogicalElement
//   ** No local properties added in this class **

// ======================================================
// The following properties are in CIM_ServiceAccessPoint
// ======================================================

  // The keys for this class are:
  // [ key ] string SystemCreationClassName
  // [ key ] string SystemName
  // [ key ] string CreationClassName
  // [ key ] string Name

  // Rather than rebuilding the key properties, we will reuse
  // the values that were inserted for us in the ObjectPath,
  // trusting that this was done correctly

  // Get the keys
  Array<CIMKeyBinding> key = inst.getPath().getKeyBindings();
  // loop through keys, inserting them as properties
  // luckily, all keys for this class are strings, so no
  // need to check key type
  for (Uint32 i=0; i<key.size(); i++)
  {
    // add a property created from the name and value
    inst.addProperty(CIMProperty(key[i].getName(),key[i].getValue()));
  }

// CIM_ProtocolEndpoint

//   string NameFormat
  if (_ipif.getNameFormat(s))
    inst.addProperty(CIMProperty(PROPERTY_NAME_FORMAT,s));

//   uint16 ProtocolType
  if (_ipif.getProtocolType(i16))
    inst.addProperty(CIMProperty(PROPERTY_PROTOCOL_TYPE,i16));

//   string OtherTypeDescription
  if (_ipif.getOtherTypeDescription(s))
  {
    // if an empty string was returned, the value must be set to NULL
    // with type string, not an array
    if (String::equal(s,String::EMPTY))
    {
      inst.addProperty(CIMProperty(PROPERTY_OTHER_TYPE_DESCRIPTION,
                                   CIMValue(CIMTYPE_STRING, false)));
    }
    else
    {
      inst.addProperty(CIMProperty(PROPERTY_OTHER_TYPE_DESCRIPTION,s));
    }
  }

// CIM_IPProtocolEndpoint

//   string Address
  if (_ipif.getAddress(s))
    inst.addProperty(CIMProperty(PROPERTY_ADDRESS,s));

//   string SubnetMask
  if (_ipif.getSubnetMask(s))
    inst.addProperty(CIMProperty(PROPERTY_SUBNET_MASK,s));

//   uint16 AddressType
  if (_ipif.getAddressType(i16))
    inst.addProperty(CIMProperty(PROPERTY_ADDRESS_TYPE,i16));

//   uint16 IPVersionSupport
  if (_ipif.getIPVersionSupport(i16))
    inst.addProperty(CIMProperty(PROPERTY_IP_VERSION_SUPPORT,i16));

#ifdef DEBUG
  cout << "IPPEpProvider::_constructInstance() -- done" << endl;
#endif

  return inst;
}