Android-cuttlefish cvd tool
pdu_parser.h
Go to the documentation of this file.
1//
2// Copyright (C) 2020 The Android Open Source Project
3//
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
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
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.
15
16#pragma once
17
18#include <string>
19
20namespace cuttlefish {
21
22class PDUParser {
23 public:
24 explicit PDUParser(std::string &pdu);
25 ~PDUParser() = default;
26
27 bool IsValidPDU();
29 std::string CreatePDU();
30 std::string CreateRemotePDU(std::string& host_port);
31 std::string CreateStatuReport(int message_reference);
32 std::string GetPhoneNumberFromAddress();
33
34 static std::string BCDToString(std::string& data);
35 static std::string StringToBCD(std::string_view data);
36
37 private:
38 bool DecodePDU(std::string& pdu);
39 int Hex2ToByte(const std::string& hex);
40 int HexCharToInt(char c);
41 std::string IntToHexString(int value);
42
43 // special handling for time zone difference (to GMT)
44 std::string IntToHexStringTimeZoneDiff(int tzdiff_hour);
45 std::string GetCurrentTimeStamp();
46
48
49 // Ignore SMSC address, default to be "00" when create PDU
50 std::string pdu_type_;
51 std::string message_reference_;
53 std::string protocol_id_;
54 std::string data_code_scheme_;
55 std::string user_data_;
56};
57
58} // namespace cuttlefish
Definition: pdu_parser.h:22
bool is_valid_pdu_
Definition: pdu_parser.h:47
bool DecodePDU(std::string &pdu)
Definition: pdu_parser.cpp:47
std::string IntToHexStringTimeZoneDiff(int tzdiff_hour)
Definition: pdu_parser.cpp:256
std::string CreatePDU()
Definition: pdu_parser.cpp:121
std::string GetPhoneNumberFromAddress()
Definition: pdu_parser.cpp:209
std::string CreateRemotePDU(std::string &host_port)
Definition: pdu_parser.cpp:183
std::string IntToHexString(int value)
Definition: pdu_parser.cpp:250
std::string data_code_scheme_
Definition: pdu_parser.h:54
int Hex2ToByte(const std::string &hex)
Definition: pdu_parser.cpp:239
static std::string StringToBCD(std::string_view data)
Definition: pdu_parser.cpp:293
std::string pdu_type_
Definition: pdu_parser.h:50
std::string message_reference_
Definition: pdu_parser.h:51
std::string user_data_
Definition: pdu_parser.h:55
static std::string BCDToString(std::string &data)
Definition: pdu_parser.cpp:272
bool IsNeededStatuReport()
Definition: pdu_parser.cpp:149
std::string GetCurrentTimeStamp()
Definition: pdu_parser.cpp:310
std::string CreateStatuReport(int message_reference)
Definition: pdu_parser.cpp:162
std::string originator_address_
Definition: pdu_parser.h:52
bool IsValidPDU()
Definition: pdu_parser.cpp:36
PDUParser(std::string &pdu)
Definition: pdu_parser.cpp:32
int HexCharToInt(char c)
Definition: pdu_parser.cpp:225
std::string protocol_id_
Definition: pdu_parser.h:53
char data[Size]
Definition: incremental_server.cpp:1
Definition: alloc_utils.cpp:23