MIH_C_F3_data_types_for_address_codec.c 8.2 KB
Newer Older
hrizi's avatar
   
hrizi committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*******************************************************************************
    OpenAirInterface 
    Copyright(c) 1999 - 2014 Eurecom

    OpenAirInterface is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.


    OpenAirInterface is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with OpenAirInterface.The full GNU General Public License is 
   included in this distribution in the file called "COPYING". If not, 
   see <http://www.gnu.org/licenses/>.

  Contact Information
  OpenAirInterface Admin: openair_admin@eurecom.fr
  OpenAirInterface Tech : openair_tech@eurecom.fr
  OpenAirInterface Dev  : openair4g-devel@eurecom.fr
  
  Address      : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE

 *******************************************************************************/

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#define MIH_C_INTERFACE
#define MIH_C_F3_DATA_TYPES_FOR_ADDRESS_CODEC_C
#include "MIH_C_F3_data_types_for_address_codec.h"

//-----------------------------------------------------------------------------
unsigned int  MIH_C_3GPP_2G_CELL_ID2String(MIH_C_3GPP_2G_CELL_ID_T *dataP, char* bufP) {
//-----------------------------------------------------------------------------
    unsigned int buffer_index = 0;
    buffer_index += sprintf(&bufP[buffer_index], "PLMN_ID = ");
    buffer_index += MIH_C_PLMN_ID2String(&dataP->plmn_id, &bufP[buffer_index]);
    buffer_index += sprintf(&bufP[buffer_index], "LAC = ");
    buffer_index += MIH_C_LAC2String(&dataP->lac, &bufP[buffer_index]);
    buffer_index += sprintf(&bufP[buffer_index], "CI = ");
    buffer_index += MIH_C_CI2String(&dataP->ci, &bufP[buffer_index]);
    return buffer_index;
}
//-----------------------------------------------------------------------------
47
void MIH_C_3GPP_2G_CELL_ID_encode(Bit_Buffer_t* bbP, MIH_C_3GPP_2G_CELL_ID_T *dataP) {
48
49
50
51
52
53
//-----------------------------------------------------------------------------
    MIH_C_PLMN_ID_encode(bbP, &dataP->plmn_id);
    MIH_C_LAC_encode(bbP, &dataP->lac);
    MIH_C_CI_encode(bbP, &dataP->ci);
}
//-----------------------------------------------------------------------------
54
void MIH_C_3GPP_2G_CELL_ID_decode(Bit_Buffer_t* bbP, MIH_C_3GPP_2G_CELL_ID_T *dataP) {
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//-----------------------------------------------------------------------------
    MIH_C_PLMN_ID_decode(bbP, &dataP->plmn_id);
    MIH_C_LAC_decode(bbP, &dataP->lac);
    MIH_C_CI_decode(bbP, &dataP->ci);
}
//-----------------------------------------------------------------------------
unsigned int  MIH_C_3GPP_3G_CELL_ID2String(MIH_C_3GPP_3G_CELL_ID_T *dataP, char* bufP) {
//-----------------------------------------------------------------------------
    unsigned int buffer_index = 0;
    buffer_index += MIH_C_PLMN_ID2String(&dataP->plmn_id, &bufP[buffer_index]);
    buffer_index += MIH_C_CELL_ID2String(&dataP->cell_id, &bufP[buffer_index]);
    return buffer_index;
}
//-----------------------------------------------------------------------------
69
void MIH_C_3GPP_3G_CELL_ID_encode(Bit_Buffer_t* bbP, MIH_C_3GPP_3G_CELL_ID_T *dataP) {
70
71
72
73
74
//-----------------------------------------------------------------------------
    MIH_C_PLMN_ID_encode(bbP, &dataP->plmn_id);
    MIH_C_CELL_ID_encode(bbP, &dataP->cell_id);
}
//-----------------------------------------------------------------------------
75
void MIH_C_3GPP_3G_CELL_ID_decode(Bit_Buffer_t* bbP, MIH_C_3GPP_3G_CELL_ID_T *dataP) {
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//-----------------------------------------------------------------------------
    MIH_C_PLMN_ID_decode(bbP, &dataP->plmn_id);
    MIH_C_CELL_ID_decode(bbP, &dataP->cell_id);
}
//-----------------------------------------------------------------------------
unsigned int MIH_C_LINK_ADDR2String(MIH_C_LINK_ADDR_T *dataP, char* bufP) {
//-----------------------------------------------------------------------------
    unsigned int buffer_index = 0;
    switch (dataP->choice) {
        case MIH_C_CHOICE_MAC_ADDR:
            buffer_index += sprintf(&bufP[buffer_index], "MAC_ADDR = ");
            buffer_index += MIH_C_MAC_ADDR2String(&dataP->_union.mac_addr, &bufP[buffer_index]);
            break;
        case MIH_C_CHOICE_3GPP_3G_CELL_ID:
            buffer_index += sprintf(&bufP[buffer_index], "3GPP_3G_CELL_ID = ");
            buffer_index = MIH_C_3GPP_3G_CELL_ID2String(&dataP->_union._3gpp_3g_cell_id, &bufP[buffer_index]);
            break;
        case MIH_C_CHOICE_3GPP_2G_CELL_ID:
            buffer_index += sprintf(&bufP[buffer_index], "3GPP_2G_CELL_ID = ");
            buffer_index = MIH_C_3GPP_2G_CELL_ID2String(&dataP->_union._3gpp_2g_cell_id, &bufP[buffer_index]);
            break;
        case MIH_C_CHOICE_3GPP_ADDR:
            buffer_index += sprintf(&bufP[buffer_index], "3GPP_ADDR = ");
            buffer_index = MIH_C_3GPP_ADDR2String(&dataP->_union._3gpp_addr, &bufP[buffer_index]);
            break;
        case MIH_C_CHOICE_3GPP2_ADDR:
            buffer_index += sprintf(&bufP[buffer_index], "3GPP2_ADDR = ");
            buffer_index = MIH_C_3GPP2_ADDR2String(&dataP->_union._3gpp2_addr, &bufP[buffer_index]);
            break;
        case MIH_C_CHOICE_OTHER_L2_ADDR:
            buffer_index += sprintf(&bufP[buffer_index], "OTHER_L2_ADDR = ");
            buffer_index = MIH_C_OTHER_L2_ADDR2String(&dataP->_union.other_l2_addr, &bufP[buffer_index]);
            break;
        default:
            buffer_index = sprintf(&bufP[buffer_index], "UNINITIALIZED ADDR");
    }
    return buffer_index;
}
//-----------------------------------------------------------------------------
115
void MIH_C_LINK_ADDR_encode(Bit_Buffer_t* bbP, MIH_C_LINK_ADDR_T *dataP) {
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
//-----------------------------------------------------------------------------
    MIH_C_CHOICE_encode(bbP, &dataP->choice);
    switch (dataP->choice) {
        case MIH_C_CHOICE_MAC_ADDR:
            MIH_C_MAC_ADDR_encode(bbP, &dataP->_union.mac_addr);
            break;
        case MIH_C_CHOICE_3GPP_3G_CELL_ID:
            MIH_C_3GPP_3G_CELL_ID_encode(bbP, &dataP->_union._3gpp_3g_cell_id);
            break;
        case MIH_C_CHOICE_3GPP_2G_CELL_ID:
            MIH_C_3GPP_2G_CELL_ID_encode(bbP, &dataP->_union._3gpp_2g_cell_id);
            break;
        case MIH_C_CHOICE_3GPP_ADDR:
            MIH_C_3GPP_ADDR_encode(bbP, &dataP->_union._3gpp_addr);
            break;
        case MIH_C_CHOICE_3GPP2_ADDR:
            MIH_C_3GPP2_ADDR_encode(bbP, &dataP->_union._3gpp2_addr);
            break;
        case MIH_C_CHOICE_OTHER_L2_ADDR:
            MIH_C_OTHER_L2_ADDR_encode(bbP, &dataP->_union.other_l2_addr);
            break;
        default:
138
            printf("[MIH_C] ERROR NO KNOWN VALUE FOR ENCODING CHOICE OF MIH_C_LINK_ADDR_T %d\n", dataP->choice);
139
140
141
    }
}
//-----------------------------------------------------------------------------
142
void MIH_C_LINK_ADDR_decode(Bit_Buffer_t* bbP, MIH_C_LINK_ADDR_T *dataP) {
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
//-----------------------------------------------------------------------------
    MIH_C_CHOICE_decode(bbP, &dataP->choice);
    switch (dataP->choice) {
        case MIH_C_CHOICE_MAC_ADDR:
            MIH_C_MAC_ADDR_decode(bbP, &dataP->_union.mac_addr);
            break;
        case MIH_C_CHOICE_3GPP_3G_CELL_ID:
            MIH_C_3GPP_3G_CELL_ID_decode(bbP, &dataP->_union._3gpp_3g_cell_id);
            break;
        case MIH_C_CHOICE_3GPP_2G_CELL_ID:
            MIH_C_3GPP_2G_CELL_ID_decode(bbP, &dataP->_union._3gpp_2g_cell_id);
            break;
        case MIH_C_CHOICE_3GPP_ADDR:
            MIH_C_3GPP_ADDR_decode(bbP, &dataP->_union._3gpp_addr);
            break;
        case MIH_C_CHOICE_3GPP2_ADDR:
            MIH_C_3GPP2_ADDR_decode(bbP, &dataP->_union._3gpp2_addr);
            break;
        case MIH_C_CHOICE_OTHER_L2_ADDR:
            MIH_C_OTHER_L2_ADDR_decode(bbP, &dataP->_union.other_l2_addr);
            break;
        default:
165
            printf("[MIH_C] ERROR NO KNOWN VALUE FOR DECODING CHOICE OF MIH_C_LINK_ADDR_T %d\n", dataP->choice);
166
167
168
169
170
171
    }
}