2 ==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 ==================================================================================
22 //-----------------------------------------------------------------------------
24 // MCC 3 digits MNC 2 digits
25 // BCD Coded format: 0xC2C1 0xfC3 0xN2N1
26 // String format : C1C2C3N1N2
28 // MCC 3 digits MNC 3 digits
29 // BCD Coded format: 0xC2C1 0xN3C3 0xN2N1
30 // String format : C1C2C3N1N2N3
32 //-----------------------------------------------------------------------------
34 type PlmnIdentity struct {
38 func (plmnid *PlmnIdentity) String() string {
39 bcd := NewBcd("0123456789?????f")
41 str := bcd.Decode(plmnid.Val[:])
44 return string(str[0:3]) + string(str[4:])
46 return string(str[0:3]) + string(str[4:]) + string(str[3])
49 func (plmnid *PlmnIdentity) MccString() string {
50 fullstr := plmnid.String()
51 return string(fullstr[0:3])
54 func (plmnid *PlmnIdentity) MncString() string {
55 fullstr := plmnid.String()
56 return string(fullstr[3:])
59 func (plmnid *PlmnIdentity) StringPut(str string) bool {
67 tmpStr = string(str[0:3]) + string("f") + string(str[3:])
69 //C1 C2 C3 N1 N2 N3 -->
71 tmpStr = string(str[0:3]) + string(str[5]) + string(str[3:5])
76 bcd := NewBcd("0123456789?????f")
77 buf := bcd.Encode(tmpStr)
83 return plmnid.BcdPut(buf)
86 func (plmnid *PlmnIdentity) BcdPut(val []uint8) bool {
91 for i := 0; i < 3; i++ {
92 plmnid.Val[i] = val[i]