Moving micasa 1.5 trunk to Novell forge.
This commit is contained in:
58
c_micasad/lib/AssemblyInfo.cs
Normal file
58
c_micasad/lib/AssemblyInfo.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
//
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
//
|
||||
[assembly: AssemblyTitle("")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
//
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
//
|
||||
// In order to sign your assembly you must specify a key to use. Refer to the
|
||||
// Microsoft .NET Framework documentation for more information on assembly signing.
|
||||
//
|
||||
// Use the attributes below to control which key is used for signing.
|
||||
//
|
||||
// Notes:
|
||||
// (*) If no key is specified, the assembly is not signed.
|
||||
// (*) KeyName refers to a key that has been installed in the Crypto Service
|
||||
// Provider (CSP) on your machine. KeyFile refers to a file which contains
|
||||
// a key.
|
||||
// (*) If the KeyFile and the KeyName values are both specified, the
|
||||
// following processing occurs:
|
||||
// (1) If the KeyName can be found in the CSP, that key is used.
|
||||
// (2) If the KeyName does not exist and the KeyFile does exist, the key
|
||||
// in the KeyFile is installed into the CSP and used.
|
||||
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
|
||||
// When specifying the KeyFile, the location of the KeyFile should be
|
||||
// relative to the project output directory which is
|
||||
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
|
||||
// located in the project directory, you would specify the AssemblyKeyFile
|
||||
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
|
||||
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
|
||||
// documentation for more information on this.
|
||||
//
|
||||
[assembly: AssemblyDelaySign(false)]
|
||||
[assembly: AssemblyKeyFile("")]
|
||||
[assembly: AssemblyKeyName("")]
|
||||
20
c_micasad/lib/Makefile
Normal file
20
c_micasad/lib/Makefile
Normal file
@@ -0,0 +1,20 @@
|
||||
#
|
||||
# configure environment
|
||||
#
|
||||
TARGET = Novell.CASA.Common
|
||||
CS_NAME = $(TARGET)$(xtra).$(CSH)
|
||||
include global.mak
|
||||
include defaults.$(PLAT)
|
||||
include rules.mak
|
||||
|
||||
|
||||
#
|
||||
# target object and source files
|
||||
#
|
||||
include src.$(PLAT)
|
||||
include objs.$(PLAT)
|
||||
|
||||
#
|
||||
# targets
|
||||
#
|
||||
include target.cs
|
||||
145
c_micasad/lib/Novell.CASA.Common.csproj
Normal file
145
c_micasad/lib/Novell.CASA.Common.csproj
Normal file
@@ -0,0 +1,145 @@
|
||||
<VisualStudioProject>
|
||||
<CSHARP
|
||||
ProjectType = "Local"
|
||||
ProductVersion = "7.10.3077"
|
||||
SchemaVersion = "2.0"
|
||||
ProjectGuid = "{57CD94A2-5B4A-40C3-8189-CB760FB78357}"
|
||||
>
|
||||
<Build>
|
||||
<Settings
|
||||
ApplicationIcon = ""
|
||||
AssemblyKeyContainerName = ""
|
||||
AssemblyName = "Novell.CASA.Common"
|
||||
AssemblyOriginatorKeyFile = ""
|
||||
DefaultClientScript = "JScript"
|
||||
DefaultHTMLPageLayout = "Grid"
|
||||
DefaultTargetSchema = "IE50"
|
||||
DelaySign = "false"
|
||||
OutputType = "Library"
|
||||
PreBuildEvent = ""
|
||||
PostBuildEvent = ""
|
||||
RootNamespace = "MiCasaLibrary"
|
||||
RunPostBuildEvent = "OnBuildSuccess"
|
||||
StartupObject = ""
|
||||
>
|
||||
<Config
|
||||
Name = "Debug"
|
||||
AllowUnsafeBlocks = "false"
|
||||
BaseAddress = "285212672"
|
||||
CheckForOverflowUnderflow = "false"
|
||||
ConfigurationOverrideFile = ""
|
||||
DefineConstants = "DEBUG;TRACE;W32"
|
||||
DocumentationFile = ""
|
||||
DebugSymbols = "true"
|
||||
FileAlignment = "4096"
|
||||
IncrementalBuild = "false"
|
||||
NoStdLib = "false"
|
||||
NoWarn = ""
|
||||
Optimize = "false"
|
||||
OutputPath = "bin\Debug\"
|
||||
RegisterForComInterop = "false"
|
||||
RemoveIntegerChecks = "false"
|
||||
TreatWarningsAsErrors = "false"
|
||||
WarningLevel = "4"
|
||||
/>
|
||||
<Config
|
||||
Name = "Release"
|
||||
AllowUnsafeBlocks = "false"
|
||||
BaseAddress = "285212672"
|
||||
CheckForOverflowUnderflow = "false"
|
||||
ConfigurationOverrideFile = ""
|
||||
DefineConstants = "TRACE; W32"
|
||||
DocumentationFile = ""
|
||||
DebugSymbols = "false"
|
||||
FileAlignment = "4096"
|
||||
IncrementalBuild = "false"
|
||||
NoStdLib = "false"
|
||||
NoWarn = ""
|
||||
Optimize = "true"
|
||||
OutputPath = "bin\Release\"
|
||||
RegisterForComInterop = "false"
|
||||
RemoveIntegerChecks = "false"
|
||||
TreatWarningsAsErrors = "false"
|
||||
WarningLevel = "4"
|
||||
/>
|
||||
</Settings>
|
||||
<References>
|
||||
<Reference
|
||||
Name = "System"
|
||||
AssemblyName = "System"
|
||||
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.Data"
|
||||
AssemblyName = "System.Data"
|
||||
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "System.XML"
|
||||
AssemblyName = "System.Xml"
|
||||
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "AppModule.NamedPipes"
|
||||
AssemblyName = "AppModule.NamedPipes"
|
||||
HintPath = "..\..\extern\w32\namedpipes\AppModule.NamedPipes.dll"
|
||||
/>
|
||||
<Reference
|
||||
Name = "AppModule.InterProcessComm"
|
||||
AssemblyName = "AppModule.InterProcessComm"
|
||||
HintPath = "..\..\extern\w32\namedpipes\AppModule.InterProcessComm.dll"
|
||||
/>
|
||||
</References>
|
||||
</Build>
|
||||
<Files>
|
||||
<Include>
|
||||
<File
|
||||
RelPath = "AssemblyInfo.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "common\LinkedKeyInfo.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "common\MiCASAStore.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "common\Ping.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "common\WrappedObject.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "communication\IClientChannel.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "communication\IPCClientFactory.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "communication\MiCasaRequestReply.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
<File
|
||||
RelPath = "communication\WinIPCClientChannel.cs"
|
||||
SubType = "Code"
|
||||
BuildAction = "Compile"
|
||||
/>
|
||||
</Include>
|
||||
</Files>
|
||||
</CSHARP>
|
||||
</VisualStudioProject>
|
||||
|
||||
48
c_micasad/lib/Novell.CASA.Common.csproj.user
Normal file
48
c_micasad/lib/Novell.CASA.Common.csproj.user
Normal file
@@ -0,0 +1,48 @@
|
||||
<VisualStudioProject>
|
||||
<CSHARP LastOpenVersion = "7.10.3077" >
|
||||
<Build>
|
||||
<Settings ReferencePath = "D:\csharp\namedpipe2\AppModule.InterProcessComm\bin\Debug\;D:\csharp\namedpipe2\AppModule.NamedPipes\bin\Debug\;D:\casatest\extern\w32\namedpipes\" >
|
||||
<Config
|
||||
Name = "Debug"
|
||||
EnableASPDebugging = "false"
|
||||
EnableASPXDebugging = "false"
|
||||
EnableUnmanagedDebugging = "false"
|
||||
EnableSQLServerDebugging = "false"
|
||||
RemoteDebugEnabled = "false"
|
||||
RemoteDebugMachine = ""
|
||||
StartAction = "Project"
|
||||
StartArguments = ""
|
||||
StartPage = ""
|
||||
StartProgram = ""
|
||||
StartURL = ""
|
||||
StartWorkingDirectory = ""
|
||||
StartWithIE = "true"
|
||||
/>
|
||||
<Config
|
||||
Name = "Release"
|
||||
EnableASPDebugging = "false"
|
||||
EnableASPXDebugging = "false"
|
||||
EnableUnmanagedDebugging = "false"
|
||||
EnableSQLServerDebugging = "false"
|
||||
RemoteDebugEnabled = "false"
|
||||
RemoteDebugMachine = ""
|
||||
StartAction = "Project"
|
||||
StartArguments = ""
|
||||
StartPage = ""
|
||||
StartProgram = ""
|
||||
StartURL = ""
|
||||
StartWorkingDirectory = ""
|
||||
StartWithIE = "true"
|
||||
/>
|
||||
</Settings>
|
||||
</Build>
|
||||
<OtherProjectSettings
|
||||
CopyProjectDestinationFolder = ""
|
||||
CopyProjectUncPath = ""
|
||||
CopyProjectOption = "0"
|
||||
ProjectView = "ShowAllFiles"
|
||||
ProjectTrust = "0"
|
||||
/>
|
||||
</CSHARP>
|
||||
</VisualStudioProject>
|
||||
|
||||
42
c_micasad/lib/common/LinkedKeyInfo.cs
Normal file
42
c_micasad/lib/common/LinkedKeyInfo.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
|
||||
namespace Novell.CASA.MiCasa.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for LinkInfo.
|
||||
/// </summary>
|
||||
///
|
||||
[Serializable]
|
||||
public class LinkedKeyInfo
|
||||
{
|
||||
private string m_sDestStoreID = null;
|
||||
private string m_sDestKeychainID = null;
|
||||
private string m_sDestSecretID = null;
|
||||
private string m_sDestKeyID = null;
|
||||
|
||||
public LinkedKeyInfo(string sDestSecretID, string sDestKey)
|
||||
{
|
||||
if (sDestSecretID.StartsWith("SS_CredSet"))
|
||||
m_sDestSecretID = sDestSecretID;
|
||||
else
|
||||
m_sDestSecretID = "SS_CredSet:" + sDestSecretID + '\0';
|
||||
|
||||
m_sDestKeyID = sDestKey;
|
||||
}
|
||||
|
||||
public string GetLinkID()
|
||||
{
|
||||
return m_sDestSecretID + ":" + m_sDestKeyID;
|
||||
}
|
||||
|
||||
public string GetLinkedSecretID()
|
||||
{
|
||||
return m_sDestSecretID;
|
||||
}
|
||||
|
||||
public string GetLinkedKeyID()
|
||||
{
|
||||
return m_sDestKeyID;
|
||||
}
|
||||
}
|
||||
}
|
||||
29
c_micasad/lib/common/MiCASAStore.cs
Normal file
29
c_micasad/lib/common/MiCASAStore.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using Novell.CASA.MiCasa.Common;
|
||||
using Novell.CASA.MiCasa.Communication;
|
||||
|
||||
namespace Novell.CASA.MiCasa.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for MiCASAStore.
|
||||
/// </summary>
|
||||
public class MiCASAStore
|
||||
{
|
||||
public MiCASAStore()
|
||||
{
|
||||
//
|
||||
// TODO: Add constructor logic here
|
||||
//
|
||||
}
|
||||
|
||||
public static bool IsLocked()
|
||||
{
|
||||
Object o = MiCasaRequestReply.Send(MiCasaRequestReply.VERB_GET_STORE_STATUS);
|
||||
|
||||
if ((o != null) && ((System.Int32)o == 2))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
23
c_micasad/lib/common/Ping.cs
Normal file
23
c_micasad/lib/common/Ping.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
|
||||
namespace Novell.CASA.MiCasa.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Ping.
|
||||
/// </summary>
|
||||
///
|
||||
[Serializable]
|
||||
public class Ping
|
||||
{
|
||||
public Ping()
|
||||
{
|
||||
//
|
||||
// TODO: Add constructor logic here
|
||||
//
|
||||
}
|
||||
|
||||
public string clientmessage;
|
||||
public string servermessage;
|
||||
|
||||
}
|
||||
}
|
||||
99
c_micasad/lib/common/WrappedObject.cs
Normal file
99
c_micasad/lib/common/WrappedObject.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
using System;
|
||||
|
||||
namespace Novell.CASA.MiCasa.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for MessageObject.
|
||||
/// </summary>
|
||||
///
|
||||
[Serializable]
|
||||
public class WrappedObject
|
||||
{
|
||||
public static string DEFAULT_KEYCHAIN_ID = "SSCS_SESSION_KEY_CHAIN_ID\0";
|
||||
|
||||
private int m_verb = 0;
|
||||
private string m_KeychainID = null;
|
||||
private string m_SecretID = null;
|
||||
private string m_KeyID = null;
|
||||
|
||||
private object m_object;
|
||||
|
||||
private int m_rcode = 0;
|
||||
private string m_errorMsg;
|
||||
|
||||
public WrappedObject(int rcode, string errorMsg)
|
||||
{
|
||||
m_rcode = rcode;
|
||||
m_errorMsg = errorMsg;
|
||||
}
|
||||
|
||||
public WrappedObject(int verb, string sKeychainID, string sSecretID, string sKeyID, object theObject)
|
||||
{
|
||||
m_verb = verb;
|
||||
if (sKeychainID != null)
|
||||
m_KeychainID = sKeychainID + '\0';
|
||||
else
|
||||
m_KeychainID = DEFAULT_KEYCHAIN_ID;
|
||||
|
||||
if (sSecretID != null)
|
||||
{
|
||||
if (sSecretID.StartsWith("SS_CredSet"))
|
||||
m_SecretID = sSecretID + '\0';
|
||||
else
|
||||
m_SecretID = "SS_CredSet:" + sSecretID + '\0';
|
||||
}
|
||||
|
||||
if (sKeyID != null)
|
||||
m_KeyID = sKeyID; // + '\0';
|
||||
|
||||
// serialize the object
|
||||
m_object = theObject;
|
||||
}
|
||||
|
||||
public string GetKeyID()
|
||||
{
|
||||
return m_KeyID;
|
||||
}
|
||||
|
||||
public string GetSecretID()
|
||||
{
|
||||
return m_SecretID;
|
||||
}
|
||||
|
||||
public string GetKeychainID()
|
||||
{
|
||||
return m_KeychainID;
|
||||
}
|
||||
|
||||
public object GetObject()
|
||||
{
|
||||
return m_object;
|
||||
}
|
||||
|
||||
public void SetObject(object theobject)
|
||||
{
|
||||
m_object = theobject;
|
||||
}
|
||||
|
||||
public int GetAction()
|
||||
{
|
||||
return m_verb;
|
||||
}
|
||||
|
||||
public void SetError(int rcode, string message)
|
||||
{
|
||||
m_rcode = rcode;
|
||||
m_errorMsg = message;
|
||||
}
|
||||
|
||||
public int GetReturnCode()
|
||||
{
|
||||
return m_rcode;
|
||||
}
|
||||
|
||||
public string GetReturnMessage()
|
||||
{
|
||||
return m_errorMsg;
|
||||
}
|
||||
}
|
||||
}
|
||||
18
c_micasad/lib/communication/IClientChannel.cs
Normal file
18
c_micasad/lib/communication/IClientChannel.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
|
||||
//using sscs.communication.win.NamedPipes;
|
||||
|
||||
|
||||
namespace Novell.CASA.MiCasa.Communication
|
||||
{
|
||||
public interface ClientChannel
|
||||
{
|
||||
void Open();
|
||||
int Read(byte[] buf);
|
||||
byte[] Read();
|
||||
int Write(byte[] buf);
|
||||
void Close();
|
||||
}
|
||||
}
|
||||
28
c_micasad/lib/communication/IPCClientFactory.cs
Normal file
28
c_micasad/lib/communication/IPCClientFactory.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
|
||||
namespace Novell.CASA.MiCasa.Communication
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for IPCClientFactory.
|
||||
/// </summary>
|
||||
public class IPCClientFactory
|
||||
{
|
||||
private IPCClientFactory()
|
||||
{
|
||||
}
|
||||
|
||||
public static ClientChannel CreateClientConnection()
|
||||
{
|
||||
|
||||
#if LINUX
|
||||
return( new UnixIPCClientChannel());
|
||||
#endif
|
||||
#if W32
|
||||
return (new WinIPCClientChannel());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
156
c_micasad/lib/communication/MiCasaRequestReply.cs
Normal file
156
c_micasad/lib/communication/MiCasaRequestReply.cs
Normal file
@@ -0,0 +1,156 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.IO;
|
||||
|
||||
using Novell.CASA.MiCasa.Common;
|
||||
|
||||
namespace Novell.CASA.MiCasa.Communication
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for MiCasaRequestReply.
|
||||
/// </summary>
|
||||
public class MiCasaRequestReply
|
||||
{
|
||||
|
||||
//public const int VERB_GET_SECRET = 1;
|
||||
//public const int VERB_SET_SECRET = 2;
|
||||
//public const int VERB_GET_KEYCHAIN = 3;
|
||||
//public const int VERB_GET_STORE = 4;
|
||||
//public const int VERB_SET_KEYVALUE = 5;
|
||||
//public const int VERB_GET_KEYVALUE = 6;
|
||||
public const int VERB_SET_LINKED_KEY = 7;
|
||||
public const int VERB_GET_LINKED_KEYS = 8;
|
||||
public const int VERB_REMOVE_LINKED_KEY = 9;
|
||||
public const int VERB_WRITE_KEY = 10;
|
||||
public const int VERB_REMOVE_ALL_SECRETS = 11;
|
||||
public const int VERB_LOCK_STORE = 12;
|
||||
public const int VERB_UNLOCK_STORE = 13;
|
||||
public const int VERB_GET_STORE_STATUS = 14;
|
||||
public const int VERB_REMOVE_KEY = 15;
|
||||
public const int VERB_READ_KEY = 16;
|
||||
public const int VERB_GET_KEY_LIST = 17;
|
||||
|
||||
public const int VERB_DUMP_LINKED_KEYS = 96;
|
||||
public const int VERB_CREATE_TEST_SECRETS = 97;
|
||||
public const int VERB_REMOVE_TEST_SECRETS = 98;
|
||||
public const int VERB_PING_MICASAD = 99;
|
||||
|
||||
public MiCasaRequestReply()
|
||||
{
|
||||
//
|
||||
// TODO: Add constructor logic here
|
||||
//
|
||||
}
|
||||
|
||||
public static object Send(int verb)
|
||||
{
|
||||
return Send(verb, null, null, null, null);
|
||||
}
|
||||
|
||||
public static object Send(int verb, object wo)
|
||||
{
|
||||
return Send(verb, null, null, null, wo);
|
||||
}
|
||||
|
||||
public static object Send(int verb,
|
||||
string sKeyChainID,
|
||||
string sSecretID,
|
||||
string sKeyID,
|
||||
object theObject)
|
||||
{
|
||||
|
||||
// Lengths of message fields
|
||||
int MSGID_LEN = 2;
|
||||
int MSG_LEN = 4;
|
||||
WrappedObject request;
|
||||
WrappedObject reply = null;
|
||||
|
||||
// open a client connection
|
||||
//IInterProcessConnection clientConnection = null;
|
||||
|
||||
ClientChannel ipcChannel = IPCClientFactory.CreateClientConnection();
|
||||
ipcChannel.Open();
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
// contruct and serialize the Message Object
|
||||
request = new WrappedObject(verb, sKeyChainID, sSecretID, sKeyID, theObject);
|
||||
|
||||
BinaryFormatter formatter = new BinaryFormatter();
|
||||
MemoryStream ms = new MemoryStream();
|
||||
formatter.Serialize(ms, request);
|
||||
ms.Flush();
|
||||
ms.Position = 0;
|
||||
|
||||
byte[] rawBytes = new byte[2+4+ms.Length];
|
||||
|
||||
byte[] t = new byte[10];
|
||||
|
||||
// set message id
|
||||
int destIndex = 0;
|
||||
ushort msgId = 20;
|
||||
t = BitConverter.GetBytes((ushort)msgId);
|
||||
Array.Copy(t,0,rawBytes,destIndex,MSGID_LEN);
|
||||
destIndex += MSGID_LEN;
|
||||
|
||||
// set the object length
|
||||
//Poorna
|
||||
int msgLen = 2+4+(int)ms.Length;
|
||||
// int msgLen = (int)ms.Length;
|
||||
t = BitConverter.GetBytes(msgLen);
|
||||
// t = BitConverter.GetBytes(ms.Length);
|
||||
Array.Copy(t,0,rawBytes,destIndex,MSG_LEN);
|
||||
destIndex += MSG_LEN;
|
||||
|
||||
// copy in the object
|
||||
Array.Copy(ms.GetBuffer(), 0, rawBytes, destIndex, ms.Length);
|
||||
|
||||
//clientConnection = new ClientPipeConnection("MyPipe", ".");
|
||||
//clientConnection = new ClientPipeConnection(XTIER_RPC_PIPE, ".");
|
||||
//clientConnection.Connect();
|
||||
|
||||
// write the bytes
|
||||
//clientConnection.WriteBytes(rawBytes);
|
||||
ipcChannel.Write(rawBytes);
|
||||
|
||||
// read the bytes
|
||||
//byte[] returnBuffer = clientConnection.ReadBytes();
|
||||
byte[] returnBuffer = ipcChannel.Read();
|
||||
|
||||
if (returnBuffer != null)
|
||||
{
|
||||
// deserialize MessageObject
|
||||
uint iMsgLen = BitConverter.ToUInt32(returnBuffer,0);
|
||||
ms = new MemoryStream(returnBuffer, 4, (int)iMsgLen);
|
||||
ms.Position = 0;
|
||||
reply = (WrappedObject)formatter.Deserialize(ms);
|
||||
|
||||
if (reply.GetReturnCode() != 0)
|
||||
throw new Exception(reply.GetReturnCode().ToString());
|
||||
|
||||
}
|
||||
|
||||
// close the connection
|
||||
//clientConnection.Close();
|
||||
ipcChannel.Close();
|
||||
|
||||
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
Console.WriteLine(e1.ToString());
|
||||
//clientConnection.Dispose();
|
||||
//throw new Exception(e1.ToString());
|
||||
}
|
||||
|
||||
if (reply != null)
|
||||
return reply.GetObject();
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
122
c_micasad/lib/communication/UnixIPCClientChannel.cs
Normal file
122
c_micasad/lib/communication/UnixIPCClientChannel.cs
Normal file
@@ -0,0 +1,122 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.IO;
|
||||
using System.Net.Sockets;
|
||||
using Mono.Unix;
|
||||
|
||||
namespace Novell.CASA.MiCasa.Communication
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for UnixIPCClientChannel.
|
||||
/// </summary>
|
||||
public class UnixIPCClientChannel : ClientChannel
|
||||
{
|
||||
|
||||
private Socket mSocket = null;
|
||||
private string socketFileName = "/tmp/.novellCASA";
|
||||
private EndPoint sockEndPoint;
|
||||
|
||||
public UnixIPCClientChannel()
|
||||
{
|
||||
}
|
||||
|
||||
public void Open()
|
||||
{
|
||||
mSocket = new Socket( AddressFamily.Unix,
|
||||
SocketType.Stream,
|
||||
ProtocolType.IP );
|
||||
|
||||
if (mSocket == null) throw new Exception("could not get socket");
|
||||
sockEndPoint = new UnixEndPoint(socketFileName);
|
||||
mSocket.Connect(sockEndPoint);
|
||||
}
|
||||
|
||||
public int Read(byte[] buf)
|
||||
{
|
||||
buf = Read();
|
||||
|
||||
if (buf != null)
|
||||
{
|
||||
Console.WriteLine("Bytes read = " + buf.Length);
|
||||
return buf.Length;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public byte[] Read()
|
||||
{
|
||||
byte[] returnBuffer = null;
|
||||
int bytesRecvd = 0;
|
||||
|
||||
try
|
||||
{
|
||||
/* We need to read 'msgLen' to know how many bytes to
|
||||
* allocate.
|
||||
*/
|
||||
|
||||
byte[] msgIdBytes = new byte[2];
|
||||
bytesRecvd = mSocket.Receive(msgIdBytes);
|
||||
if( 0 == bytesRecvd )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
byte[] msgLenBytes = new byte[4];
|
||||
bytesRecvd = mSocket.Receive(msgLenBytes);
|
||||
if( 0 == bytesRecvd )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
uint msgLen = BitConverter.ToUInt32(msgLenBytes,0);
|
||||
if( msgLen > 6 )
|
||||
{
|
||||
byte[] buf = new byte[msgLen - 6];
|
||||
bytesRecvd = mSocket.Receive (buf);
|
||||
if( 0 == bytesRecvd )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
returnBuffer = new byte[msgLen];
|
||||
Array.Copy(msgIdBytes,returnBuffer,2);
|
||||
Array.Copy(msgLenBytes,0,returnBuffer,2,4);
|
||||
Array.Copy(buf,0,returnBuffer,6,buf.Length);
|
||||
return returnBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
returnBuffer = new byte[6];
|
||||
Array.Copy(msgIdBytes,returnBuffer,2);
|
||||
Array.Copy(msgLenBytes,0,returnBuffer,2,4);
|
||||
return returnBuffer;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int Write(byte[] buf)
|
||||
{
|
||||
try
|
||||
{
|
||||
mSocket.Send(buf);
|
||||
Console.WriteLine("Bytes written = " + buf.Length);
|
||||
return buf.Length;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
mSocket.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
80
c_micasad/lib/communication/WinIPCClientChannel.cs
Normal file
80
c_micasad/lib/communication/WinIPCClientChannel.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
|
||||
using AppModule.InterProcessComm;
|
||||
using AppModule.NamedPipes;
|
||||
|
||||
namespace Novell.CASA.MiCasa.Communication
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for WinIPCClientChannel.
|
||||
/// </summary>
|
||||
public class WinIPCClientChannel : ClientChannel
|
||||
{
|
||||
|
||||
private static IInterProcessConnection clientConnection = null;
|
||||
private static string XTIER_RPC_PIPE = "SS_RPC_PIPE";
|
||||
|
||||
public WinIPCClientChannel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Open()
|
||||
{
|
||||
if (clientConnection == null)
|
||||
{
|
||||
clientConnection = new ClientPipeConnection(XTIER_RPC_PIPE, ".");
|
||||
clientConnection.Connect();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int Read(byte[] buf)
|
||||
{
|
||||
buf = Read();
|
||||
|
||||
if (buf != null)
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
public byte[] Read()
|
||||
{
|
||||
byte[] returnBuffer;
|
||||
|
||||
try
|
||||
{
|
||||
returnBuffer = clientConnection.ReadBytes();
|
||||
return returnBuffer;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int Write(byte[] buf)
|
||||
{
|
||||
try
|
||||
{
|
||||
clientConnection.WriteBytes(buf);
|
||||
return 0;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.ToString());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
|
||||
//clientConnection.Close();
|
||||
//clientConnection.Dispose();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
11
c_micasad/lib/objs.lux
Normal file
11
c_micasad/lib/objs.lux
Normal file
@@ -0,0 +1,11 @@
|
||||
OBJS=\
|
||||
AssemblyInfo \
|
||||
common/LinkedKeyInfo \
|
||||
common/Ping \
|
||||
common/WrappedObject \
|
||||
common/MiCASAStore \
|
||||
communication/IClientChannel \
|
||||
communication/IPCClientFactory \
|
||||
communication/MiCasaRequestReply \
|
||||
communication/UnixIPCClientChannel
|
||||
|
||||
11
c_micasad/lib/src.lux
Normal file
11
c_micasad/lib/src.lux
Normal file
@@ -0,0 +1,11 @@
|
||||
SRC=\
|
||||
AssemblyInfo.cs \
|
||||
common/LinkedKeyInfo.cs \
|
||||
common/Ping.cs \
|
||||
common/WrappedObject.cs \
|
||||
common/MiCASAStore.cs \
|
||||
communication/IClientChannel.cs \
|
||||
communication/IPCClientFactory.cs \
|
||||
communication/MiCasaRequestReply.cs \
|
||||
communication/UnixIPCClientChannel.cs
|
||||
|
||||
Reference in New Issue
Block a user