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
20#include "absl/strings/string_view.h"
21
22namespace cuttlefish {
23
24class PDUParser {
25 public:
26 explicit PDUParser(std::string &pdu);
27 ~PDUParser() = default;
28
29 bool IsValidPDU();
31 std::string CreatePDU();
32 std::string CreateRemotePDU(std::string& host_port);
33 std::string CreateStatuReport(int message_reference);
34 std::string GetPhoneNumberFromAddress();
35
36 static std::string BCDToString(std::string& data);
37 static std::string StringToBCD(absl::string_view data);
38
39 private:
40 bool DecodePDU(std::string& pdu);
41 int Hex2ToByte(const std::string& hex);
42 int HexCharToInt(char c);
43 std::string IntToHexString(int value);
44
45 // special handling for time zone difference (to GMT)
46 std::string IntToHexStringTimeZoneDiff(int tzdiff_hour);
47 std::string GetCurrentTimeStamp();
48
50
51 // Ignore SMSC address, default to be "00" when create PDU
52 std::string pdu_type_;
53 std::string message_reference_;
55 std::string protocol_id_;
56 std::string data_code_scheme_;
57 std::string user_data_;
58};
59
60} // namespace cuttlefish
Definition: pdu_parser.h:24
bool is_valid_pdu_
Definition: pdu_parser.h:49
bool DecodePDU(std::string &pdu)
Definition: pdu_parser.cpp:50
std::string IntToHexStringTimeZoneDiff(int tzdiff_hour)
Definition: pdu_parser.cpp:263
std::string CreatePDU()
Definition: pdu_parser.cpp:124
std::string GetPhoneNumberFromAddress()
Definition: pdu_parser.cpp:212
std::string CreateRemotePDU(std::string &host_port)
Definition: pdu_parser.cpp:186
std::string IntToHexString(int value)
Definition: pdu_parser.cpp:257
std::string data_code_scheme_
Definition: pdu_parser.h:56
int Hex2ToByte(const std::string &hex)
Definition: pdu_parser.cpp:242
std::string pdu_type_
Definition: pdu_parser.h:52
std::string message_reference_
Definition: pdu_parser.h:53
std::string user_data_
Definition: pdu_parser.h:57
static std::string StringToBCD(absl::string_view data)
Definition: pdu_parser.cpp:300
static std::string BCDToString(std::string &data)
Definition: pdu_parser.cpp:279
bool IsNeededStatuReport()
Definition: pdu_parser.cpp:152
std::string GetCurrentTimeStamp()
Definition: pdu_parser.cpp:317
std::string CreateStatuReport(int message_reference)
Definition: pdu_parser.cpp:165
std::string originator_address_
Definition: pdu_parser.h:54
bool IsValidPDU()
Definition: pdu_parser.cpp:39
PDUParser(std::string &pdu)
Definition: pdu_parser.cpp:35
int HexCharToInt(char c)
Definition: pdu_parser.cpp:228
std::string protocol_id_
Definition: pdu_parser.h:55
char data[Size]
Definition: incremental_server.cpp:1
Definition: alloc_driver.h:21