lpdu.cpp
1 /* 2 EIBD eib bus access and management daemon 3 Copyright (C) 2005-2011 Martin Koegler <mkoegler@auto.tuwien.ac.at> 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 */ 19 20 #include "lpdu.h" 21 22 #include <cstdio> 23 24 #include "cm_tp1.h" 25 #include "tpdu.h" 26 27 /* L_Data */ 28 29 std::string L_Data_PDU::Decode (TracePtr tr) const 30 { 31 assert (lsdu.size() >= 1); 32 assert (lsdu.size() <= 0xff); 33 assert ((hop_count & 0xf8) == 0); 34 35 std::string s ("L_Data"); 36 if (!valid_length) 37 s += " (incomplete)"; 38 if (repeated) 39 s += " (repeated)"; 40 switch (priority) 41 { 42 case PRIO_SYSTEM: 43 s += " system"; 44 break; 45 case PRIO_URGENT: 46 s += " urgent"; 47 break; 48 case PRIO_NORMAL: 49 s += " normal"; 50 break; 51 case PRIO_LOW: 52 s += " low"; 53 break; 54 } 55 if (!valid_checksum) 56 s += " INVALID CHECKSUM"; 57 s += " from "; 58 s += FormatEIBAddr (source_address); 59 s += " to "; 60 s += (address_type == GroupAddress ? 61 FormatGroupAddr (destination_address) : 62 FormatEIBAddr (destination_address)); 63 s += " hops: "; 64 addHex (s, hop_count); 65 TPDUPtr d = TPDU::fromPacket (address_type, destination_address, lsdu, tr); 66 s += d->Decode (tr); 67 return s; 68 } 69 70 /* L_SystemBroadcast */ 71 72 std::string L_SystemBroadcast_PDU::Decode (TracePtr) const 73 { 74 std::string s ("L_SystemBroadcast"); 75 // @todo 76 return s; 77 } 78 79 /* L_Poll_Data */ 80 81 std::string L_Poll_Data_PDU::Decode (TracePtr) const 82 { 83 std::string s ("L_Poll_Data"); 84 // @todo 85 return s; 86 } 87 88 /* L_Poll_Update */ 89 90 std::string L_Poll_Update_PDU::Decode (TracePtr) const 91 { 92 std::string s ("L_Poll_Update"); 93 // @todo 94 return s; 95 } 96 97 /* L_Busmon */ 98 99 L_Busmon_PDU::L_Busmon_PDU () : LPDU() 100 { 101 struct timeval tv; 102 gettimeofday(&tv,NULL); 103 time_stamp = tv.tv_sec*65536 + tv.tv_usec/(1000000/65536+1); 104 l_status = 0; 105 } 106 107 std::string 108 L_Busmon_PDU::Decode (TracePtr tr) const 109 { 110 std::string s ("L_Busmon: "); 111 112 if (lpdu.size() == 0) 113 return "empty LPDU"; 114 115 C_ITER (i,lpdu) 116 addHex (s, *i); 117 s += ":"; 118 LDataPtr l = CM_TP1_to_L_Data (lpdu, tr); 119 s += l->Decode (tr); 120 return s; 121 } 122 123 /* L_Service_Information */ 124 125 std::string L_Service_Information_PDU::Decode (TracePtr) const 126 { 127 std::string s ("L_Service_Information"); 128 // @todo 129 return s; 130 } 131 132 /* L_Management */ 133 134 std::string L_Management_PDU::Decode (TracePtr) const 135 { 136 std::string s ("L_Management"); 137 // @todo 138 return s; 139 }