summaryrefslogtreecommitdiffstats
path: root/veslibrary/ves_cpplibrary/src/lib/encode/XMobileFlowFieldsImp.cpp
blob: 8889db9273354db65df47c1eadb10ad5372d03ed (plain)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#include "XMobileFlowFieldsImp.h"

const std::string XEnumMobileFlowFieldsMobileFlowFieldsVersionMapping[] = {
    "4.0"
};

XMobileFlowFieldsImp::XMobileFlowFieldsImp(std::shared_ptr<XCommonEventHeader> header,
                const XString& flowDirection,
                const XGtpPerFlowMetrics& gtpPerFlowMetrics,
                const XString& ipProtocolType,
                const XString& ipVersion,
                const XString& otherEndpointIpAddress,
                XInteger otherEndpointPort,
                const XString& reportingEndpointIpAddr,
                XInteger reportingEndpointPort
    ):
        header_(header),
        flowDirection_(flowDirection),
        gtpPerFlowMetrics_(gtpPerFlowMetrics),
        ipProtocolType_(ipProtocolType),
        ipVersion_(ipVersion),
        mobileFlowFieldsVersion_(XEnumMobileFlowFieldsMobileFlowFieldsVersion4_0),
        otherEndpointIpAddress_(otherEndpointIpAddress),
        otherEndpointPort_(otherEndpointPort),
        reportingEndpointIpAddr_(reportingEndpointIpAddr),
        reportingEndpointPort_(reportingEndpointPort)
{

}

std::string XMobileFlowFieldsImp::toString()
{
    try
    {
        auto js = toJson();
        return js.dump();
    }
    catch (json::exception& e)
    {
        SPDLOG_ERROR("Fail to dump XMobileFlowFields to json string:{}.", e.what());
        return "";
    }
}

void XMobileFlowFieldsImp::setRac(const XString& rac)
{
    comVals_["rac"] = rac;
}
            
void XMobileFlowFieldsImp::setSac(const XString& sac)
{
    comVals_["sac"] = sac;
}
            
void XMobileFlowFieldsImp::setSamplingAlgorithm(XInteger samplingAlgorithm)
{
    comVals_["samplingAlgorithm"] = samplingAlgorithm;
}
            
void XMobileFlowFieldsImp::setIpVersion(const XString& ipVersion)
{
    comVals_["ipVersion"] = ipVersion;
}
            
void XMobileFlowFieldsImp::setGtpPerFlowMetrics(const XGtpPerFlowMetrics& gtpPerFlowMetrics)
{
    gtpPerFlowMetrics_ = gtpPerFlowMetrics;
}
            
void XMobileFlowFieldsImp::setTac(const XString& tac)
{
    comVals_["tac"] = tac;
}
            
void XMobileFlowFieldsImp::setMnc(const XString& mnc)
{
    comVals_["mnc"] = mnc;
}
            
void XMobileFlowFieldsImp::setTunnelId(const XString& tunnelId)
{
    comVals_["tunnelId"] = tunnelId;
}
            
void XMobileFlowFieldsImp::setAppProtocolVersion(const XString& appProtocolVersion)
{
    comVals_["appProtocolVersion"] = appProtocolVersion;
}
            
void XMobileFlowFieldsImp::setGtpVersion(const XString& gtpVersion)
{
    comVals_["gtpVersion"] = gtpVersion;
}
            
void XMobileFlowFieldsImp::setConnectionType(const XString& connectionType)
{
    comVals_["connectionType"] = connectionType;
}
            
void XMobileFlowFieldsImp::setAdditionalFields(const XHashMap& additionalFields)
{
    additionalFields_ = additionalFields;
}
            
void XMobileFlowFieldsImp::setHttpHeader(const XString& httpHeader)
{
    comVals_["httpHeader"] = httpHeader;
}
            
void XMobileFlowFieldsImp::setImsi(const XString& imsi)
{
    comVals_["imsi"] = imsi;
}
            
void XMobileFlowFieldsImp::setApplicationType(const XString& applicationType)
{
    comVals_["applicationType"] = applicationType;
}
            
void XMobileFlowFieldsImp::setMsisdn(const XString& msisdn)
{
    comVals_["msisdn"] = msisdn;
}
            
void XMobileFlowFieldsImp::setMcc(const XString& mcc)
{
    comVals_["mcc"] = mcc;
}
            
void XMobileFlowFieldsImp::setFlowDirection(const XString& flowDirection)
{
    comVals_["flowDirection"] = flowDirection;
}
            
void XMobileFlowFieldsImp::setLac(const XString& lac)
{
    comVals_["lac"] = lac;
}
            
void XMobileFlowFieldsImp::setOtherEndpointPort(XInteger otherEndpointPort)
{
    comVals_["otherEndpointPort"] = otherEndpointPort;
}
            
void XMobileFlowFieldsImp::setVlanId(const XString& vlanId)
{
    comVals_["vlanId"] = vlanId;
}
            
void XMobileFlowFieldsImp::setImei(const XString& imei)
{
    comVals_["imei"] = imei;
}
            
void XMobileFlowFieldsImp::setGtpProtocolType(const XString& gtpProtocolType)
{
    comVals_["gtpProtocolType"] = gtpProtocolType;
}
            
void XMobileFlowFieldsImp::setEcgi(const XString& ecgi)
{
    comVals_["ecgi"] = ecgi;
}
            
void XMobileFlowFieldsImp::setCid(const XString& cid)
{
    comVals_["cid"] = cid;
}
            
void XMobileFlowFieldsImp::setReportingEndpointPort(XInteger reportingEndpointPort)
{
    comVals_["reportingEndpointPort"] = reportingEndpointPort;
}
            
void XMobileFlowFieldsImp::setRadioAccessTechnology(const XString& radioAccessTechnology)
{
    comVals_["radioAccessTechnology"] = radioAccessTechnology;
}
            
void XMobileFlowFieldsImp::setAppProtocolType(const XString& appProtocolType)
{
    comVals_["appProtocolType"] = appProtocolType;
}
            
void XMobileFlowFieldsImp::setOtherEndpointIpAddress(const XString& otherEndpointIpAddress)
{
    comVals_["otherEndpointIpAddress"] = otherEndpointIpAddress;
}
            
void XMobileFlowFieldsImp::setIpProtocolType(const XString& ipProtocolType)
{
    comVals_["ipProtocolType"] = ipProtocolType;
}
            
void XMobileFlowFieldsImp::setOtherFunctionalRole(const XString& otherFunctionalRole)
{
    comVals_["otherFunctionalRole"] = otherFunctionalRole;
}
            
void XMobileFlowFieldsImp::setReportingEndpointIpAddr(const XString& reportingEndpointIpAddr)
{
    comVals_["reportingEndpointIpAddr"] = reportingEndpointIpAddr;
}

json XMobileFlowFieldsImp::toJson()
{
    try
    {
        json field = {
            {"ipVersion", ipVersion_},
            {"mobileFlowFieldsVersion", XEnumMobileFlowFieldsMobileFlowFieldsVersionMapping[mobileFlowFieldsVersion_]},
            {"gtpPerFlowMetrics", dynamic_pointer_cast<XJsonable>(gtpPerFlowMetrics_.imp_)->toJson()},
            {"flowDirection", flowDirection_},
            {"otherEndpointPort", otherEndpointPort_},
            {"reportingEndpointPort", reportingEndpointPort_},
            {"otherEndpointIpAddress", otherEndpointIpAddress_},
            {"ipProtocolType", ipProtocolType_},
            {"reportingEndpointIpAddr", reportingEndpointIpAddr_}
        };

        //optional val
        if (!additionalFields_.empty())
        {
            field["additionalFields"] = additionalFields_;
        }
        field = mergeCommonValues(field, comVals_);

        json jsEvent;
        header_->setDomain(XEnumCommonEventHeaderDomainMobileFlow);
        jsEvent["event"]["commonEventHeader"] = dynamic_pointer_cast<XJsonable>(header_)->toJson();
        jsEvent["event"]["mobileFlowFields"] = field;

        return jsEvent;
    }
    catch (json::exception& e)
    {
        SPDLOG_ERROR("Fail to build XMobileFlowFields to json object:{}.", e.what());
        return json();
    }
}

std::shared_ptr<XCommonEventHeader> XMobileFlowFieldsImp::getCommonHeader()
{
    return header_;
}