/[projects]/smsdaemon/SmsPdu.cpp
ViewVC logotype

Diff of /smsdaemon/SmsPdu.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 69 by torben, Fri Jun 13 06:38:43 2008 UTC revision 70 by torben, Fri Jun 13 07:56:57 2008 UTC
# Line 78  namespace SmsPdu Line 78  namespace SmsPdu
78                  return vec;                  return vec;
79          }          }
80    
81          std::string Decode8to7bit(vector<unsigned char> input)          std::string Decode8to7bit(vector<unsigned char> input, int shift_start = 0)
82          {          {
83                  string result;                  string result;
84    
85                  int shift = 0;                  int shift = shift_start;
86                  for (unsigned int i=0; i<input.size(); ++i)                  for (unsigned int i=0; i<input.size(); ++i)
87                  {                  {
88                          unsigned char current = input.at(i);                          unsigned char current = input.at(i);
# Line 284  namespace SmsPdu Line 284  namespace SmsPdu
284                  it += (*it++); // Skip smsc info                  it += (*it++); // Skip smsc info
285    
286                  unsigned char deliver_first_octet = (*it++);                  unsigned char deliver_first_octet = (*it++);
287    
288                    bool UDHI = (deliver_first_octet & 0x40) > 0;
289    
290                  unsigned char sender_len = (*it++);                  unsigned char sender_len = (*it++);
291                  if ( (sender_len % 2) == 1)                  if ( (sender_len % 2) == 1)
292                          sender_len++;                          sender_len++;
# Line 299  namespace SmsPdu Line 302  namespace SmsPdu
302                  result.timestamp = DecodeTimestamp(it, it+7);                  result.timestamp = DecodeTimestamp(it, it+7);
303                  it += 7;                  it += 7;
304    
305    
306                  unsigned char data_len = (*it++);                  unsigned char data_len = (*it++);
307    
308                    int shift_start = 0;
309                    if (UDHI)
310                    {
311                            int udh_len = (*it++);
312                            cout << "UDH_LEN:" << udh_len << endl;
313                            it += udh_len; //just ignore the User Data Header
314                            data_len -= udh_len;
315    
316                            shift_start = udh_len+1; //make the 8to7bit decode start with the right shift level
317                    }
318                    cout << hex<< (int)(*it) << endl;;
319    
320    
321                  vector<unsigned char> user_data;                  vector<unsigned char> user_data;
322                  user_data.insert(user_data.end(), it, it+data_len);                  user_data.insert(user_data.end(), it, it+data_len);
323                                    
324                  result.message = Decode8to7bit(user_data);                  result.message = Decode8to7bit(user_data, shift_start);
325                                    
326    
327                  return result;                  return result;

Legend:
Removed from v.69  
changed lines
  Added in v.70

  ViewVC Help
Powered by ViewVC 1.1.20