private ATTSnapshotCall_t ReadSnapshotCall(IStructReader reader) { try { if ((reader.BaseStream.Length - reader.BaseStream.Position) >= 4) { logger.Info("ATTMonitorCallConfParser.ReadSnapshotCall: read count from stream..."); uint count = reader.ReadUInt32(); logger.Info("ATTMonitorCallConfParser.ReadSnapshotCall: count={0}", count); List <CSTASnapshotCallResponseInfo_t> snapshotCalls = new List <CSTASnapshotCallResponseInfo_t>(); if (count > 0) { if ((reader.BaseStream.Length - reader.BaseStream.Position) >= 8) { logger.Info("ATTMonitorCallConfParser.ReadSnapshotCall: advance the base stream 8 positions..."); reader.BaseStream.Position += 8; } int size = Marshal.SizeOf(typeof(CSTASnapshotCallResponseInfo_t)); for (int i = 0; i < count; i++) { logger.Info("ATTMonitorCallConfParser.ReadSnapshotCall: read snap shot call response from the stream..."); if ((reader.BaseStream.Length - reader.BaseStream.Position) >= size) { object result; if (reader.TryReadStruct(typeof(CSTASnapshotCallResponseInfo_t), out result)) { logger.Info("ATTMonitorCallConfParser.ReadSnapshotCall: successfully read snap shot call response from the stream!"); CSTASnapshotCallResponseInfo_t snapshotCallInfo = (CSTASnapshotCallResponseInfo_t)result; logger.Info("ATTMonitorCallConfParser.ReadSnapshotCall: snapshotCallInfo.deviceOnCall.deviceID.device={0};snapshotCallInfo.deviceOnCall.deviceIDType={1};snapshotCallInfo.deviceOnCall.deviceIDStatus={2};snapshotCallInfo.callIdentifier.callID={3};snapshotCallInfo.callIdentifier.deviceID.device={4};snapshotCallInfo.callIdentifier.devIDType={5};snapshotCallInfo.localConnectionState={6}", snapshotCallInfo.deviceOnCall.deviceID.device, snapshotCallInfo.deviceOnCall.deviceIDType, snapshotCallInfo.deviceOnCall.deviceIDStatus, snapshotCallInfo.callIdentifier.callID, snapshotCallInfo.callIdentifier.deviceID.device, snapshotCallInfo.callIdentifier.devIDType, snapshotCallInfo.localConnectionState); snapshotCalls.Add(snapshotCallInfo); } } } } return(new ATTSnapshotCall_t() { count = count, pInfo = snapshotCalls.ToArray() }); } } catch (Exception err) { logger.Error(string.Format("Error in ATTMonitorCallConfParser.ReadSnapshotCall: {0}", err)); } return(new ATTSnapshotCall_t()); }
public object MarshalNativeToManaged(System.IntPtr pNativeData) { Marshal.PtrToStructure(pNativeData, this.marshaledObj.evt); if (this.marshaledObj.evt.eventHeader.eventClass.eventClass == Csta.CSTACONFIRMATION) { this.marshaledObj.evt.cstaConfirmation = (CSTAConfirmationEvent)Aux.ByteArrayToStructure <CSTAConfirmationEvent>(this.marshaledObj.evt.heap); } // Marshal SnapShotCall Event if (this.marshaledObj.evt.eventHeader.eventClass.eventClass == Csta.CSTACONFIRMATION && this.marshaledObj.evt.eventHeader.eventType.eventType == Csta.CSTA_SNAPSHOT_CALL_CONF) { this.marshaledObj.evt.cstaConfirmation.snapshotCall = (Csta.CSTASnapshotCallConfEvent_t)Aux.ByteArrayToStructure <Csta.CSTASnapshotCallConfEvent_t>(this.marshaledObj.evt.cstaConfirmation.heap); int infoCount = this.marshaledObj.evt.cstaConfirmation.snapshotCall.snapshotData.count; IntPtr pInfo = this.marshaledObj.evt.cstaConfirmation.snapshotCall.snapshotData.pInfo; Csta.CSTASnapshotCallResponseInfo_t[] infoArray = new CSTASnapshotCallResponseInfo_t[infoCount]; int infoSize = Marshal.SizeOf(new CSTASnapshotCallResponseInfo_t()); for (int i = 0; i < infoCount; i++) { infoArray[i] = (CSTASnapshotCallResponseInfo_t)Marshal.PtrToStructure(new IntPtr(pInfo.ToInt32() + infoSize * i), typeof(CSTASnapshotCallResponseInfo_t)); } this.marshaledObj.auxData.Add("snapCallInfo", infoArray); } // Marshal SnapShotDevice Event if (this.marshaledObj.evt.eventHeader.eventClass.eventClass == Csta.CSTACONFIRMATION && this.marshaledObj.evt.eventHeader.eventType.eventType == Csta.CSTA_SNAPSHOT_DEVICE_CONF) { this.marshaledObj.evt.cstaConfirmation.snapshotDevice = (CSTASnapshotDeviceConfEvent_t)Aux.ByteArrayToStructure <CSTASnapshotDeviceConfEvent_t>(this.marshaledObj.evt.cstaConfirmation.heap); int infoCount = this.marshaledObj.evt.cstaConfirmation.snapshotDevice.snapshotData.count; IntPtr pInfo = this.marshaledObj.evt.cstaConfirmation.snapshotDevice.snapshotData.pInfo; Csta.CSTASnapshotDeviceResponseInfo_t[] infoArray = new CSTASnapshotDeviceResponseInfo_t[infoCount]; int infoSize = Marshal.SizeOf(new CSTASnapshotDeviceResponseInfo_t()); for (int i = 0; i < infoCount; i++) { infoArray[i] = (CSTASnapshotDeviceResponseInfo_t)Marshal.PtrToStructure(new IntPtr(pInfo.ToInt32() + infoSize * i), typeof(CSTASnapshotDeviceResponseInfo_t)); int stateCount = infoArray[i].localCallState.count; IntPtr pState = infoArray[i].localCallState.pState; LocalConnectionState_t[] stateArray = new LocalConnectionState_t[stateCount]; for (int j = 0; j < stateCount; j++) { stateArray[j] = (LocalConnectionState_t)Marshal.ReadInt32(pState, (sizeof(int) * j)); } this.marshaledObj.auxData.Add("snapDeviceState" + i, stateArray); } this.marshaledObj.auxData.Add("snapDeviceInfo", infoArray); } return(this.marshaledObj); }
private CSTASnapshotCallData_t ReadSnapshotCallData(IStructReader reader) { try { logger.Info("CSTASnapshotCallConfParser.ReadSnapshotCallData: read count from stream..."); uint count = reader.ReadUInt32(); logger.Info("CSTASnapshotCallConfParser.ReadSnapshotCallData: count={0}", count); logger.Info("CSTASnapshotCallConfParser.ReadSnapshotCallData: advance the base stream 4 positions..."); reader.BaseStream.Position = 20; List <CSTASnapshotCallResponseInfo_t> infoList = new List <CSTASnapshotCallResponseInfo_t>(); for (int i = 0; i < count; i++) { object result; logger.Info("CSTASnapshotCallConfParser.ReadSnapshotCallData: read snapshot call info from the stream..."); if (reader.TryReadStruct(typeof(CSTASnapshotCallResponseInfo_t), out result)) { logger.Info("CSTASnapshotCallConfParser.ReadSnapshotCallData: successfully read snapshot call info from the stream!"); CSTASnapshotCallResponseInfo_t info = (CSTASnapshotCallResponseInfo_t)result; logger.Info("CSTASnapshotCallConfParser.ReadSnapshotCallData: deviceOnCall.deviceID.device={0};deviceOnCall.deviceIDType={1};deviceOnCall.deviceIDStatus={2};callIdentifier.callID={3};callIdentifier.deviceID.device={4};callIdentifier.devIDType={5};localConnectionState={6};", info.deviceOnCall.deviceID.device, info.deviceOnCall.deviceIDType, info.deviceOnCall.deviceIDStatus, info.callIdentifier.callID, info.callIdentifier.deviceID.device, info.callIdentifier.devIDType, info.localConnectionState); infoList.Add(info); } } return(new CSTASnapshotCallData_t() { count = count, info = infoList.ToArray() }); } catch (Exception err) { logger.Error(string.Format("Error in CSTASnapshotCallConfParser.ReadSnapshotCallData: {0}", err)); } return(new CSTASnapshotCallData_t() { count = 0, info = new CSTASnapshotCallResponseInfo_t[] { } }); }
public object MarshalNativeToManaged(System.IntPtr pNativeData) { Marshal.PtrToStructure(pNativeData, this.marshaledObj.evt); if (this.marshaledObj.evt.eventHeader.eventClass.eventClass == Csta.CSTACONFIRMATION) { this.marshaledObj.evt.cstaConfirmation = (CSTAConfirmationEvent)Aux.ByteArrayToStructure<CSTAConfirmationEvent>(this.marshaledObj.evt.heap); } // Marshal SnapShotCall Event if (this.marshaledObj.evt.eventHeader.eventClass.eventClass == Csta.CSTACONFIRMATION && this.marshaledObj.evt.eventHeader.eventType.eventType == Csta.CSTA_SNAPSHOT_CALL_CONF) { this.marshaledObj.evt.cstaConfirmation.snapshotCall = (Csta.CSTASnapshotCallConfEvent_t)Aux.ByteArrayToStructure<Csta.CSTASnapshotCallConfEvent_t>(this.marshaledObj.evt.cstaConfirmation.heap); int infoCount = this.marshaledObj.evt.cstaConfirmation.snapshotCall.snapshotData.count; IntPtr pInfo = this.marshaledObj.evt.cstaConfirmation.snapshotCall.snapshotData.pInfo; Csta.CSTASnapshotCallResponseInfo_t[] infoArray = new CSTASnapshotCallResponseInfo_t[infoCount]; int infoSize = Marshal.SizeOf(new CSTASnapshotCallResponseInfo_t()); for (int i = 0; i < infoCount; i++) { infoArray[i] = (CSTASnapshotCallResponseInfo_t)Marshal.PtrToStructure(new IntPtr(pInfo.ToInt32() + infoSize * i), typeof(CSTASnapshotCallResponseInfo_t)); } this.marshaledObj.auxData.Add("snapCallInfo", infoArray); } // Marshal SnapShotDevice Event if (this.marshaledObj.evt.eventHeader.eventClass.eventClass == Csta.CSTACONFIRMATION && this.marshaledObj.evt.eventHeader.eventType.eventType == Csta.CSTA_SNAPSHOT_DEVICE_CONF) { this.marshaledObj.evt.cstaConfirmation.snapshotDevice = (CSTASnapshotDeviceConfEvent_t)Aux.ByteArrayToStructure<CSTASnapshotDeviceConfEvent_t>(this.marshaledObj.evt.cstaConfirmation.heap); int infoCount = this.marshaledObj.evt.cstaConfirmation.snapshotDevice.snapshotData.count; IntPtr pInfo = this.marshaledObj.evt.cstaConfirmation.snapshotDevice.snapshotData.pInfo; Csta.CSTASnapshotDeviceResponseInfo_t[] infoArray = new CSTASnapshotDeviceResponseInfo_t[infoCount]; int infoSize = Marshal.SizeOf(new CSTASnapshotDeviceResponseInfo_t()); for (int i = 0; i < infoCount; i++) { infoArray[i] = (CSTASnapshotDeviceResponseInfo_t)Marshal.PtrToStructure(new IntPtr(pInfo.ToInt32() + infoSize * i), typeof(CSTASnapshotDeviceResponseInfo_t)); int stateCount = infoArray[i].localCallState.count; IntPtr pState = infoArray[i].localCallState.pState; LocalConnectionState_t[] stateArray = new LocalConnectionState_t[stateCount]; for (int j = 0; j < stateCount; j++) { stateArray[j] = (LocalConnectionState_t)Marshal.ReadInt32(pState, (sizeof(int) * j)); } this.marshaledObj.auxData.Add("snapDeviceState" + i, stateArray); } this.marshaledObj.auxData.Add("snapDeviceInfo", infoArray); } return this.marshaledObj; }