Debian Codegraph @

gobi-api/GobiAPI_2013-07-31-1347/Gobi3000Translation/Gobi3000TranslationNAS.cpp

raw
1 /*===========================================================================
2 FILE:
3 Gobi3000TranslationNAS.cpp
4
5 DESCRIPTION:
6 QUALCOMM Translation for Gobi 3000 (NAS Service)
7
8 Copyright (c) 2013, The Linux Foundation. All rights reserved.
9
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions are met:
12 * Redistributions of source code must retain the above copyright
13 notice, this list of conditions and the following disclaimer.
14 * Redistributions in binary form must reproduce the above copyright
15 notice, this list of conditions and the following disclaimer in the
16 documentation and/or other materials provided with the distribution.
17 * Neither the name of The Linux Foundation nor the names of its
18 contributors may be used to endorse or promote products derived from
19 this software without specific prior written permission.
20
21
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 POSSIBILITY OF SUCH DAMAGE.
33 ==========================================================================*/
34
35 //---------------------------------------------------------------------------
36 // Include Files
37 //---------------------------------------------------------------------------
38 #include "Gobi3000Translation.h"
39
40 // Maximum length for a scanned network description
41 const ULONG MAX_SNI_DESCRIPTION_LEN = 255;
42
43 //---------------------------------------------------------------------------
44 // Pragmas (pack structs)
45 //---------------------------------------------------------------------------
46 #pragma pack( push, 1 )
47
48 /*=========================================================================*/
49 // Struct sEVDOCustomSCPConfig
50 // Struct to represent CDMA 1xEV-DO custom SCP config
51 /*=========================================================================*/
52 struct sEVDOCustomSCPConfig
53 {
54 public:
55 BYTE mbActive;
56 ULONG mProtocolMask;
57 ULONG mBroadcastMask;
58 ULONG mApplicationMask;
59 };
60
61 /*=========================================================================*/
62 // Struct sScannedNetworkInfo
63 // Struct to represent scanned network information
64 /*=========================================================================*/
65 struct sScannedNetworkInfo
66 {
67 public:
68 USHORT mMCC;
69 USHORT mMNC;
70 ULONG mInUse;
71 ULONG mRoaming;
72 ULONG mForbidden;
73 ULONG mPreferred;
74 CHAR mDescription[MAX_SNI_DESCRIPTION_LEN];
75 };
76
77 /*=========================================================================*/
78 // Struct sScannedNetworkRATInfo
79 // Struct to represent scanned network RAT information
80 /*=========================================================================*/
81 struct sScannedNetworkRATInfo
82 {
83 public:
84 USHORT mMCC;
85 USHORT mMNC;
86 ULONG mRAT;
87 };
88
89 //---------------------------------------------------------------------------
90 // Pragmas
91 //---------------------------------------------------------------------------
92 #pragma pack( pop )
93
94 /*===========================================================================
95 METHOD:
96 ParseGetANAAAAuthenticationStatus
97
98 DESCRIPTION:
99 This function gets the AN-AAA authentication status
100
101 PARAMETERS:
102 inLen [ I ] - Length of input buffer
103 pIn [ I ] - Input buffer
104 pStatus [ O ] - AN-AAA authentication status
105
106 RETURN VALUE:
107 ULONG - Return code
108 ===========================================================================*/
109 ULONG ParseGetANAAAAuthenticationStatus(
110 ULONG inLen,
111 const BYTE * pIn,
112 ULONG * pStatus )
113 {
114 // Validate arguments
115 if (pIn == 0 || pStatus == 0)
116 {
117 return eGOBI_ERR_INVALID_ARG;
118 }
119
120 // Find the TLV
121 const sNASGetANAAAAuthenticationStatusResponse_Status * pTLVx01;
122 ULONG outLenx01;
123 ULONG rc = GetTLV( inLen, pIn, 0x01, &outLenx01, (const BYTE **)&pTLVx01 );
124 if (rc != eGOBI_ERR_NONE)
125 {
126 return rc;
127 }
128
129 // Is the TLV large enough?
130 if (outLenx01 < sizeof( sNASGetANAAAAuthenticationStatusResponse_Status ))
131 {
132 return eGOBI_ERR_MALFORMED_RSP;
133 }
134
135 *pStatus = pTLVx01->mANAAAAuthenticationStatus;
136
137 return eGOBI_ERR_NONE;
138 }
139
140 /*===========================================================================
141 METHOD:
142 ParseGetSignalStrength
143
144 DESCRIPTION:
145 This function gets the current signal strength (in dBm) as measured by
146 the device, the signal strength returned will be one of the currently
147 available technologies with preference CDMA 1xEV-DO, CDMA, AMPS,
148 WCDMA, GSM
149
150 PARAMETERS:
151 inLen [ I ] - Length of input buffer
152 pIn [ I ] - Input buffer
153 pSignalStrength [ O ] - Received signal strength (dBm)
154 pRadioInterface [ O ] - Radio interface technology
155
156 RETURN VALUE:
157 ULONG - Return code
158 ===========================================================================*/
159 ULONG ParseGetSignalStrength(
160 ULONG inLen,
161 const BYTE * pIn,
162 INT8 * pSignalStrength,
163 ULONG * pRadioInterface )
164 {
165 // Validate arguments
166 if (pSignalStrength == 0 || pRadioInterface == 0)
167 {
168 return eGOBI_ERR_INVALID_ARG;
169 }
170
171 ULONG sigSz = 12;
172 INT8 sigs[12];
173 ULONG radios[12];
174 ULONG qcErr = ParseGetSignalStrengths( inLen,
175 pIn,
176 &sigSz,
177 &sigs[0],
178 &radios[0] );
179 if (qcErr != eGOBI_ERR_NONE)
180 {
181 return qcErr;
182 }
183
184 std::map <ULONG, INT8> sigMap;
185 for (ULONG s = 0; s < sigSz; s++)
186 {
187 sigMap[radios[s]] = sigs[s];
188 }
189
190 std::map <ULONG, INT8>::const_iterator pIter;
191
192 // HDR?
193 pIter = sigMap.find( 2 );
194 if (pIter != sigMap.end())
195 {
196 *pSignalStrength = pIter->second;
197 *pRadioInterface = pIter->first;
198
199 return eGOBI_ERR_NONE;
200 }
201
202 // CDMA?
203 pIter = sigMap.find( 1 );
204 if (pIter != sigMap.end())
205 {
206 *pSignalStrength = pIter->second;
207 *pRadioInterface = pIter->first;
208
209 return eGOBI_ERR_NONE;
210 }
211
212 // AMPS?
213 pIter = sigMap.find( 3 );
214 if (pIter != sigMap.end())
215 {
216 *pSignalStrength = pIter->second;
217 *pRadioInterface = pIter->first;
218
219 return eGOBI_ERR_NONE;
220 }
221
222 // WCDMA?
223 pIter = sigMap.find( 5 );
224 if (pIter != sigMap.end())
225 {
226 *pSignalStrength = pIter->second;
227 *pRadioInterface = pIter->first;
228
229 return eGOBI_ERR_NONE;
230 }
231
232 // GSM?
233 pIter = sigMap.find( 4 );
234 if (pIter != sigMap.end())
235 {
236 *pSignalStrength = pIter->second;
237 *pRadioInterface = pIter->first;
238
239 return eGOBI_ERR_NONE;
240 }
241
242 // Error values
243 *pSignalStrength = -128;
244 *pRadioInterface = 0;
245
246 return eGOBI_ERR_NO_SIGNAL;
247 }
248
249 /*===========================================================================
250 METHOD:
251 ParseGetSignalStrengths
252
253 DESCRIPTION:
254 This function gets the current available signal strengths (in dBm)
255 as measured by the device
256
257 PARAMETERS:
258 inLen [ I ] - Length of input buffer
259 pIn [ I ] - Input buffer
260 pArraySizes [I/O] - Upon input the maximum number of elements
261 that each array can contain can contain.
262 Upon successful output the actual number
263 of elements in each array
264 pSignalStrengths [ O ] - Received signal strength array (dBm)
265 pRadioInterfaces [ O ] - Radio interface technology array
266
267 RETURN VALUE:
268 ULONG - Return code
269 ===========================================================================*/
270 ULONG ParseGetSignalStrengths(
271 ULONG inLen,
272 const BYTE * pIn,
273 ULONG * pArraySizes,
274 INT8 * pSignalStrengths,
275 ULONG * pRadioInterfaces )
276 {
277 // Validate arguments
278 if (pIn == 0
279 || pArraySizes == 0
280 || *pArraySizes == 0
281 || pSignalStrengths == 0
282 || pRadioInterfaces == 0)
283 {
284 return eGOBI_ERR_INVALID_ARG;
285 }
286
287 ULONG maxSignals = (ULONG)*pArraySizes;
288
289 // Assume failure
290 *pArraySizes = 0;
291
292 // Find the first signal strength value
293 const sNASGetSignalStrengthResponse_SignalStrength * pTLVx01;
294 ULONG outLenx01;
295 ULONG rc = GetTLV( inLen, pIn, 0x01, &outLenx01, (const BYTE **)&pTLVx01 );
296 if (rc != eGOBI_ERR_NONE)
297 {
298 return rc;
299 }
300
301 // Is the TLV large enough?
302 if (outLenx01 < sizeof( sNASGetSignalStrengthResponse_SignalStrength ))
303 {
304 return eGOBI_ERR_MALFORMED_RSP;
305 }
306
307 // Weed out bogus values
308 std::map <ULONG, INT8> sigMap;
309
310 INT8 sigVal = pTLVx01->mSignalStrengthdBm;
311 ULONG radioVal = pTLVx01->mRadioInterface;
312 if (sigVal <= -30 && sigVal > -125 && radioVal != 0)
313 {
314 sigMap[radioVal] = sigVal;
315 }
316
317 // Handle list, if present
318 const sNASGetSignalStrengthResponse_SignalStrengthList * pTLVx10;
319 ULONG outLenx10;
320 rc = GetTLV( inLen, pIn, 0x10, &outLenx10, (const BYTE **)&pTLVx10 );
321 if (rc == eGOBI_ERR_NONE)
322 {
323 if (outLenx10 < sizeof( sNASGetSignalStrengthResponse_SignalStrengthList ))
324 {
325 return eGOBI_ERR_MALFORMED_RSP;
326 }
327
328 ULONG auxSigs = pTLVx10->mNumberOfInfoInstances;
329 if (auxSigs > maxSignals)
330 {
331 auxSigs = maxSignals;
332 }
333
334 const sNASGetSignalStrengthResponse_SignalStrengthList::sInfo * pInfo;
335
336 // Verify there is room for the array in the TLV
337 if (outLenx10 < sizeof( sNASGetSignalStrengthResponse_SignalStrengthList )
338 + sizeof( sNASGetSignalStrengthResponse_SignalStrengthList::sInfo )
339 * auxSigs)
340 {
341 return eGOBI_ERR_MALFORMED_RSP;
342 }
343
344 // Align to the first array element
345 pInfo = (const sNASGetSignalStrengthResponse_SignalStrengthList::sInfo *)
346 ((const BYTE *)pTLVx10
347 + sizeof( sNASGetSignalStrengthResponse_SignalStrengthList ));
348
349 for (ULONG s = 0; s < auxSigs; s++)
350 {
351 sigVal = pInfo->mSignalStrengthdBm;
352 radioVal = pInfo->mRadioInterface;
353 if (sigVal <= -30 && sigVal > -125 && radioVal != 0)
354 {
355 sigMap[radioVal] = sigVal;
356 }
357
358 // Move pInfo forward one element
359 pInfo++;
360 }
361 }
362
363 ULONG sigCount = 0;
364 std::map <ULONG, INT8>::const_iterator pIter;
365 for (pIter = sigMap.begin(); pIter != sigMap.end(); pIter++, sigCount++)
366 {
367 if (sigCount < maxSignals)
368 {
369 pSignalStrengths[sigCount] = pIter->second;
370 pRadioInterfaces[sigCount] = pIter->first;
371 *pArraySizes = sigCount + 1;
372 }
373 }
374
375 // No valid signals?
376 if (sigCount == 0)
377 {
378 return eGOBI_ERR_NO_SIGNAL;
379 }
380
381 return eGOBI_ERR_NONE;
382 }
383
384 /*===========================================================================
385 METHOD:
386 ParseGetRFInfo
387
388 DESCRIPTION:
389 This function gets the current RF information
390
391 PARAMETERS:
392 inLen [ I ] - Length of input buffer
393 pIn [ I ] - Input buffer
394 pInstanceSize [I/O] - Upon input the maximum number of elements that the
395 RF info instance array can contain. Upon success
396 the actual number of elements in the RF info
397 instance array
398 pInstances [ O ] - The RF info instance array
399
400 RETURN VALUE:
401 ULONG - Return code
402 ===========================================================================*/
403 ULONG ParseGetRFInfo(
404 ULONG inLen,
405 const BYTE * pIn,
406 BYTE * pInstanceSize,
407 BYTE * pInstances )
408 {
409 // Validate arguments
410 if (pIn == 0
411 || pInstanceSize == 0
412 || *pInstanceSize == 0
413 || pInstances == 0)
414 {
415 return eGOBI_ERR_INVALID_ARG;
416 }
417
418 // Assume failure
419 BYTE maxInstances = *pInstanceSize;
420 *pInstanceSize = 0;
421
422 // Find the TLV
423 const sNASGetRFInfoResponse_RFInfo * pTLVx01;
424 ULONG outLenx01;
425 ULONG rc = GetTLV( inLen, pIn, 0x01, &outLenx01, (const BYTE **)&pTLVx01 );
426 if (rc != eGOBI_ERR_NONE)
427 {
428 return rc;
429 }
430
431 // Is the TLV large enough?
432 if (outLenx01 < sizeof( sNASGetRFInfoResponse_RFInfo ))
433 {
434 return eGOBI_ERR_MALFORMED_RSP;
435 }
436
437 BYTE ifaceCount = pTLVx01->mNumberOfInstances;
438 if (ifaceCount > maxInstances)
439 {
440 ifaceCount = maxInstances;
441 }
442
443 const sNASGetRFInfoResponse_RFInfo::sInstance * pInstance;
444
445 // Verify there is room for the array in the TLV
446 if (outLenx01 < sizeof( sNASGetRFInfoResponse_RFInfo )
447 + sizeof( sNASGetRFInfoResponse_RFInfo::sInstance )
448 * ifaceCount)
449 {
450 return eGOBI_ERR_MALFORMED_RSP;
451 }
452
453 // Align to the first array element
454 pInstance = (const sNASGetRFInfoResponse_RFInfo::sInstance *)
455 ((const BYTE *)pTLVx01
456 + sizeof( sNASGetRFInfoResponse_RFInfo ));
457
458 ULONG * pOutput = (ULONG *)pInstances;
459 for (BYTE i = 0; i < ifaceCount; i++)
460 {
461 *pOutput++ = pInstance->mRadioInterface;
462 *pOutput++ = pInstance->mActiveBandClass;
463 *pOutput++ = pInstance->mActiveChannel;
464
465 // Move pInstance forward one element
466 pInstance++;
467 }
468
469 *pInstanceSize = ifaceCount;
470
471 return eGOBI_ERR_NONE;
472 }
473
474 /*===========================================================================
475 METHOD:
476 ParsePerformNetworkScan
477
478 DESCRIPTION:
479 This function performs a scan for available networks
480
481 PARAMETERS:
482 inLen [ I ] - Length of input buffer
483 pIn [ I ] - Input buffer
484 pInstanceSize [I/O] - Upon input the maximum number of elements that the
485 network info instance array can contain. Upon
486 success the actual number of elements in the
487 network info instance array
488 pInstances [ O ] - The network info instance array
489
490 RETURN VALUE:
491 ULONG - Return code
492 ===========================================================================*/
493 ULONG ParsePerformNetworkScan(
494 ULONG inLen,
495 const BYTE * pIn,
496 BYTE * pInstanceSize,
497 BYTE * pInstances )
498 {
499 // Validate arguments
500 if (pIn == 0
501 || pInstanceSize == 0
502 || *pInstanceSize == 0
503 || pInstances == 0)
504 {
505 return eGOBI_ERR_INVALID_ARG;
506 }
507
508 BYTE maxInstances = *pInstanceSize;
509
510 // Assume failure
511 *pInstanceSize = 0;
512
513 // Find the TLV
514 const sNASPerformNetworkScanResponse_NetworkInfo * pTLVx10;
515 ULONG outLenx10;
516 ULONG rc = GetTLV( inLen, pIn, 0x10, &outLenx10, (const BYTE **)&pTLVx10 );
517 if (rc != eGOBI_ERR_NONE)
518 {
519 return rc;
520 }
521
522 // Is the TLV large enough?
523 if (outLenx10 < sizeof( sNASPerformNetworkScanResponse_NetworkInfo ))
524 {
525 return eGOBI_ERR_MALFORMED_RSP;
526 }
527
528 UINT16 netCount = pTLVx10->mNumberOfInfoInstances;
529 if (netCount > maxInstances)
530 {
531 netCount = maxInstances;
532 }
533
534 const sNASPerformNetworkScanResponse_NetworkInfo::sNetworkInfo * pNetInfo;
535
536 // Align to the first array element
537 pNetInfo = (const sNASPerformNetworkScanResponse_NetworkInfo::sNetworkInfo *)
538 ((const BYTE *)pTLVx10
539 + sizeof( sNASPerformNetworkScanResponse_NetworkInfo ));
540 ULONG offset = sizeof( sNASPerformNetworkScanResponse_NetworkInfo );
541
542 sScannedNetworkInfo * pNet = (sScannedNetworkInfo *)pInstances;
543 for (BYTE i = 0; i < netCount; i++)
544 {
545 // Check TLV size
546 if (offset > outLenx10)
547 {
548 return eGOBI_ERR_MALFORMED_RSP;
549 }
550
551 pNet->mMCC = pNetInfo->mMobileCountryCode;
552 pNet->mMNC = pNetInfo->mMobileNetworkCode;
553 pNet->mInUse = pNetInfo->mInUseStatus;
554 pNet->mRoaming = pNetInfo->mRoamingStatus;
555 pNet->mForbidden = pNetInfo->mForbiddenStatus;
556 pNet->mPreferred = pNetInfo->mPreferredStatus;
557
558 memset( &pNet->mDescription[0], 0, MAX_SNI_DESCRIPTION_LEN );
559
560 BYTE descLen = pNetInfo->mDescriptionLength;
561 if (descLen > 0)
562 {
563 // Move pNetInfo forward
564 pNetInfo++;
565 offset += sizeof( sNASPerformNetworkScanResponse_NetworkInfo::sNetworkInfo );
566
567 // Check TLV size
568 if (offset > outLenx10)
569 {
570 return eGOBI_ERR_MALFORMED_RSP;
571 }
572
573 std::string netDesc( (LPCSTR)pNetInfo );
574
575 ULONG actualLen = (ULONG)netDesc.size();
576 if (actualLen >= MAX_SNI_DESCRIPTION_LEN)
577 {
578 actualLen = MAX_SNI_DESCRIPTION_LEN - 1;
579 }
580
581 LPCSTR pNetDesc = netDesc.c_str();
582 memcpy( &pNet->mDescription[0], pNetDesc, actualLen );
583
584 // Move pNetInfo past string
585 pNetInfo = (const sNASPerformNetworkScanResponse_NetworkInfo::sNetworkInfo *)
586 ((const BYTE *)pNetInfo + descLen);
587 offset += descLen;
588 }
589
590 pNet++;
591 }
592
593 *pInstanceSize = (BYTE)netCount;
594
595 return eGOBI_ERR_NONE;
596 }
597
598 /*===========================================================================
599 METHOD:
600 ParsePerformNetworkRATScan
601
602 DESCRIPTION:
603 This function performs a scan for available networks (includes RAT)
604
605 PARAMETERS:
606 inLen [ I ] - Length of input buffer
607 pIn [ I ] - Input buffer
608 pInstanceSize [I/O] - Upon input the maximum number of elements that the
609 network info instance array can contain. Upon
610 success the actual number of elements in the
611 network info instance array
612 pInstances [ O ] - The network info instance array
613 pRATSize [I/O] - Upon input the maximum number of elements that the
614 RAT info instance array can contain. Upon success
615 the actual number of elements in the RAT info
616 instance array
617 pRATInstances [ O ] - The RAT info instance array
618
619 RETURN VALUE:
620 ULONG - Return code
621 ===========================================================================*/
622 ULONG ParsePerformNetworkRATScan(
623 ULONG inLen,
624 const BYTE * pIn,
625 BYTE * pInstanceSize,
626 BYTE * pInstances,
627 BYTE * pRATSize,
628 BYTE * pRATInstances )
629 {
630 // Validate arguments
631 if (pIn == 0
632 || pInstanceSize == 0
633 || *pInstanceSize == 0
634 || pInstances == 0
635 || pRATSize == 0
636 || *pRATSize == 0
637 || pRATInstances == 0)
638 {
639 return eGOBI_ERR_INVALID_ARG;
640 }
641
642 BYTE maxRATInstances = *pRATSize;
643
644 // Assume failure
645 *pInstanceSize = 0;
646 *pRATSize = 0;
647
648 // First, generate the instances using ParsePerformNetworkScan
649 ULONG rc = ParsePerformNetworkScan( inLen, pIn, pInstanceSize, pInstances );
650 if (rc != eGOBI_ERR_NONE)
651 {
652 return rc;
653 }
654
655 // Now find the RAT info too
656
657 // Find the TLV
658 const sNASPerformNetworkScanResponse_NetworkRAT * pTLVx11;
659 ULONG outLenx11;
660 rc = GetTLV( inLen, pIn, 0x11, &outLenx11, (const BYTE **)&pTLVx11 );
661 if (rc != eGOBI_ERR_NONE)
662 {
663 return rc;
664 }
665
666 // Is the TLV large enough?
667 if (outLenx11 < sizeof( sNASPerformNetworkScanResponse_NetworkRAT ))
668 {
669 return eGOBI_ERR_MALFORMED_RSP;
670 }
671
672 UINT16 ratCount = pTLVx11->mNumberOfInfoInstances;
673 if (ratCount > maxRATInstances)
674 {
675 ratCount = maxRATInstances;
676 }
677
678 const sNASPerformNetworkScanResponse_NetworkRAT::sInfo * pRatInfo;
679
680 // Verify there is room for the array in the TLV
681 if (outLenx11 < sizeof( sNASPerformNetworkScanResponse_NetworkRAT )
682 + sizeof( sNASPerformNetworkScanResponse_NetworkRAT::sInfo )
683 * ratCount)
684 {
685 return eGOBI_ERR_MALFORMED_RSP;
686 }
687
688 // Align to the first array element
689 pRatInfo = (const sNASPerformNetworkScanResponse_NetworkRAT::sInfo *)
690 ((const BYTE *)pTLVx11
691 + sizeof( sNASPerformNetworkScanResponse_NetworkRAT ));
692
693 sScannedNetworkRATInfo * pRAT = (sScannedNetworkRATInfo *)pRATInstances;
694 for (BYTE r = 0; r < ratCount; r++)
695 {
696 pRAT->mMCC = pRatInfo->mMobileCountryCode;
697 pRAT->mMNC = pRatInfo->mMobileNetworkCode;
698 pRAT->mRAT = pRatInfo->mRadioAccessTechnology;
699
700 pRAT++;
701 pRatInfo++;
702 }
703
704 *pRATSize = (BYTE)ratCount;
705
706 return eGOBI_ERR_NONE;
707 }
708
709 /*===========================================================================
710 METHOD:
711 PackInitiateNetworkRegistration
712
713 DESCRIPTION:
714 This function initiates a network registration
715
716 PARAMETERS:
717 pOutLen [I/O] - Upon input the maximum number of BYTEs pOut can
718 contain, upon output the number of BYTEs copied
719 to pOut
720 pOut [ O ] - Output buffer
721 regType [ I ] - Registration type
722 mcc [ I ] - Mobile country code (ignored for auto registration)
723 mnc [ I ] - Mobile network code (ignored for auto registration)
724 rat [ I ] - Radio access type (ignored for auto registration)
725
726 RETURN VALUE:
727 ULONG - Return code
728 ===========================================================================*/
729 ULONG PackInitiateNetworkRegistration(
730 ULONG * pOutLen,
731 BYTE * pOut,
732 ULONG regType,
733 WORD mcc,
734 WORD mnc,
735 ULONG rat )
736 {
737 // Validate arguments
738 if (pOut == 0)
739 {
740 return eGOBI_ERR_INVALID_ARG;
741 }
742
743 // Set the action
744
745 // Check size
746 WORD tlvx01Sz = sizeof( sNASInitiateNetworkRegisterRequest_Action );
747 if (*pOutLen < sizeof( sQMIRawContentHeader ) + tlvx01Sz)
748 {
749 return eGOBI_ERR_BUFFER_SZ;
750 }
751
752 sQMIRawContentHeader * pHeader = (sQMIRawContentHeader*)pOut;
753 pHeader->mTypeID = 0x01;
754 pHeader->mLength = tlvx01Sz;
755
756 ULONG offset = sizeof( sQMIRawContentHeader );
757
758 sNASInitiateNetworkRegisterRequest_Action * pTLVx01;
759 pTLVx01 = (sNASInitiateNetworkRegisterRequest_Action*)(pOut + offset);
760 memset( pTLVx01, 0, tlvx01Sz );
761
762 // Set the value
763 pTLVx01->mRegisterAction = (eQMINASRegisterActions)regType;
764
765 offset += tlvx01Sz;
766
767 // Set the info
768
769 // Check size
770 WORD tlvx10Sz = sizeof( sNASInitiateNetworkRegisterRequest_ManualInfo );
771 if (*pOutLen < offset + sizeof( sQMIRawContentHeader ) + tlvx10Sz)
772 {
773 return eGOBI_ERR_BUFFER_SZ;
774 }
775
776 pHeader = (sQMIRawContentHeader*)(pOut + offset);
777 pHeader->mTypeID = 0x10;
778 pHeader->mLength = tlvx10Sz;
779
780 offset = sizeof( sQMIRawContentHeader );
781
782 sNASInitiateNetworkRegisterRequest_ManualInfo * pTLVx10;
783 pTLVx10 = (sNASInitiateNetworkRegisterRequest_ManualInfo*)(pOut + offset);
784 memset( pTLVx10, 0, tlvx10Sz );
785
786 // Set the value
787 pTLVx10->mMobileCountryCode = mcc;
788 pTLVx10->mMobileNetworkCode = mnc;
789 pTLVx10->mRadioAccessTechnology = (eQMINASRadioAccessTechnologies)rat;
790
791 offset += tlvx10Sz;
792
793 *pOutLen = offset;
794 return eGOBI_ERR_NONE;
795 }
796
797 /*===========================================================================
798 METHOD:
799 PackInitiateDomainAttach
800
801 DESCRIPTION:
802 This function initiates a domain attach (or detach)
803
804 PARAMETERS:
805 pOutLen [I/O] - Upon input the maximum number of BYTEs pOut can
806 contain, upon output the number of BYTEs copied
807 to pOut
808 pOut [ O ] - Output buffer
809 action [ I ] - PS attach action (attach or detach)
810
811 RETURN VALUE:
812 ULONG - Return code
813 ===========================================================================*/
814 ULONG PackInitiateDomainAttach(
815 ULONG * pOutLen,
816 BYTE * pOut,
817 ULONG action )
818 {
819 // Validate arguments
820 if (pOut == 0)
821 {
822 return eGOBI_ERR_INVALID_ARG;
823 }
824
825 // Check size
826 WORD tlvx10Sz = sizeof( sNASInitiateAttachRequest_Action );
827 if (*pOutLen < sizeof( sQMIRawContentHeader ) + tlvx10Sz)
828 {
829 return eGOBI_ERR_BUFFER_SZ;
830 }
831
832 sQMIRawContentHeader * pHeader = (sQMIRawContentHeader*)pOut;
833 pHeader->mTypeID = 0x10;
834 pHeader->mLength = tlvx10Sz;
835
836 ULONG offset = sizeof( sQMIRawContentHeader );
837
838 sNASInitiateAttachRequest_Action * pTLVx10;
839 pTLVx10 = (sNASInitiateAttachRequest_Action*)(pOut + offset);
840 memset( pTLVx10, 0, tlvx10Sz );
841
842 // Set the value
843 pTLVx10->mPSAttachAction = (eQMINASPSAttachActions)action;
844
845 offset += tlvx10Sz;
846
847 *pOutLen = offset;
848 return eGOBI_ERR_NONE;
849 }
850
851 /*===========================================================================
852 METHOD:
853 ParseGetServingNetwork
854
855 DESCRIPTION:
856 Gets information regarding the system that currently provides service
857 to the device
858
859 PARAMETERS:
860 inLen [ I ] - Length of input buffer
861 pIn [ I ] - Input buffer
862 pRegistrationState [ O ] - Registration state
863 pCSDomain [ O ] - Circuit switch domain status
864 pPSDomain [ O ] - Packet switch domain status
865 pRAN [ O ] - Radio access network
866 pRadioIfacesSize [I/O] - Upon input the maximum number of elements
867 that the radio interfaces can contain. Upon
868 successful output the actual number of elements
869 in the radio interface array
870 pRadioIfaces [ O ] - The radio interface array
871 pRoaming [ O ] - Roaming indicator (0xFFFFFFFF - Unknown)
872 pMCC [ O ] - Mobile country code (0xFFFF - Unknown)
873 pMNC [ O ] - Mobile network code (0xFFFF - Unknown)
874 nameSize [ I ] - The maximum number of characters (including
875 NULL terminator) that the network name array
876 can contain
877 pName [ O ] - The network name or description represented
878 as a NULL terminated string (empty string
879 returned when unknown)
880
881 RETURN VALUE:
882 ULONG - Return code
883 ===========================================================================*/
884 ULONG ParseGetServingNetwork(
885 ULONG inLen,
886 const BYTE * pIn,
887 ULONG * pRegistrationState,
888 ULONG * pCSDomain,
889 ULONG * pPSDomain,
890 ULONG * pRAN,
891 BYTE * pRadioIfacesSize,
892 BYTE * pRadioIfaces,
893 ULONG * pRoaming,
894 WORD * pMCC,
895 WORD * pMNC,
896 BYTE nameSize,
897 CHAR * pName )
898 {
899 // Validate arguments
900 if (pIn == 0
901 || pRegistrationState == 0
902 || pCSDomain == 0
903 || pPSDomain == 0
904 || pRAN == 0
905 || pRadioIfacesSize == 0
906 || *pRadioIfacesSize == 0
907 || pRadioIfaces == 0
908 || pRoaming == 0
909 || pMCC == 0
910 || pMNC == 0
911 || nameSize == 0
912 || pName == 0)
913 {
914 return eGOBI_ERR_INVALID_ARG;
915 }
916
917 BYTE maxRadioIfaces = *pRadioIfacesSize;
918
919 // Assume failure
920 *pRadioIfacesSize = 0;
921 *pRoaming = 0xffffffff;
922 *pMCC = 0xffff;
923 *pMNC = 0xffff;
924 *pName = 0;
925
926 // Parse the serving system (mandatory)
927
928 // Find the TLV
929 const sNASGetServingSystemResponse_ServingSystem * pTLVx01;
930 ULONG outLenx01;
931 ULONG rc = GetTLV( inLen, pIn, 0x01, &outLenx01, (const BYTE **)&pTLVx01 );
932 if (rc != eGOBI_ERR_NONE)
933 {
934 return rc;
935 }
936
937 // Is the TLV large enough?
938 if (outLenx01 < sizeof( sNASGetServingSystemResponse_ServingSystem ))
939 {
940 return eGOBI_ERR_MALFORMED_RSP;
941 }
942
943 // Populate the variables
944 *pRegistrationState = pTLVx01->mRegistrationState;
945 *pCSDomain = pTLVx01->mCSAttachState;
946 *pPSDomain = pTLVx01->mPSAttachState;
947 *pRAN = pTLVx01->mRegisteredNetwork;
948
949 BYTE activeRadioIfaces = pTLVx01->mNumberOfRadioInterfacesInUse;
950 if (activeRadioIfaces > maxRadioIfaces)
951 {
952 activeRadioIfaces = maxRadioIfaces;
953 }
954
955 const eQMINASRadioInterfaces * pRadioInfo;
956
957 // Verify there is room for the array in the TLV
958 if (outLenx01 < sizeof( sNASGetServingSystemResponse_ServingSystem )
959 + sizeof( eQMINASRadioInterfaces ) * activeRadioIfaces)
960 {
961 return eGOBI_ERR_MALFORMED_RSP;
962 }
963
964 // Align to the first array element
965 pRadioInfo = (const eQMINASRadioInterfaces *)
966 ((const BYTE *)pTLVx01
967 + sizeof( sNASGetServingSystemResponse_ServingSystem ));
968
969 ULONG * pOutRadioIfaces = (ULONG *)pRadioIfaces;
970 for (ULONG r = 0; r < activeRadioIfaces; r++)
971 {
972 *pOutRadioIfaces = *pRadioInfo;
973 pOutRadioIfaces++;
974 pRadioInfo++;
975 }
976
977 *pRadioIfacesSize = activeRadioIfaces;
978
979 // Find the roaming indicator (optional)
980 const sNASGetServingSystemResponse_RoamingIndicator * pTLVx10;
981 ULONG outLenx10;
982 rc = GetTLV( inLen, pIn, 0x10, &outLenx10, (const BYTE **)&pTLVx10 );
983 if (rc == eGOBI_ERR_NONE)
984 {
985 if (outLenx10 < sizeof( sNASGetServingSystemResponse_RoamingIndicator ))
986 {
987 return eGOBI_ERR_MALFORMED_RSP;
988 }
989
990 // Get the values
991 *pRoaming = (eQMINASRoamingIndicators)pTLVx10->mRoamingIndicator;
992 }
993
994 // Find the PLMN (optional)
995 const sNASGetServingSystemResponse_CurrentPLMN * pTLVx12;
996 ULONG outLenx12;
997 rc = GetTLV( inLen, pIn, 0x12, &outLenx12, (const BYTE **)&pTLVx12 );
998 if (rc == eGOBI_ERR_NONE)
999 {
1000 if (outLenx12 < sizeof( sNASGetServingSystemResponse_CurrentPLMN ))
1001 {
1002 return eGOBI_ERR_MALFORMED_RSP;
1003 }
1004
1005 *pMCC = pTLVx12->mMobileCountryCode;
1006 *pMNC = pTLVx12->mMobileNetworkCode;
1007
1008 ULONG descLen = pTLVx12->mDescriptionLength;
1009 const CHAR * pDesc;
1010
1011 // Verify there is room for the array in the TLV
1012 if (outLenx12 < sizeof( sNASGetServingSystemResponse_CurrentPLMN )
1013 + sizeof( CHAR ) * descLen)
1014 {
1015 return eGOBI_ERR_MALFORMED_RSP;
1016 }
1017
1018 // Space to perform the copy?
1019 if (nameSize < descLen + 1)
1020 {
1021 return eGOBI_ERR_BUFFER_SZ;
1022 }
1023
1024 // Align to the first array element
1025 pDesc = (const CHAR *)((const BYTE *)pTLVx12
1026 + sizeof( sNASGetServingSystemResponse_CurrentPLMN ));
1027
1028 memcpy( pName, pDesc, descLen );
1029 pName[descLen] = 0;
1030 }
1031
1032 return eGOBI_ERR_NONE;
1033 }
1034
1035 /*===========================================================================
1036 METHOD:
1037 ParseGetServingNetworkCapabilities
1038
1039 DESCRIPTION:
1040 Gets information regarding the data capabilities of the system that
1041 currently provides service to the device
1042
1043 PARAMETERS:
1044 inLen [ I ] - Length of input buffer
1045 pIn [ I ] - Input buffer
1046 pDataCapsSize [I/O] - Upon input the maximum number of elements that the
1047 data capabilities array can contain. Upon success
1048 the actual number of elements in the data
1049 capabilities array
1050 pDataCaps [ O ] - The data capabilities array
1051
1052 RETURN VALUE:
1053 ULONG - Return code
1054 ===========================================================================*/
1055 ULONG ParseGetServingNetworkCapabilities(
1056 ULONG inLen,
1057 const BYTE * pIn,
1058 BYTE * pDataCapsSize,
1059 BYTE * pDataCaps )
1060 {
1061 // Validate arguments
1062 if (pIn == 0
1063 || pDataCapsSize == 0
1064 || *pDataCapsSize == 0
1065 || pDataCaps == 0)
1066 {
1067 return eGOBI_ERR_INVALID_ARG;
1068 }
1069
1070 BYTE maxDataCaps = *pDataCapsSize;
1071
1072 // Assume failure
1073 *pDataCapsSize = 0;
1074
1075 // Find the TLV
1076 const sNASGetServingSystemResponse_DataServices * pTLVx11;
1077 ULONG outLenx11;
1078 ULONG rc = GetTLV( inLen, pIn, 0x11, &outLenx11, (const BYTE **)&pTLVx11 );
1079 if (rc != eGOBI_ERR_NONE)
1080 {
1081 return rc;
1082 }
1083
1084 // Is the TLV large enough?
1085 if (outLenx11 < sizeof( sNASGetServingSystemResponse_DataServices ))
1086 {
1087 return eGOBI_ERR_MALFORMED_RSP;
1088 }
1089
1090 BYTE activeDataCaps = pTLVx11->mNumberOfDataCapabilities;
1091 if (activeDataCaps > maxDataCaps)
1092 {
1093 activeDataCaps = maxDataCaps;
1094 }
1095
1096 const eQMINASDataServiceCapabilities2 * pInDataCaps;
1097
1098 // Verify there is room for the array in the TLV
1099 if (outLenx11 < sizeof( sNASGetServingSystemResponse_DataServices )
1100 + sizeof( eQMINASDataServiceCapabilities2 ) * activeDataCaps)
1101 {
1102 return eGOBI_ERR_MALFORMED_RSP;
1103 }
1104
1105 // Align to the first array element
1106 pInDataCaps = (const eQMINASDataServiceCapabilities2 *)
1107 ((const BYTE *)pTLVx11
1108 + sizeof( sNASGetServingSystemResponse_DataServices ));
1109
1110 ULONG * pOutDataCaps = (ULONG *)pDataCaps;
1111 for (ULONG d = 0; d < activeDataCaps; d++)
1112 {
1113 *pOutDataCaps = *pInDataCaps;
1114 pOutDataCaps++;
1115 pInDataCaps++;
1116 }
1117
1118 *pDataCapsSize = activeDataCaps;
1119
1120 return eGOBI_ERR_NONE;
1121 }
1122
1123 /*===========================================================================
1124 METHOD:
1125 ParseGetHomeNetwork
1126
1127 DESCRIPTION:
1128 This function retrieves information about the home network of the device
1129
1130 PARAMETERS:
1131 inLen [ I ] - Length of input buffer
1132 pIn [ I ] - Input buffer
1133 pMCC [ O ] - Mobile country code
1134 pMNC [ O ] - Mobile network code
1135 nameSize [ I ] - The maximum number of characters (including NULL
1136 terminator) that the network name array can contain
1137 pName [ O ] - The network name or description represented as a NULL
1138 terminated string (empty string returned when unknown)
1139 pSID [ O ] - Home network system ID (0xFFFF - Unknown)
1140 pNID [ O ] - Home network ID (0xFFFF - Unknown)
1141
1142 RETURN VALUE:
1143 ULONG - Return code
1144 ===========================================================================*/
1145 ULONG ParseGetHomeNetwork(
1146 ULONG inLen,
1147 const BYTE * pIn,
1148 WORD * pMCC,
1149 WORD * pMNC,
1150 BYTE nameSize,
1151 CHAR * pName,
1152 WORD * pSID,
1153 WORD * pNID )
1154 {
1155 // Validate arguments
1156 if (pIn == 0
1157 || pMCC == 0
1158 || pMNC == 0
1159 || nameSize == 0
1160 || pName == 0
1161 || pSID == 0)
1162 {
1163 return eGOBI_ERR_INVALID_ARG;
1164 }
1165
1166 // Assume failure
1167 *pName = 0;
1168 *pSID = 0xffff;
1169 *pNID = 0xffff;
1170
1171 // Find the name (mandatory)
1172 const sNASGetHomeNetworkResponse_HomeNetwork * pTLVx01;
1173 ULONG outLenx01;
1174 ULONG rc = GetTLV( inLen, pIn, 0x01, &outLenx01, (const BYTE **)&pTLVx01 );
1175 if (rc != eGOBI_ERR_NONE)
1176 {
1177 return rc;
1178 }
1179
1180 if (outLenx01 < sizeof( sNASGetHomeNetworkResponse_HomeNetwork ))
1181 {
1182 return eGOBI_ERR_MALFORMED_RSP;
1183 }
1184
1185 // Populate the variables
1186 *pMCC = pTLVx01->mMobileCountryCode;
1187 *pMNC = pTLVx01->mMobileNetworkCode;
1188
1189 ULONG descLen = pTLVx01->mDescriptionLength;
1190 const CHAR * pDesc;
1191
1192 // Verify there is room for the array in the TLV
1193 if (outLenx01 < sizeof( sNASGetHomeNetworkResponse_HomeNetwork )
1194 + sizeof( CHAR ) * descLen)
1195 {
1196 return eGOBI_ERR_MALFORMED_RSP;
1197 }
1198
1199 // Space to perform the copy?
1200 if (nameSize < descLen + 1)
1201 {
1202 return eGOBI_ERR_BUFFER_SZ;
1203 }
1204
1205 // Align to the first array element
1206 pDesc = (const CHAR *)((const BYTE *)pTLVx01
1207 + sizeof( sNASGetHomeNetworkResponse_HomeNetwork ));
1208
1209 memcpy( pName, pDesc, descLen );
1210 pName[descLen] = 0;
1211
1212
1213 // Find the SID/NID (optional)
1214 const sNASGetHomeNetworkResponse_HomeIDs * pTLVx10;
1215 ULONG outLenx10;
1216 rc = GetTLV( inLen, pIn, 0x10, &outLenx10, (const BYTE **)&pTLVx10 );
1217 if (rc == eGOBI_ERR_NONE)
1218 {
1219 if (outLenx10 < sizeof( sNASGetHomeNetworkResponse_HomeIDs ))
1220 {
1221 return eGOBI_ERR_MALFORMED_RSP;
1222 }
1223
1224 *pSID = pTLVx10->mSystemID;
1225 *pNID = pTLVx10->mNetworkID;
1226 }
1227
1228 return eGOBI_ERR_NONE;
1229 }
1230
1231 /*===========================================================================
1232 METHOD:
1233 PackSetNetworkPreference
1234
1235 DESCRIPTION:
1236 This function sets the network registration preference
1237
1238 PARAMETERS:
1239 pOutLen [I/O] - Upon input the maximum number of BYTEs pOut can
1240 contain, upon output the number of BYTEs copied
1241 to pOut
1242 pOut [ O ] - Output buffer
1243 technologyPref [ I ] - Technology preference bitmap
1244 duration [ I ] - Duration of active preference
1245
1246 RETURN VALUE:
1247 ULONG - Return code
1248 ===========================================================================*/
1249 ULONG PackSetNetworkPreference(
1250 ULONG * pOutLen,
1251 BYTE * pOut,
1252 ULONG technologyPref,
1253 ULONG duration )
1254 {
1255 // Validate arguments
1256 if (pOut == 0)
1257 {
1258 return eGOBI_ERR_INVALID_ARG;
1259 }
1260
1261 // Check size
1262 WORD tlvx01Sz = sizeof( sNASSetTechnologyPreferenceRequest_Preference );
1263 if (*pOutLen < sizeof( sQMIRawContentHeader ) + tlvx01Sz)
1264 {
1265 return eGOBI_ERR_BUFFER_SZ;
1266 }
1267
1268 sQMIRawContentHeader * pHeader = (sQMIRawContentHeader*)pOut;
1269 pHeader->mTypeID = 0x01;
1270 pHeader->mLength = tlvx01Sz;
1271
1272 ULONG offset = sizeof( sQMIRawContentHeader );
1273
1274 sNASSetTechnologyPreferenceRequest_Preference * pTLVx01;
1275 pTLVx01 = (sNASSetTechnologyPreferenceRequest_Preference*)(pOut + offset);
1276 memset( pTLVx01, 0, tlvx01Sz );
1277
1278 // Copy technology preference WORD as-is
1279 memcpy( &pTLVx01->mValOfTechnology, &technologyPref, 2 );
1280
1281 pTLVx01->mDuration = (eQMINASTechPrefDurations)duration;
1282
1283 offset += tlvx01Sz;
1284
1285 *pOutLen = offset;
1286 return eGOBI_ERR_NONE;
1287 }
1288
1289 /*===========================================================================
1290 METHOD:
1291 ParseGetNetworkPreference
1292
1293 DESCRIPTION:
1294 This function returns the network registration preference
1295
1296 PARAMETERS:
1297 inLen [ I ] - Length of input buffer
1298 pIn [ I ] - Input buffer
1299 pTechnologyPref [ O ] - Technology preference bitmap
1300 pDuration [ O ] - Duration of active preference
1301 pPersistentTechnologyPref [ O ] - Persistent technology preference bitmap
1302
1303 RETURN VALUE:
1304 ULONG - Return code
1305 ===========================================================================*/
1306 ULONG ParseGetNetworkPreference(
1307 ULONG inLen,
1308 const BYTE * pIn,
1309 ULONG * pTechnologyPref,
1310 ULONG * pDuration,
1311 ULONG * pPersistentTechnologyPref )
1312 {
1313 // Validate arguments
1314 if (pIn == 0
1315 || pTechnologyPref == 0
1316 || pDuration == 0
1317 || pPersistentTechnologyPref == 0)
1318 {
1319 return eGOBI_ERR_INVALID_ARG;
1320 }
1321
1322 // Find the preference (mandatory)
1323 const sNASGetTechnologyPreferenceResponse_ActivePreference * pTLVx01;
1324 ULONG outLenx01;
1325 ULONG rc = GetTLV( inLen, pIn, 0x01, &outLenx01, (const BYTE **)&pTLVx01 );
1326 if (rc != eGOBI_ERR_NONE)
1327 {
1328 return rc;
1329 }
1330
1331 if (outLenx01 < sizeof( sNASGetTechnologyPreferenceResponse_ActivePreference ))
1332 {
1333 return eGOBI_ERR_MALFORMED_RSP;
1334 }
1335
1336 // Copy technology preference WORD as-is
1337 *pTechnologyPref = 0;
1338 memcpy( pTechnologyPref, &pTLVx01->mValOfTechnology, 2 );
1339
1340 *pDuration = pTLVx01->mDuration;
1341
1342
1343 // Until we know any better the persistent setting is the current setting
1344 *pPersistentTechnologyPref = *pTechnologyPref;
1345
1346 // Find the persistant technology preference (optional)
1347 const sNASGetTechnologyPreferenceResponse_PersistentPreference * pTLVx10;
1348 ULONG outLenx10;
1349 rc = GetTLV( inLen, pIn, 0x10, &outLenx10, (const BYTE **)&pTLVx10 );
1350 if (rc == eGOBI_ERR_NONE)
1351 {
1352 if (outLenx10 < sizeof( sNASGetTechnologyPreferenceResponse_PersistentPreference ))
1353 {
1354 return eGOBI_ERR_MALFORMED_RSP;
1355 }
1356
1357 // Copy technology preference WORD as-is
1358 *pTechnologyPref = 0;
1359 memcpy( pPersistentTechnologyPref, &pTLVx10->mValOfTechnology, 2 );
1360 }
1361
1362 return eGOBI_ERR_NONE;
1363 }
1364
1365 /*===========================================================================
1366 METHOD:
1367 PackSetCDMANetworkParameters
1368
1369 DESCRIPTION:
1370 This function sets the desired CDMA network parameters
1371
1372 PARAMETERS:
1373 pOutLen [I/O] - Upon input the maximum number of BYTEs pOut can
1374 contain, upon output the number of BYTEs copied
1375 to pOut
1376 pOut [ O ] - Output buffer
1377 pSPC [ I ] - Six digit service programming code
1378 pForceRev0 [ I ] - (Optional) Force CDMA 1x-EV-DO Rev. 0 mode?
1379 pCustomSCP [ I ] - (Optional) Use a custom config for CDMA 1x-EV-DO SCP?
1380 pProtocol [ I ] - (Optional) Protocol mask for custom SCP config
1381 pBroadcast [ I ] - (Optional) Broadcast mask for custom SCP config
1382 pApplication [ I ] - (Optional) Application mask for custom SCP config
1383 pRoaming [ I ] - (Optional) Roaming preference
1384
1385 RETURN VALUE:
1386 ULONG - Return code
1387 ===========================================================================*/
1388 ULONG PackSetCDMANetworkParameters(
1389 ULONG * pOutLen,
1390 BYTE * pOut,
1391 CHAR * pSPC,
1392 BYTE * pForceRev0,
1393 BYTE * pCustomSCP,
1394 ULONG * pProtocol,
1395 ULONG * pBroadcast,
1396 ULONG * pApplication,
1397 ULONG * pRoaming )
1398 {
1399 // Validate arguments
1400 if (pOut == 0)
1401 {
1402 return eGOBI_ERR_INVALID_ARG;
1403 }
1404
1405 // If you specify one of the custom SCP config fields then you must
1406 // specify them all
1407 ULONG scpCount = 0;
1408 if (pCustomSCP != 0)
1409 {
1410 scpCount++;
1411 }
1412
1413 if (pProtocol != 0)
1414 {
1415 scpCount++;
1416 }
1417
1418 if (pBroadcast != 0)
1419 {
1420 scpCount++;
1421 }
1422
1423 if (pApplication != 0)
1424 {
1425 scpCount++;
1426 }
1427
1428 if (scpCount != 0 && scpCount != 4)
1429 {
1430 return eGOBI_ERR_INVALID_ARG;
1431 }
1432
1433 // Rev. 0 and SCP custom config are mutually exclusive
1434 if (pForceRev0 != 0 && scpCount == 4)
1435 {
1436 if (*pForceRev0 != 0 && *pCustomSCP != 0)
1437 {
1438 return eGOBI_ERR_INVALID_ARG;
1439 }
1440 }
1441
1442 sQMIRawContentHeader * pHeader;
1443 ULONG offset = 0;
1444
1445 // Need to start with SPC?
1446 if (pForceRev0 != 0 || scpCount == 4)
1447 {
1448 // Validate arguments
1449 if (pSPC == 0 || pSPC[0] == 0)
1450 {
1451 return eGOBI_ERR_INVALID_ARG;
1452 }
1453
1454 std::string spc( pSPC );
1455 if (spc.size() > 6)
1456 {
1457 return eGOBI_ERR_INVALID_ARG;
1458 }
1459
1460 if (spc.find_first_not_of( "0123456789" ) != std::string::npos )
1461 {
1462 return eGOBI_ERR_INVALID_ARG;
1463 }
1464
1465 // Check size
1466 WORD tlvx10Sz = sizeof( sNASSetNetworkParametersRequest_SPC );
1467 if (*pOutLen < offset + sizeof( sQMIRawContentHeader ) + tlvx10Sz)
1468 {
1469 return eGOBI_ERR_BUFFER_SZ;
1470 }
1471
1472 pHeader = (sQMIRawContentHeader*)(pOut + offset);
1473 pHeader->mTypeID = 0x10;
1474 pHeader->mLength = tlvx10Sz;
1475
1476 offset += sizeof( sQMIRawContentHeader );
1477
1478 sNASSetNetworkParametersRequest_SPC * pTLVx10;
1479 pTLVx10 = (sNASSetNetworkParametersRequest_SPC*)(pOut + offset);
1480 memset( pTLVx10, 0, tlvx10Sz );
1481
1482 // Set the values
1483 memcpy( &pTLVx10->mSPC[0], spc.c_str(), spc.size() );
1484
1485 offset += tlvx10Sz;
1486 }
1487
1488 // Force Rev. 0?
1489 if (pForceRev0 != 0)
1490 {
1491 // Check size
1492 WORD tlvx14Sz = sizeof( sNASSetNetworkParametersRequest_CDMA1xEVDORevision );
1493 if (*pOutLen < offset + sizeof( sQMIRawContentHeader ) + tlvx14Sz)
1494 {
1495 return eGOBI_ERR_BUFFER_SZ;
1496 }
1497
1498 pHeader = (sQMIRawContentHeader*)(pOut + offset);
1499 pHeader->mTypeID = 0x14;
1500 pHeader->mLength = tlvx14Sz;
1501
1502 offset += sizeof( sQMIRawContentHeader );
1503
1504 sNASSetNetworkParametersRequest_CDMA1xEVDORevision * pTLVx14;
1505 pTLVx14 = (sNASSetNetworkParametersRequest_CDMA1xEVDORevision*)(pOut + offset);
1506 memset( pTLVx14, 0, tlvx14Sz );
1507
1508 // Set the value
1509 pTLVx14->mForceCDMA1xEVDORev0 = (*pForceRev0 == 0 ? 0 : 1);
1510
1511 offset += tlvx14Sz;
1512 }
1513
1514 if (scpCount == 4)
1515 {
1516 // Check size
1517 WORD tlvx15Sz = sizeof( sNASSetNetworkParametersRequest_CDMA1xEVDOSCPCustom );
1518 if (*pOutLen < offset + sizeof( sQMIRawContentHeader ) + tlvx15Sz)
1519 {
1520 return eGOBI_ERR_BUFFER_SZ;
1521 }
1522
1523 pHeader = (sQMIRawContentHeader*)(pOut + offset);
1524 pHeader->mTypeID = 0x15;
1525 pHeader->mLength = tlvx15Sz;
1526
1527 offset += sizeof( sQMIRawContentHeader );
1528
1529 sNASSetNetworkParametersRequest_CDMA1xEVDOSCPCustom * pTLVx15;
1530 pTLVx15 = (sNASSetNetworkParametersRequest_CDMA1xEVDOSCPCustom*)(pOut + offset);
1531 memset( pTLVx15, 0, tlvx15Sz );
1532
1533 // Set the values
1534 pTLVx15->mCDMA1xEVDOSCPCustomConfig = (*pCustomSCP == 0 ? 0 : 1);
1535
1536 // The pProtocol bitmask
1537 pTLVx15->mSubtype2PhysicalLayer = (*pProtocol & 0x00000001 ? 1 : 0);
1538 pTLVx15->mEnhancedCCMAC = (*pProtocol & 0x00000002 ? 1 : 0);
1539 pTLVx15->mEnhancedACMAC = (*pProtocol & 0x00000004 ? 1 : 0);
1540 pTLVx15->mEnhancedFTCMAC = (*pProtocol & 0x00000008 ? 1 : 0);
1541 pTLVx15->mSubtype3RTCMAC = (*pProtocol & 0x00000010 ? 1 : 0);
1542 pTLVx15->mSubtype1RTCMAC = (*pProtocol & 0x00000020 ? 1 : 0);
1543 pTLVx15->mEnhancedIdle = (*pProtocol & 0x00000040 ? 1 : 0);
1544 pTLVx15->mGenericMultimodeCapableDiscPort
1545 = (*pProtocol & 0x00000080 ? 1 : 0);
1546
1547 pTLVx15->mGenericBroadcast = (*pBroadcast & 0x00000001 ? 1 : 0);
1548
1549 pTLVx15->mSNMultiflowPacketApplication
1550 = (*pApplication & 0x00000001 ? 1 : 0);
1551
1552 pTLVx15->mSNEnhancedMultiflowPacketApplication
1553 = (*pApplication & 0x00000002 ? 1 : 0);
1554
1555 offset += tlvx15Sz;
1556 }
1557
1558 if (pRoaming != 0)
1559 {
1560 // Check size
1561 WORD tlvx16Sz = sizeof( sNASSetNetworkParametersRequest_Roaming );
1562 if (*pOutLen < offset + sizeof( sQMIRawContentHeader ) + tlvx16Sz)
1563 {
1564 return eGOBI_ERR_BUFFER_SZ;
1565 }
1566
1567 pHeader = (sQMIRawContentHeader*)(pOut + offset);
1568 pHeader->mTypeID = 0x16;
1569 pHeader->mLength = tlvx16Sz;
1570
1571 offset += sizeof( sQMIRawContentHeader );
1572
1573 sNASSetNetworkParametersRequest_Roaming * pTLVx16;
1574 pTLVx16 = (sNASSetNetworkParametersRequest_Roaming*)(pOut + offset);
1575 memset( pTLVx16, 0, tlvx16Sz );
1576
1577 // Set the values
1578 pTLVx16->mRoamPreference = (eQMINASRoamingPreferences)*pRoaming;
1579
1580 offset += tlvx16Sz;
1581 }
1582
1583 // At least one of the optional parameters must have been set
1584 if (offset == 0)
1585 {
1586 return eGOBI_ERR_INVALID_ARG;
1587 }
1588
1589 *pOutLen = offset;
1590 return eGOBI_ERR_NONE;
1591 }
1592
1593 /*===========================================================================
1594 METHOD:
1595 ParseGetCDMANetworkParameters
1596
1597 DESCRIPTION:
1598 This function gets the current CDMA network parameters
1599
1600 PARAMETERS:
1601 inLen [ I ] - Length of input buffer
1602 pIn [ I ] - Input buffer
1603 pSCI [ O ] - Slot cycle index
1604 pSCM [ O ] - Station class mark
1605 pRegHomeSID [ O ] - Register on home SID?
1606 pRegForeignSID [ O ] - Register on foreign SID?
1607 pRegForeignNID [ O ] - Register on foreign NID?
1608 pForceRev0 [ O ] - Force CDMA 1x-EV-DO Rev. 0 mode?
1609 pCustomSCP [ O ] - Use a custom config for CDMA 1x-EV-DO SCP?
1610 pProtocol [ O ] - Protocol mask for custom SCP config
1611 pBroadcast [ O ] - Broadcast mask for custom SCP config
1612 pApplication [ O ] - Application mask for custom SCP config
1613 pRoaming [ O ] - Roaming preference
1614
1615 RETURN VALUE:
1616 ULONG - Return code
1617 ===========================================================================*/
1618 ULONG ParseGetCDMANetworkParameters(
1619 ULONG inLen,
1620 const BYTE * pIn,
1621 BYTE * pSCI,
1622 BYTE * pSCM,
1623 BYTE * pRegHomeSID,
1624 BYTE * pRegForeignSID,
1625 BYTE * pRegForeignNID,
1626 BYTE * pForceRev0,
1627 BYTE * pCustomSCP,
1628 ULONG * pProtocol,
1629 ULONG * pBroadcast,
1630 ULONG * pApplication,
1631 ULONG * pRoaming )
1632 {
1633 // Validate arguments
1634 if (pIn == 0
1635 || pSCI == 0
1636 || pSCM == 0
1637 || pRegHomeSID == 0
1638 || pRegForeignSID == 0
1639 || pRegForeignNID == 0
1640 || pForceRev0 == 0
1641 || pCustomSCP == 0
1642 || pProtocol == 0
1643 || pBroadcast == 0
1644 || pApplication == 0
1645 || pRoaming == 0)
1646 {
1647 return eGOBI_ERR_INVALID_ARG;
1648 }
1649
1650 *pSCI = 0xff;
1651 *pSCM = 0xff;
1652 *pRegHomeSID = 0xff;
1653 *pRegForeignSID = 0xff;
1654 *pRegForeignNID = 0xff;
1655 *pForceRev0 = 0xff;
1656 *pCustomSCP = 0xff;
1657 *pProtocol = 0xffffffff;
1658 *pBroadcast = 0xffffffff;
1659 *pApplication = 0xffffffff;
1660 *pRoaming = 0xff;
1661
1662 // Find the SCI
1663 const sNASGetNetworkParametersResponse_SCI * pTLVx11;
1664 ULONG outLenx11;
1665 ULONG rc = GetTLV( inLen, pIn, 0x11, &outLenx11, (const BYTE **)&pTLVx11 );
1666 if (rc == eGOBI_ERR_NONE)
1667 {
1668 if (outLenx11 < sizeof( sNASGetNetworkParametersResponse_SCI ))
1669 {
1670 return eGOBI_ERR_MALFORMED_RSP;
1671 }
1672
1673 *pSCI = pTLVx11->mSlotCycleIndex;
1674 }
1675
1676 // Find the SCM
1677 const sNASGetNetworkParametersResponse_SCM * pTLVx12;
1678 ULONG outLenx12;
1679 rc = GetTLV( inLen, pIn, 0x12, &outLenx12, (const BYTE **)&pTLVx12 );
1680 if (rc == eGOBI_ERR_NONE)
1681 {
1682 if (outLenx12 < sizeof( sNASGetNetworkParametersResponse_SCM ))
1683 {
1684 return eGOBI_ERR_MALFORMED_RSP;
1685 }
1686
1687 *pSCM = pTLVx12->mStationClassMark;
1688 }
1689
1690 // Find the Registration
1691 const sNASGetNetworkParametersResponse_Registration * pTLVx13;
1692 ULONG outLenx13;
1693 rc = GetTLV( inLen, pIn, 0x13, &outLenx13, (const BYTE **)&pTLVx13 );
1694 if (rc == eGOBI_ERR_NONE)
1695 {
1696 if (outLenx13 < sizeof( sNASGetNetworkParametersResponse_Registration ))
1697 {
1698 return eGOBI_ERR_MALFORMED_RSP;
1699 }
1700
1701 *pRegHomeSID = pTLVx13->mRegisterOnHomeSystem;
1702 *pRegForeignSID = pTLVx13->mRegisterOnForeignSystem;
1703 *pRegForeignNID = pTLVx13->mRegisterOnForeignNetwork;
1704 }
1705
1706 // Rev. 0?
1707 const sNASGetNetworkParametersResponse_CDMA1xEVDORevision * pTLVx14;
1708 ULONG outLenx14;
1709 rc = GetTLV( inLen, pIn, 0x14, &outLenx14, (const BYTE **)&pTLVx14 );
1710 if (rc == eGOBI_ERR_NONE)
1711 {
1712 if (outLenx14 < sizeof( sNASGetNetworkParametersResponse_CDMA1xEVDORevision ))
1713 {
1714 return eGOBI_ERR_MALFORMED_RSP;
1715 }
1716
1717 *pRegHomeSID = pTLVx14->mForceCDMA1xEVDORev0;
1718 }
1719
1720 // We're lazy, so we'll just typecast all the bitmask members from
1721 // sNASGetNetworkParametersResponse_CDMA1xEVDOSCPCustom into their
1722 // respective container parameters
1723 const sEVDOCustomSCPConfig * pTLVx15;
1724 ULONG outLenx15;
1725 rc = GetTLV( inLen, pIn, 0x15, &outLenx15, (const BYTE **)&pTLVx15 );
1726 if (rc == eGOBI_ERR_NONE)
1727 {
1728 if (outLenx15 < sizeof( sEVDOCustomSCPConfig ))
1729 {
1730 return eGOBI_ERR_MALFORMED_RSP;
1731 }
1732
1733 *pCustomSCP = pTLVx15->mbActive;
1734 *pProtocol = pTLVx15->mProtocolMask;
1735 *pBroadcast = pTLVx15->mBroadcastMask;
1736 *pApplication = pTLVx15->mApplicationMask;
1737 }
1738
1739 // Roaming?
1740 const sNASGetNetworkParametersResponse_Roaming * pTLVx16;
1741 ULONG outLenx16;
1742 rc = GetTLV( inLen, pIn, 0x16, &outLenx16, (const BYTE **)&pTLVx16 );
1743 if (rc == eGOBI_ERR_NONE)
1744 {
1745 if (outLenx16 < sizeof( sNASGetNetworkParametersResponse_Roaming ))
1746 {
1747 return eGOBI_ERR_MALFORMED_RSP;
1748 }
1749
1750 *pRoaming = (eQMINASRoamingPreferences)pTLVx16->mRoamPreference;
1751 }
1752
1753 return eGOBI_ERR_NONE;
1754 }
1755
1756 /*===========================================================================
1757 METHOD:
1758 ParseGetACCOLC
1759
1760 DESCRIPTION:
1761 This function returns the Access Overload Class (ACCOLC) of the device
1762
1763 PARAMETERS:
1764 inLen [ I ] - Length of input buffer
1765 pIn [ I ] - Input buffer
1766 pACCOLC [ O ] - The ACCOLC
1767
1768 RETURN VALUE:
1769 ULONG - Return code
1770 ===========================================================================*/
1771 ULONG ParseGetACCOLC(
1772 ULONG inLen,
1773 const BYTE * pIn,
1774 BYTE * pACCOLC )
1775 {
1776 // Validate arguments
1777 if (pIn == 0 || pACCOLC == 0)
1778 {
1779 return eGOBI_ERR_INVALID_ARG;
1780 }
1781
1782 // Find the ACCOLC (mandatory)
1783 const sNASGetACCOLCResponse_ACCOLC * pTLVx01;
1784 ULONG outLenx01;
1785 ULONG rc = GetTLV( inLen, pIn, 0x01, &outLenx01, (const BYTE **)&pTLVx01 );
1786 if (rc != eGOBI_ERR_NONE)
1787 {
1788 return rc;
1789 }
1790
1791 if (outLenx01 < sizeof( sNASGetACCOLCResponse_ACCOLC ))
1792 {
1793 return eGOBI_ERR_MALFORMED_RSP;
1794 }
1795
1796 *pACCOLC = pTLVx01->mACCOLC;
1797
1798 return eGOBI_ERR_NONE;
1799 }
1800
1801 /*===========================================================================
1802 METHOD:
1803 PackSetACCOLC
1804
1805 DESCRIPTION:
1806 This function sets the Access Overload Class (ACCOLC) of the device
1807
1808 PARAMETERS:
1809 pOutLen [I/O] - Upon input the maximum number of BYTEs pOut can
1810 contain, upon output the number of BYTEs copied
1811 to pOut
1812 pOut [ O ] - Output buffer
1813 pSPC [ I ] - NULL terminated string representing the six digit
1814 service programming code
1815 accolc [ I ] - The ACCOLC
1816
1817 RETURN VALUE:
1818 ULONG - Return code
1819 ===========================================================================*/
1820 ULONG PackSetACCOLC(
1821 ULONG * pOutLen,
1822 BYTE * pOut,
1823 CHAR * pSPC,
1824 BYTE accolc )
1825 {
1826 // Validate arguments
1827 if (pOut == 0 || pSPC == 0 || pSPC[0] == 0)
1828 {
1829 return eGOBI_ERR_INVALID_ARG;
1830 }
1831
1832 std::string spc( pSPC );
1833 if (spc.size() > 6)
1834 {
1835 return eGOBI_ERR_INVALID_ARG;
1836 }
1837
1838 if (spc.find_first_not_of( "0123456789" ) != std::string::npos )
1839 {
1840 return eGOBI_ERR_INVALID_ARG;
1841 }
1842
1843 // Check size
1844 WORD tlvx01Sz = sizeof( sNASSetACCOLCRequest_ACCOLC );
1845 if (*pOutLen < sizeof( sQMIRawContentHeader ) + tlvx01Sz)
1846 {
1847 return eGOBI_ERR_BUFFER_SZ;
1848 }
1849
1850 sQMIRawContentHeader * pHeader = (sQMIRawContentHeader*)pOut;
1851 pHeader->mTypeID = 0x01;
1852 pHeader->mLength = tlvx01Sz;
1853
1854 ULONG offset = sizeof( sQMIRawContentHeader );
1855
1856 sNASSetACCOLCRequest_ACCOLC * pTLVx01;
1857 pTLVx01 = (sNASSetACCOLCRequest_ACCOLC*)(pOut + offset);
1858 memset( pTLVx01, 0, tlvx01Sz );
1859
1860 // Set the values
1861 memcpy( &pTLVx01->mSPC[0], spc.c_str(), spc.size() );
1862 pTLVx01->mACCOLC = accolc;
1863
1864 offset += tlvx01Sz;
1865 *pOutLen = offset;
1866
1867 return eGOBI_ERR_NONE;
1868 }
1869
1870 /*===========================================================================
1871 METHOD:
1872 ParseGetPLMNMode
1873
1874 DESCRIPTION:
1875 This function returns the PLMN mode from the CSP
1876
1877 PARAMETERS:
1878 inLen [ I ] - Length of input buffer
1879 pIn [ I ] - Input buffer
1880 pMode [ O ] - PLMN mode
1881
1882 RETURN VALUE:
1883 ULONG - Return code
1884 ===========================================================================*/
1885 ULONG ParseGetPLMNMode(
1886 ULONG inLen,
1887 const BYTE * pIn,
1888 ULONG * pMode )
1889 {
1890 // Validate arguments
1891 if (pIn == 0 || pMode == 0)
1892 {
1893 return eGOBI_ERR_INVALID_ARG;
1894 }
1895
1896 // Find the mode (mandatory)
1897 const sNASGetCSPPLMNModeResponse_Mode * pTLVx10;
1898 ULONG outLenx10;
1899 ULONG rc = GetTLV( inLen, pIn, 0x10, &outLenx10, (const BYTE **)&pTLVx10 );
1900 if (rc != eGOBI_ERR_NONE)
1901 {
1902 return rc;
1903 }
1904
1905 if (outLenx10 < sizeof( sNASGetCSPPLMNModeResponse_Mode ))
1906 {
1907 return eGOBI_ERR_MALFORMED_RSP;
1908 }
1909
1910 *pMode = pTLVx10->mRestrictManualPLMNSelection;
1911
1912 return eGOBI_ERR_NONE;
1913 }
1914
1915 /*===========================================================================
1916 METHOD:
1917 PackGetPLMNName
1918
1919 DESCRIPTION:
1920 This function returns PLMN name information for the given MCC/MNC
1921
1922 PARAMETERS:
1923 pOutLen [I/O] - Upon input the maximum number of BYTEs pOut can
1924 contain, upon output the number of BYTEs copied
1925 to pOut
1926 pOut [ O ] - Output buffer
1927 mcc [ I ] - Mobile country code
1928 mnc [ I ] - Mobile network code
1929
1930 RETURN VALUE:
1931 ULONG - Return code
1932 ===========================================================================*/
1933 ULONG PackGetPLMNName(
1934 ULONG * pOutLen,
1935 BYTE * pOut,
1936 USHORT mcc,
1937 USHORT mnc )
1938 {
1939 // Validate arguments
1940 if (pOut == 0)
1941 {
1942 return eGOBI_ERR_INVALID_ARG;
1943 }
1944
1945 // Check size
1946 WORD tlvx01Sz = sizeof( sNASGetPLMNNameRequest_PLMN );
1947 if (*pOutLen < sizeof( sQMIRawContentHeader ) + tlvx01Sz)
1948 {
1949 return eGOBI_ERR_BUFFER_SZ;
1950 }
1951
1952 sQMIRawContentHeader * pHeader = (sQMIRawContentHeader*)pOut;
1953 pHeader->mTypeID = 0x01;
1954 pHeader->mLength = tlvx01Sz;
1955
1956 ULONG offset = sizeof( sQMIRawContentHeader );
1957
1958 sNASGetPLMNNameRequest_PLMN * pTLVx01;
1959 pTLVx01 = (sNASGetPLMNNameRequest_PLMN*)(pOut + offset);
1960 memset( pTLVx01, 0, tlvx01Sz );
1961
1962 // Set the values
1963 pTLVx01->mMobileCountryCode = mcc;
1964 pTLVx01->mMobileNetworkCode = mnc;
1965
1966 offset += tlvx01Sz;
1967 *pOutLen = offset;
1968
1969 return eGOBI_ERR_NONE;
1970 }
1971
1972 /*===========================================================================
1973 METHOD:
1974 ParseGetPLMNName
1975
1976 DESCRIPTION:
1977 This function returns PLMN name information for the given MCC/MNC
1978
1979 PARAMETERS:
1980 inLen [ I ] - Length of input buffer
1981 pIn [ I ] - Input buffer
1982 pNamesSize [I/O] - Upon input the size in BYTEs of the name structure
1983 array. Upon success the actual number of BYTEs
1984 copied to the name structure array
1985 pNames [ O ] - The name structure array
1986
1987 RETURN VALUE:
1988 ULONG - Return code
1989 ===========================================================================*/
1990 ULONG ParseGetPLMNName(
1991 ULONG inLen,
1992 const BYTE * pIn,
1993 ULONG * pNamesSize,
1994 BYTE * pNames )
1995 {
1996 // Validate arguments
1997 if (pIn == 0 || *pNamesSize == 0 || pNames == 0)
1998 {
1999 return eGOBI_ERR_INVALID_ARG;
2000 }
2001
2002 const BYTE * pTLVx10;
2003 ULONG outLenx10;
2004 ULONG rc = GetTLV( inLen, pIn, 0x10, &outLenx10, (const BYTE **)&pTLVx10 );
2005 if (rc != eGOBI_ERR_NONE)
2006 {
2007 return rc;
2008 }
2009
2010 // The output format just happens to be the same as
2011 // sNASGetPLMNNameResponse_Name. Copy the full TLV to pNames
2012 if (outLenx10 > *pNamesSize)
2013 {
2014 return eGOBI_ERR_BUFFER_SZ;
2015 }
2016
2017 memcpy( pNames, pTLVx10, outLenx10 );
2018 *pNamesSize = outLenx10;
2019
2020 return eGOBI_ERR_NONE;
2021 }