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 namespace cuttlefish { 21 22 class PDUParser { 23 public: 24 explicit PDUParser(std::string &pdu); 25 ~PDUParser() = default; 26 27 bool IsValidPDU(); 28 bool IsNeededStatuReport(); 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 value); 45 std::string GetCurrentTimeStamp(); 46 47 bool is_valid_pdu_; 48 49 // Ignore SMSC address, default to be "00" when create PDU 50 std::string pdu_type_; 51 std::string message_reference_; 52 std::string originator_address_; 53 std::string protocol_id_; 54 std::string data_code_scheme_; 55 std::string user_data_; 56 }; 57 58 } // namespace cuttlefish 59