2 * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Runtime.InteropServices;
19 using System.Collections.Generic;
24 [StructLayout(LayoutKind.Sequential)]
25 internal struct SimImsiInfoStruct
27 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)]
29 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)]
31 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 11)]
35 [StructLayout(LayoutKind.Sequential)]
36 internal struct SimEccInfoStruct
38 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 31)]
40 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 7)]
41 internal string Number;
42 internal SimEccEmergencyServiceType Type;
45 [StructLayout(LayoutKind.Sequential)]
46 internal struct SimEccInfoListStruct
49 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 15, ArraySubType = UnmanagedType.LPStruct)]
50 internal SimEccInfoStruct[] ListInfo;
53 [StructLayout(LayoutKind.Explicit)]
54 internal struct CfDataStruct
57 internal SimCfisStruct Cfis;
59 internal SimCphsCfStruct CphsCf;
62 [StructLayout(LayoutKind.Sequential)]
63 internal struct SimCallForwardRequestStruct
66 internal CfDataStruct CfData;
69 [StructLayout(LayoutKind.Sequential)]
70 internal struct SimCfisStruct
72 internal int RecIndex;
74 internal byte CfuStatus;
75 internal SimTypeOfNumber Ton;
76 internal SimNumberPlanIdentity Npi;
77 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 21)]
78 internal string CfuNum;
83 [StructLayout(LayoutKind.Sequential)]
84 internal struct SimCfisListStruct
86 internal int ProfileCount;
87 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2, ArraySubType = UnmanagedType.LPStruct)]
88 internal SimCfisStruct[] CfisList;
91 [StructLayout(LayoutKind.Sequential)]
92 internal struct SimCphsCfStruct
100 [StructLayout(LayoutKind.Sequential)]
101 internal struct SimCallForwardResponseStruct
104 internal SimCfisListStruct CfList;
105 internal SimCphsCfStruct CphsCf;
108 [StructLayout(LayoutKind.Explicit)]
109 internal struct MwData
112 internal SimMwisStruct Mwis;
114 internal SimCphsMwStruct CphsMw;
117 [StructLayout(LayoutKind.Sequential)]
118 internal struct SimMessageWaitingRequestStruct
124 [StructLayout(LayoutKind.Sequential)]
125 internal struct SimMwisStruct
127 internal int RecIndex;
128 internal byte IndicatorStatus;
129 internal int VoiceCount;
130 internal int FaxCount;
131 internal int EmailCount;
132 internal int OtherCount;
133 internal int VideoCount;
136 [StructLayout(LayoutKind.Sequential)]
137 internal struct SimMwisListStruct
139 internal int ProfileCount;
140 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2, ArraySubType = UnmanagedType.LPStruct)]
141 internal SimMwisStruct[] MwList;
144 [StructLayout(LayoutKind.Sequential)]
145 internal struct SimCphsMwStruct
153 [StructLayout(LayoutKind.Sequential)]
154 internal struct SimMessageWaitingResponseStruct
157 internal SimMwisListStruct MwList;
158 internal SimCphsMwStruct CphsMw;
161 [StructLayout(LayoutKind.Sequential)]
162 internal struct SimMailboxNumberStruct
165 internal int RecIndex;
166 internal int ProfileNum;
167 internal SimMailboxType MbType;
168 internal int AlphaMaxLen;
169 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 31)]
170 internal string AlphaId;
171 internal SimTypeOfNumber Ton;
172 internal SimNumberPlanIdentity Npi;
173 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 21)]
174 internal string Number;
176 internal byte Ext1Id;
179 [StructLayout(LayoutKind.Sequential)]
180 internal struct SimMailboxListStruct
183 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10, ArraySubType = UnmanagedType.LPStruct)]
184 internal SimMailboxNumberStruct[] List;
187 [StructLayout(LayoutKind.Sequential)]
188 internal struct SimAuthenticationDataStruct
190 internal SimAuthenticationType AuthType;
191 internal int RandLength;
192 internal int AutnLength;
193 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
194 internal string RandData;
195 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
196 internal string AutnData;
199 [StructLayout(LayoutKind.Sequential)]
200 internal struct SimAuthenticationResponseStruct
202 internal SimAuthenticationType AuthType;
203 internal SimAuthenticationResult AuthResult;
204 internal int RespLength;
205 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
206 internal string RespData;
207 internal int AuthKeyLength;
208 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
209 internal string AuthKey;
210 internal int CipherLength;
211 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
212 internal string CipherData;
213 internal int IntegrityLength;
214 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
215 internal string IntegrityData;
218 [StructLayout(LayoutKind.Sequential)]
219 internal struct SimPinDataStruct
221 internal SimPinType Type;
222 [MarshalAs(UnmanagedType.LPStr)]
224 internal uint PinLength;
227 [StructLayout(LayoutKind.Sequential)]
228 internal struct SimFacilityStruct
230 internal SimLockType LockType;
231 [MarshalAs(UnmanagedType.LPStr)]
232 internal string Password;
233 internal int PasswordLength;
236 [StructLayout(LayoutKind.Sequential)]
237 internal struct SimFacilityResultStruct
239 internal SimLockType Type;
240 internal int RetryCount;
243 [StructLayout(LayoutKind.Sequential)]
244 internal struct SimFacilityInfoStruct
246 internal SimLockType Type;
247 internal SimFacilityStatus Status;
250 [StructLayout(LayoutKind.Sequential)]
251 internal struct SimApduStruct
253 internal ushort ApduLen;
254 [MarshalAs(UnmanagedType.LPStr)]
255 internal string Apdu;
258 [StructLayout(LayoutKind.Sequential)]
259 internal struct SimApduResponseStruct
261 internal ushort RespLen;
262 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5120)]
263 internal byte[] ApduResp;
266 [StructLayout(LayoutKind.Sequential)]
267 internal struct SimIccIdInfoStruct
269 internal int IccLength;
270 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
271 internal string IccNumber;
274 [StructLayout(LayoutKind.Sequential)]
275 internal struct SimCphsServiceTableStruct
277 internal int CustomerServiceProfile;
278 internal int ServiceStringTable;
279 internal int MailboxNumbers;
280 internal int OperatorNameShortForm;
281 internal int InformationNumbers;
284 [StructLayout(LayoutKind.Sequential)]
285 internal struct SimCphsInfoStruct
287 internal SimCphsPhaseType CphsPhase;
288 internal SimCphsServiceTableStruct CphsServiceTable;
291 [StructLayout(LayoutKind.Explicit)]
292 internal struct CstServiceStrct
295 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 47)]
296 internal string CdmaService;
298 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 41)]
299 internal string CsimService;
302 [StructLayout(LayoutKind.Sequential)]
303 internal struct SimCstStrct
305 internal SimCdmaServiceTable CdmaSvcTable;
306 internal CstServiceStrct Cst;
309 [StructLayout(LayoutKind.Explicit)]
310 internal struct ServiceTable
313 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 56)]
314 internal string SimSstService;
316 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
317 internal string SimUstService;
319 internal SimCstStrct Cst;
322 [StructLayout(LayoutKind.Sequential)]
323 internal struct SimServiceTableStruct
325 internal SimCardType SimType;
326 internal ServiceTable Table;
329 [StructLayout(LayoutKind.Sequential)]
330 internal struct SimSubscriberInfoStruct
332 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 27)]
333 internal string Number;
334 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 31)]
335 internal string Name;
338 [StructLayout(LayoutKind.Sequential)]
339 internal struct SimMsisdnListStruct
342 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 3, ArraySubType = UnmanagedType.LPStruct)]
343 internal SimSubscriberInfoStruct[] List;
346 [StructLayout(LayoutKind.Sequential)]
347 internal struct SimOplmnwactStruct
349 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 7)]
350 internal string Plmn;
355 [StructLayout(LayoutKind.Sequential)]
356 internal struct SimOplmnwactListStruct
359 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 100, ArraySubType = UnmanagedType.LPStruct)]
360 internal SimOplmnwactStruct[] List;
363 [StructLayout(LayoutKind.Sequential)]
364 internal struct SimSpnStruct
366 internal byte DisplayCondition;
367 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 41)]
371 [StructLayout(LayoutKind.Sequential)]
372 internal struct SimCphsNetNameStruct
374 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 41)]
375 internal string FullName;
376 [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 11)]
377 internal string ShortName;
380 [StructLayout(LayoutKind.Sequential)]
381 internal struct SimPinResultStruct
383 internal SimPinType Type;
384 internal int RetryCount;
387 [StructLayout(LayoutKind.Sequential)]
388 internal struct SimLockInfoStruct
390 internal SimLockType Type;
391 internal SimLockStatus Status;
392 internal int RetryCount;
395 [StructLayout(LayoutKind.Sequential)]
396 internal struct SimAtrResponseStruct
398 internal ushort AtrRespLen;
399 [MarshalAs(UnmanagedType.ByValArray, SizeConst = 5120)]
400 internal byte[] AtrResp;
403 [StructLayout(LayoutKind.Sequential)]
404 internal struct SimImpuListStruct
407 internal IntPtr List;
410 [StructLayout(LayoutKind.Sequential)]
411 internal struct SimPcscfStruct
413 internal SimPcscfType Type;
414 [MarshalAs(UnmanagedType.LPStr)]
415 internal string Pcscf;
418 [StructLayout(LayoutKind.Sequential)]
419 internal struct SimPcscfListStruct
422 internal IntPtr List;
425 internal static class SimStructConversions
427 internal static SimImsiInfo ConvertSimImsiInfoStruct(SimImsiInfoStruct imsiStruct)
429 SimImsiInfo imsi = new SimImsiInfo();
430 imsi.CountryCode = imsiStruct.Mcc;
431 imsi.NetworkCode = imsiStruct.Mnc;
432 imsi.StationId = imsiStruct.Msin;
436 internal static SimEccInfo ConvertSimEccInfoStruct(SimEccInfoStruct eccStruct)
438 SimEccInfo ecc = new SimEccInfo();
439 ecc.NameInfo = eccStruct.Name;
440 ecc.NumberInfo = eccStruct.Number;
441 ecc.TypeInfo = eccStruct.Type;
445 internal static SimEccInfoList ConvertSimEccInfoListStruct(SimEccInfoListStruct listStruct)
447 SimEccInfoList eccList = new SimEccInfoList();
448 eccList.EccCount = listStruct.Count;
449 List<SimEccInfo> eccInfoList = new List<SimEccInfo>();
450 foreach (SimEccInfoStruct info in listStruct.ListInfo)
452 eccInfoList.Add(ConvertSimEccInfoStruct(info));
455 eccList.List = eccInfoList;
459 internal static SimIccIdInfo ConvertSimIccIdInfoStruct(SimIccIdInfoStruct iccStruct)
461 SimIccIdInfo iccId = new SimIccIdInfo();
462 iccId.Length = iccStruct.IccLength;
463 iccId.Number = iccStruct.IccNumber;
467 internal static SimCfis ConvertSimCfisStruct(SimCfisStruct cfisStruct)
469 SimCfis cfis = new SimCfis();
470 cfis.RecIndex = cfisStruct.RecIndex;
471 cfis.MspNum = cfisStruct.MspNum;
472 cfis.CfuStatus = cfisStruct.CfuStatus;
473 cfis.Ton = cfisStruct.Ton;
474 cfis.Npi = cfisStruct.Npi;
475 cfis.CfuNum = cfisStruct.CfuNum;
476 cfis.Cc2Id = cfisStruct.Cc2Id;
477 cfis.Ext7Id = cfisStruct.Ext7Id;
481 internal static SimCfisList ConvertSimCfisListStruct(SimCfisListStruct listStruct)
483 SimCfisList cfisList = new SimCfisList();
484 cfisList.Count = listStruct.ProfileCount;
485 List<SimCfis> cfis = new List<SimCfis>();
486 foreach (SimCfisStruct cfStruct in listStruct.CfisList)
488 cfis.Add(ConvertSimCfisStruct(cfStruct));
491 cfisList.List = cfis;
495 internal static SimCphsCf ConvertSimCphsCfStruct(SimCphsCfStruct cphsCfStruct)
497 SimCphsCf cphs = new SimCphsCf();
498 cphs.Line1 = cphsCfStruct.Line1;
499 cphs.Line2 = cphsCfStruct.Line2;
500 cphs.Fax = cphsCfStruct.Fax;
501 cphs.Data = cphsCfStruct.Data;
505 internal static SimCallForwardResponse ConvertSimCallForwardResponseStruct(SimCallForwardResponseStruct respStruct)
507 SimCallForwardResponse resp = new SimCallForwardResponse();
508 if (respStruct.IsCphs == 1)
510 resp.IsCphsCf = true;
513 else if (respStruct.IsCphs == 0)
515 resp.IsCphsCf = false;
518 resp.List = ConvertSimCfisListStruct(respStruct.CfList);
519 resp.CphsCfInfo = ConvertSimCphsCfStruct(respStruct.CphsCf);
523 internal static SimMwis ConvertSimMwisStruct(SimMwisStruct mwisStruct)
525 SimMwis mwis = new SimMwis();
526 mwis.RecIndex = mwisStruct.RecIndex;
527 mwis.IndicatorStatus = mwisStruct.IndicatorStatus;
528 mwis.VoiceCount = mwisStruct.VoiceCount;
529 mwis.FaxCount = mwisStruct.FaxCount;
530 mwis.EmailCount = mwisStruct.EmailCount;
531 mwis.OtherCount = mwisStruct.OtherCount;
532 mwis.VideoCount = mwisStruct.VideoCount;
536 internal static SimMwisList ConvertSimMwisListStruct(SimMwisListStruct mwStruct)
538 SimMwisList mwList = new SimMwisList();
539 mwList.Count = mwStruct.ProfileCount;
540 List<SimMwis> mwisList = new List<SimMwis>();
541 foreach (SimMwisStruct mwisStruct in mwStruct.MwList)
543 mwisList.Add(ConvertSimMwisStruct(mwisStruct));
546 mwList.List = mwisList;
550 internal static SimCphsMw ConvertSimCphsMwStruct(SimCphsMwStruct cphsStruct)
552 SimCphsMw cphsMw = new SimCphsMw();
553 if (cphsStruct.Voice1 == 1)
555 cphsMw.IsVoice1 = true;
560 cphsMw.IsVoice1 = false;
563 if (cphsStruct.Voice2 == 1)
565 cphsMw.IsVoice2 = true;
570 cphsMw.IsVoice2 = false;
573 if (cphsStruct.Fax == 1)
580 cphsMw.IsFax = false;
583 if (cphsStruct.Data == 1)
585 cphsMw.IsData = true;
590 cphsMw.IsData = false;
596 internal static SimMessageWaitingResponse ConvertSimMessageWaitingRespStruct(SimMessageWaitingResponseStruct responseStruct)
598 SimMessageWaitingResponse waitingResp = new SimMessageWaitingResponse();
599 if (responseStruct.IsCphs == 1)
601 waitingResp.IsCphsMw = true;
606 waitingResp.IsCphsMw = false;
609 waitingResp.List = ConvertSimMwisListStruct(responseStruct.MwList);
610 waitingResp.CphsMwInfo = ConvertSimCphsMwStruct(responseStruct.CphsMw);
614 internal static SimMailboxNumber ConvertSimMailboxNumberStruct(SimMailboxNumberStruct mbStruct)
616 SimMailboxNumber mbNumber = new SimMailboxNumber();
617 if (mbStruct.IsCphs == 1)
619 mbNumber.IsCphs = true;
622 else if (mbStruct.IsCphs == 0)
624 mbNumber.IsCphs = false;
627 mbNumber.RecIndex = mbStruct.RecIndex;
628 mbNumber.ProfileNumber = mbStruct.ProfileNum;
629 mbNumber.MbType = mbStruct.MbType;
630 mbNumber.AlphaMaxLength = mbStruct.AlphaMaxLen;
631 mbNumber.AlphaId = mbStruct.AlphaId;
632 mbNumber.Ton = mbStruct.Ton;
633 mbNumber.Npi = mbStruct.Npi;
634 mbNumber.Number = mbStruct.Number;
635 mbNumber.CcId = mbStruct.CcId;
636 mbNumber.Ext1Id = mbStruct.Ext1Id;
640 internal static SimMailboxList ConvertSimMailboxListStruct(SimMailboxListStruct mbListStruct)
642 SimMailboxList mbList = new SimMailboxList();
643 mbList.MbCount = mbListStruct.Count;
644 List<SimMailboxNumber> mbNumList = new List<SimMailboxNumber>();
645 foreach (SimMailboxNumberStruct mbStruct in mbListStruct.List)
647 mbNumList.Add(ConvertSimMailboxNumberStruct(mbStruct));
650 mbList.MbList = mbNumList;
654 internal static SimCphsServiceTable ConvertSimCphsServiceTableStruct(SimCphsServiceTableStruct svcStruct)
656 SimCphsServiceTable svcTable = new SimCphsServiceTable();
657 svcTable.CustomerSvcProfile = svcStruct.CustomerServiceProfile;
658 svcTable.SvcStringTable = svcStruct.ServiceStringTable;
659 svcTable.MbNumbers = svcStruct.MailboxNumbers;
660 svcTable.OperatorNameShort = svcStruct.OperatorNameShortForm;
661 svcTable.InformationNum = svcStruct.InformationNumbers;
665 internal static SimCphsInfo ConvertSimCphsInfoStruct(SimCphsInfoStruct cphsStruct)
667 SimCphsInfo cphsInfo = new SimCphsInfo();
668 cphsInfo.Phase = cphsStruct.CphsPhase;
669 cphsInfo.CphsSvcTable = ConvertSimCphsServiceTableStruct(cphsStruct.CphsServiceTable);
673 internal static SimCst ConvertSimCstStruct(SimCstStrct cstStruct)
675 SimCst cst = new SimCst();
676 cst.CdmaSvc = cstStruct.CdmaSvcTable;
677 if (cstStruct.CdmaSvcTable == SimCdmaServiceTable.Cdma)
679 cst.Cdma = Encoding.ASCII.GetBytes(cstStruct.Cst.CdmaService);
682 else if (cstStruct.CdmaSvcTable == SimCdmaServiceTable.Csim)
684 cst.Csim = Encoding.ASCII.GetBytes(cstStruct.Cst.CsimService);
690 internal static SimServiceTable ConvertSimServiceTableStruct(SimServiceTableStruct svcTableStruct)
692 SimServiceTable svcTable = new SimServiceTable();
693 svcTable.Type = svcTableStruct.SimType;
694 if (svcTableStruct.SimType == SimCardType.Gsm)
696 svcTable.Sst = Encoding.ASCII.GetBytes(svcTableStruct.Table.SimSstService);
699 else if (svcTableStruct.SimType == SimCardType.Usim)
701 svcTable.Ust = Encoding.ASCII.GetBytes(svcTableStruct.Table.SimUstService);
704 else if (svcTableStruct.SimType == SimCardType.Ruim)
706 svcTable.Cst = ConvertSimCstStruct(svcTableStruct.Table.Cst);
712 internal static SimSubscriberInfo ConvertSimSubscriberInfoStruct(SimSubscriberInfoStruct infoStruct)
714 SimSubscriberInfo subscriber = new SimSubscriberInfo();
715 subscriber.MsisdnNum = infoStruct.Number;
716 subscriber.MsisdnName = infoStruct.Name;
720 internal static SimMsisdnList ConvertSimMsisdnListStruct(SimMsisdnListStruct msisdnStruct)
722 SimMsisdnList list = new SimMsisdnList();
723 list.MsisdnCount = msisdnStruct.Count;
724 List<SimSubscriberInfo> subsList = new List<SimSubscriberInfo>();
725 foreach (SimSubscriberInfoStruct subsStruct in msisdnStruct.List)
727 subsList.Add(ConvertSimSubscriberInfoStruct(subsStruct));
730 list.SubscriberList = subsList;
734 internal static SimOplmnwact ConvertSimOplmnwactStruct(SimOplmnwactStruct oplmnStruct)
736 SimOplmnwact oplmn = new SimOplmnwact();
737 oplmn.PlmnString = oplmnStruct.Plmn;
738 if (oplmnStruct.IsUmts == 1)
740 oplmn.UmtsFlag = true;
743 else if (oplmnStruct.IsUmts == 0)
745 oplmn.UmtsFlag = false;
748 if (oplmnStruct.IsGsm == 1)
750 oplmn.GsmFlag = true;
753 else if (oplmnStruct.IsGsm == 0)
755 oplmn.GsmFlag = false;
761 internal static SimOplmnwactList ConvertSimOplmnwactListStruct(SimOplmnwactListStruct listStruct)
763 SimOplmnwactList oplmnList = new SimOplmnwactList();
764 oplmnList.OplmnCount = listStruct.Count;
765 List<SimOplmnwact> wactList = new List<SimOplmnwact>();
766 foreach (SimOplmnwactStruct wactStruct in listStruct.List)
768 wactList.Add(ConvertSimOplmnwactStruct(wactStruct));
771 oplmnList.OplmnList = wactList;
775 internal static SimSpn ConvertSimSpnStruct(SimSpnStruct spnStruct)
777 SimSpn spn = new SimSpn();
778 spn.Condition = spnStruct.DisplayCondition;
779 spn.SpName = spnStruct.Spn;
783 internal static SimCphsNetName ConvertSimCphsNetNameStruct(SimCphsNetNameStruct cphsStruct)
785 SimCphsNetName cphsName = new SimCphsNetName();
786 cphsName.Full = cphsStruct.FullName;
787 cphsName.Short = cphsStruct.ShortName;
791 internal static SimAuthenticationResponse ConvertSimAuthenticationResponseStruct(SimAuthenticationResponseStruct respStruct)
793 SimAuthenticationResponse response = new SimAuthenticationResponse();
794 response.Type = respStruct.AuthType;
795 response.Result = respStruct.AuthResult;
796 response.RespLength = respStruct.RespLength;
797 response.RespData = respStruct.RespData;
798 response.AuthKeyLen = respStruct.AuthKeyLength;
799 response.Key = respStruct.AuthKey;
800 response.CipherLen = respStruct.CipherLength;
801 response.Cipher = respStruct.CipherData;
802 response.IntegrityLen = respStruct.IntegrityLength;
803 response.Integrity = respStruct.IntegrityData;
807 internal static SimPinResult ConvertSimPinResultStruct(SimPinResultStruct resultStruct)
809 SimPinResult pinResult = new SimPinResult();
810 pinResult.PinType = resultStruct.Type;
811 pinResult.Retry = resultStruct.RetryCount;
815 internal static SimFacilityResult ConvertSimFacilityResultStruct(SimFacilityResultStruct resultStruct)
817 SimFacilityResult facilityResult = new SimFacilityResult();
818 facilityResult.LockType = resultStruct.Type;
819 facilityResult.Count = resultStruct.RetryCount;
820 return facilityResult;
823 internal static SimFacilityInfo ConvertSimFacilityInfoStruct(SimFacilityInfoStruct infoStruct)
825 SimFacilityInfo facilityInfo = new SimFacilityInfo();
826 facilityInfo.LockType = infoStruct.Type;
827 facilityInfo.FacilityStatus = infoStruct.Status;
831 internal static SimLockInfo ConvertSimLockInfoStruct(SimLockInfoStruct infoStruct)
833 SimLockInfo lockInfo = new SimLockInfo();
834 lockInfo.LockType = infoStruct.Type;
835 lockInfo.LockStatus = infoStruct.Status;
836 lockInfo.Count = infoStruct.RetryCount;
840 internal static SimApduResponse ConvertSimApduResponseStruct(SimApduResponseStruct respStruct)
842 SimApduResponse response = new SimApduResponse();
843 response.ApduLen = respStruct.RespLen;
844 response.ApduResp = respStruct.ApduResp;
848 internal static SimAtrResponse ConvertSimAtrResponseStruct(SimAtrResponseStruct respStruct)
850 SimAtrResponse atrResp = new SimAtrResponse();
851 atrResp.AtrRespLen = respStruct.AtrRespLen;
852 atrResp.AtrResp = respStruct.AtrResp;
856 internal static SimImpuList ConvertSimImpuListStruct(SimImpuListStruct listStruct)
858 SimImpuList impuList = new SimImpuList();
859 impuList.DataCount = listStruct.Count;
860 IntPtr[] ptrList = new IntPtr[listStruct.Count];
861 Marshal.Copy(listStruct.List, ptrList, 0, (int)listStruct.Count);
862 List<string> list = new List<string>();
863 for (int i = 0; i < listStruct.Count; i++)
865 list.Add(Marshal.PtrToStringAnsi(ptrList[i]));
868 impuList.ImpuList = list;
872 internal static SimPcscf ConvertSimPcscfStruct(SimPcscfStruct pcscfStruct)
874 SimPcscf pcscf = new SimPcscf();
875 pcscf.PcscfType = pcscfStruct.Type;
876 pcscf.PcscfData = pcscfStruct.Pcscf;
880 internal static SimPcscfList ConvertSimPcscfListStruct(SimPcscfListStruct listStruct)
882 SimPcscfList pcscfList = new SimPcscfList();
883 pcscfList.DataCount = listStruct.Count;
884 IntPtr[] ptrList = new IntPtr[listStruct.Count];
885 Marshal.Copy(listStruct.List, ptrList, 0, (int)listStruct.Count);
886 List<SimPcscf> list = new List<SimPcscf>();
887 for (int i = 0; i < listStruct.Count; i++)
889 list.Add(ConvertSimPcscfStruct(Marshal.PtrToStructure<SimPcscfStruct>(ptrList[i])));
892 pcscfList.PcscfList = list;
897 internal static class SimClassConversions
899 internal static SimCallForwardRequestStruct ConvertSimCallForwardRequest(SimCallForwardRequest request)
901 SimCallForwardRequestStruct cfStruct = new SimCallForwardRequestStruct();
902 if (request.IsCphs == true)
907 else if (request.IsCphs == false)
912 if (request.IsCphs == true)
914 cfStruct.CfData.CphsCf.Line1 = request.CphsCf.Line1;
915 cfStruct.CfData.CphsCf.Line2 = request.CphsCf.Line2;
916 cfStruct.CfData.CphsCf.Fax = request.CphsCf.Fax;
917 cfStruct.CfData.CphsCf.Data = request.CphsCf.Data;
922 cfStruct.CfData.Cfis.RecIndex = request.Cfis.RecIndex;
923 cfStruct.CfData.Cfis.MspNum = request.Cfis.MspNum;
924 cfStruct.CfData.Cfis.CfuStatus = request.Cfis.CfuStatus;
925 cfStruct.CfData.Cfis.Ton = request.Cfis.Ton;
926 cfStruct.CfData.Cfis.Npi = request.Cfis.Npi;
927 cfStruct.CfData.Cfis.CfuNum = request.Cfis.CfuNum;
928 cfStruct.CfData.Cfis.Cc2Id = request.Cfis.Cc2Id;
929 cfStruct.CfData.Cfis.Ext7Id = request.Cfis.Ext7Id;
935 internal static SimMwisStruct ConvertSimMwis(SimMwis mwis)
937 SimMwisStruct mwisStruct = new SimMwisStruct();
938 mwisStruct.RecIndex = mwis.RecIndex;
939 mwisStruct.IndicatorStatus = mwis.IndicatorStatus;
940 mwisStruct.VoiceCount = mwis.VoiceCount;
941 mwisStruct.FaxCount = mwis.FaxCount;
942 mwisStruct.EmailCount = mwis.EmailCount;
943 mwisStruct.OtherCount = mwis.OtherCount;
944 mwisStruct.VideoCount = mwis.VideoCount;
948 internal static SimCphsMwStruct ConvertSimCphsMw(SimCphsMw cphsMw)
950 SimCphsMwStruct cphsStruct = new SimCphsMwStruct();
951 if (cphsMw.IsVoice1 == true)
953 cphsStruct.Voice1 = 1;
958 cphsStruct.Voice1 = 0;
961 if (cphsMw.IsVoice2 == true)
963 cphsStruct.Voice2 = 1;
968 cphsStruct.Voice2 = 0;
971 if (cphsMw.IsFax == true)
981 if (cphsMw.IsData == true)
994 internal static SimMessageWaitingRequestStruct ConvertSimMessageWaitingRequest(SimMessageWaitingRequest request)
996 SimMessageWaitingRequestStruct requestStruct = new SimMessageWaitingRequestStruct();
997 if (request.IsCphs == true)
999 requestStruct.IsCphs = 1;
1004 requestStruct.IsCphs = 0;
1007 if (request.IsCphs == true)
1009 requestStruct.Mw.CphsMw = ConvertSimCphsMw(request.CphsMw);
1014 requestStruct.Mw.Mwis = ConvertSimMwis(request.Mwis);
1017 return requestStruct;
1020 internal static SimMailboxNumberStruct ConvertSimMailboxNumber(SimMailboxNumber mbNumber)
1022 SimMailboxNumberStruct mbStruct = new SimMailboxNumberStruct();
1023 if (mbNumber.IsCphs)
1025 mbStruct.IsCphs = 1;
1030 mbStruct.IsCphs = 0;
1033 mbStruct.RecIndex = mbNumber.RecIndex;
1034 mbStruct.ProfileNum = mbNumber.ProfileNumber;
1035 mbStruct.MbType = mbNumber.MbType;
1036 mbStruct.AlphaMaxLen = mbNumber.AlphaMaxLength;
1037 mbStruct.AlphaId = mbNumber.AlphaId;
1038 mbStruct.Ton = mbNumber.Ton;
1039 mbStruct.Npi = mbNumber.Npi;
1040 mbStruct.Number = mbNumber.Number;
1041 mbStruct.CcId = mbNumber.CcId;
1042 mbStruct.Ext1Id = mbNumber.Ext1Id;
1046 internal static SimPinDataStruct ConvertSimPinData(SimPinData data)
1048 SimPinDataStruct pinStruct = new SimPinDataStruct();
1049 pinStruct.Type = data.Type;
1050 pinStruct.Pin = data.Pin;
1051 pinStruct.PinLength = data.PinLength;
1055 internal static SimFacilityStruct ConvertSimFacility(SimFacility facility)
1057 SimFacilityStruct facilityStruct = new SimFacilityStruct();
1058 facilityStruct.LockType = facility.LockType;
1059 facilityStruct.Password = facility.Password;
1060 facilityStruct.PasswordLength = facility.PasswordLength;
1061 return facilityStruct;
1064 internal static SimApduStruct ConvertSimApdu(SimApdu apdu)
1066 SimApduStruct apduStruct = new SimApduStruct();
1067 apduStruct.ApduLen = (ushort)apdu.Apdu.Length;
1068 apduStruct.Apdu = Encoding.UTF8.GetString(apdu.Apdu);
1072 internal static SimAuthenticationDataStruct ConvertSimAuthenticationDataStruct(SimAuthenticationData authData)
1074 SimAuthenticationDataStruct authStruct = new SimAuthenticationDataStruct();
1075 authStruct.AuthType = authData.AuthType;
1076 authStruct.RandLength = authData.RandLength;
1077 authStruct.AutnLength = authData.AutnLength;
1078 authStruct.RandData = Encoding.UTF8.GetString(authData.RandData);
1079 authStruct.AutnData = Encoding.UTF8.GetString(authData.AutnData);