This file is indexed.

/usr/include/gsmlib/gsm_sms.h is in libgsmme-dev 1.10+20120414.gita5e5ae9a-0.2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
// *************************************************************************
// * GSM TA/ME library
// *
// * File:    gsm_sms.h
// *
// * Purpose: SMS functions
// *          (ETSI GSM 07.05)
// *
// * Author:  Peter Hofmann (software@pxh.de)
// *
// * Created: 16.5.1999
// *************************************************************************

#ifndef GSM_SMS_H
#define GSM_SMS_H

#include <gsmlib/gsm_sms_codec.h>
#include <gsmlib/gsm_error.h>
#include <gsmlib/gsm_util.h>
#include <gsmlib/gsm_at.h>
#include <string>
#include <vector>

namespace gsmlib
{
  // forward declarations
  class SMSStore;
  class SMSMessage;

  // this class represents a single SMS message
  class SMSMessage : public RefBase
  {
  private:
    Ref<GsmAt> _at;             // connection to the device

  public:
    // possible values for message type indicator
    enum MessageType {SMS_DELIVER = 0, SMS_DELIVER_REPORT = 0,
                      SMS_STATUS_REPORT = 2, SMS_COMMAND = 2,
                      SMS_SUBMIT = 1, SMS_SUBMIT_REPORT = 1};

  protected:
    // fields of the different TPDUs
    // all PDUs
    std::string _userData;
    UserDataHeader _userDataHeader;
    Address _serviceCentreAddress;
    MessageType _messageTypeIndicator;// 2 bits
    DataCodingScheme _dataCodingScheme;

  public:
    // decode hexadecimal pdu string
    // return SMSMessage of the appropriate type
    // differentiate between SMS transfer directions SC to ME, ME to SC
    // also give GsmAt object for send()
    static Ref<SMSMessage> decode(std::string pdu,
                                  bool SCtoMEdirection = true,
                                  GsmAt *at = NULL)
      throw(GsmException);

    static Ref<SMSMessage> decode(std::istream& s) throw(GsmException);

    // encode pdu, return hexadecimal pdu string
    virtual std::string encode() = 0;

    // send this PDU
    // returns message reference and ACK-PDU (if requested)
    // only applicate to SMS-SUBMIT and SMS-COMMAND
    unsigned char send(Ref<SMSMessage> &ackPdu) throw(GsmException);
    
    // same as above, but ACK-PDU is discarded
    unsigned char send() throw(GsmException);

    // create textual representation of SMS
    virtual std::string toString() const = 0;

    // return deep copy of this message
    virtual Ref<SMSMessage> clone() = 0;

    // return length of SC address when encoded
    unsigned int getSCAddressLen();

    // accessor functions
    MessageType messageType() const {return _messageTypeIndicator;}
    Address serviceCentreAddress() const {return _serviceCentreAddress;}

    // provided for sorting messages by timestamp
    virtual Timestamp serviceCentreTimestamp() const {return Timestamp();}
    
    // return recipient, destination etc. address (for sorting by address)
    virtual Address address() const = 0;

    virtual void setUserData(std::string x) {_userData = x;}
    virtual std::string userData() const {return _userData;}
    
    // return the size of user data (including user data header)
    unsigned char userDataLength() const;

    // accessor functions
    virtual void setUserDataHeader(UserDataHeader x) {_userDataHeader = x;}
    virtual UserDataHeader userDataHeader() const {return _userDataHeader;}
    
    virtual DataCodingScheme dataCodingScheme() const
      {return _dataCodingScheme;}
    virtual void setDataCodingScheme(DataCodingScheme x)
      {_dataCodingScheme = x;}

    void setServiceCentreAddress(Address &x) {_serviceCentreAddress = x;}
    void setAt(Ref<GsmAt> at) {_at = at;}

    virtual ~SMSMessage();

    // print ASCII hex representation of message
    std::ostream& operator<<(std::ostream& s);

    // copy constructor and assignment
//     SMSMessage(SMSMessage &m);
//     SMSMessage &operator=(SMSMessage &m);

    friend class SMSStore;
  };

  // SMS-DELIVER TPDU
  class SMSDeliverMessage : public SMSMessage
  {
  private:
    // SMS-DELIVER PDU members (see GSM 03.40 section 9.2.2.1)
    bool _moreMessagesToSend;
    bool _replyPath;
    bool _statusReportIndication;
    Address _originatingAddress;
    unsigned char _protocolIdentifier; // octet
    Timestamp _serviceCentreTimestamp;

    // initialize members to sensible values
    void init();
    
  public:
    // constructor, sets sensible default values
    SMSDeliverMessage();

    // constructor with given pdu
    SMSDeliverMessage(std::string pdu) throw(GsmException);

    // encode pdu, return hexadecimal pdu string
    virtual std::string encode();

    // create textual representation of SMS
    virtual std::string toString() const;

    // inherited from SMSMessage
    Address address() const;
    Ref<SMSMessage> clone();

    // accessor functions
    bool moreMessagesToSend() const {return _moreMessagesToSend;}
    bool replyPath() const {return _replyPath;}
    bool statusReportIndication() const {return _statusReportIndication;}
    Address originatingAddress() const {return _originatingAddress;}
    unsigned char protocolIdentifier() const {return _protocolIdentifier;}
    Timestamp serviceCentreTimestamp() const {return _serviceCentreTimestamp;}

    void setMoreMessagesToSend(bool x) {_moreMessagesToSend = x;}
    void setReplyPath(bool x) {_replyPath = x;}
    void setStatusReportIndication(bool x) {_statusReportIndication = x;}
    void setOriginatingAddress(Address &x) {_originatingAddress = x;}
    void setProtocolIdentifier(unsigned char x) {_protocolIdentifier = x;}
    void setServiceCentreTimestamp(Timestamp &x) {_serviceCentreTimestamp = x;}

    virtual ~SMSDeliverMessage() {}
  };

  // SMS-SUBMIT TPDU
  class SMSSubmitMessage : public SMSMessage
  {
  private:
    // SMS-SUBMIT PDU (see GSM 03.40 section 9.2.2.2)
    bool _rejectDuplicates;
    TimePeriod::Format _validityPeriodFormat; // 2 bits
    bool _replyPath;
    bool _statusReportRequest;
    unsigned char _messageReference; // integer
    Address _destinationAddress;
    unsigned char _protocolIdentifier;
    TimePeriod _validityPeriod;

    // initialize members to sensible values
    void init();
    
  public:
    // constructor, sets sensible default values
    SMSSubmitMessage();

    // constructor with given pdu
    SMSSubmitMessage(std::string pdu) throw(GsmException);

    // convenience constructor
    // given the text and recipient telephone number
    SMSSubmitMessage(std::string text, std::string number);

    // encode pdu, return hexadecimal pdu string
    virtual std::string encode();

    // create textual representation of SMS
    virtual std::string toString() const;

    // inherited from SMSMessage
    Address address() const;
    Ref<SMSMessage> clone();

    // accessor functions
    bool rejectDuplicates() const {return _rejectDuplicates;}
    TimePeriod::Format validityPeriodFormat() const
      {return _validityPeriodFormat;}
    bool replyPath() const {return _replyPath;}
    bool statusReportRequest() const {return _statusReportRequest;}
    unsigned char messageReference() const {return _messageReference;}
    Address destinationAddress() const {return _destinationAddress;}
    unsigned char protocolIdentifier() const {return _protocolIdentifier;}
    TimePeriod validityPeriod() const {return _validityPeriod;}

    void setRejectDuplicates(bool x) {_rejectDuplicates = x;}
    void setValidityPeriodFormat(TimePeriod::Format &x)
      {_validityPeriodFormat = x;}
    void setReplyPath(bool x) {_replyPath = x;}
    void setStatusReportRequest(bool x) {_statusReportRequest = x;}
    void setMessageReference(unsigned char x) {_messageReference = x;}
    void setDestinationAddress(Address &x) {_destinationAddress = x;}
    void setProtocolIdentifier(unsigned char x) {_protocolIdentifier = x;}
    void setValidityPeriod(TimePeriod &x) {_validityPeriod = x;}
    
    virtual ~SMSSubmitMessage() {}
  };

  // SMS-STATUS-REPORT TPDU
  class SMSStatusReportMessage : public SMSMessage
  {
  private:
    // SMS-STATUS-REPORT PDU (see GSM 03.40 section 9.2.2.3)
    bool _moreMessagesToSend;
    bool _statusReportQualifier;
    unsigned char _messageReference;
    Address _recipientAddress;
    Timestamp _serviceCentreTimestamp;
    Timestamp _dischargeTime;
    unsigned char _status;      // octet
    
    // initialize members to sensible values
    void init();
    
  public:
    // constructor, sets sensible default values
    SMSStatusReportMessage() {init();}

    // constructor with given pdu
    SMSStatusReportMessage(std::string pdu) throw(GsmException);

    // encode pdu, return hexadecimal pdu string
    virtual std::string encode();

    // create textual representation of SMS
    virtual std::string toString() const;

    // inherited from SMSMessage
    Address address() const;
    Ref<SMSMessage> clone();

    // accessor functions
    bool moreMessagesToSend() const {return _moreMessagesToSend;}
    bool statusReportQualifier() const {return _statusReportQualifier;}
    unsigned char messageReference() const {return _messageReference;}
    Address recipientAddress() const {return _recipientAddress;}
    Timestamp serviceCentreTimestamp() const {return _serviceCentreTimestamp;}
    Timestamp dischargeTime() const {return _dischargeTime;}
    unsigned char status() const {return _status;}
    
    void setMoreMessagesToSend(bool x) {_moreMessagesToSend = x;}
    void setStatusReportQualifier(bool x) {_statusReportQualifier = x;}
    void setMessageReference(unsigned char x) {_messageReference = x;}
    void setRecipientAddress(Address x) {_recipientAddress = x;}
    void setServiceCentreTimestamp(Timestamp x) {_serviceCentreTimestamp = x;}
    void setDischargeTime(Timestamp x) {_serviceCentreTimestamp = x;}
    void setStatus(unsigned char x) {_status = x;}

    virtual ~SMSStatusReportMessage() {}
  };

  // SMS-COMMAND TPDU
  class SMSCommandMessage : public SMSMessage
  {
  public:
    // command types, other values are reserved or SC-specific
    enum CommandType {EnquireSM = 0, CancelStatusReportRequest = 1,
                      DeleteSubmittedSM = 2, EnalbeStatusReportRequest = 3};

  private:
    // SMS-COMMAND PDU (see GSM 03.40 section 9.2.2.4)
    unsigned char _messageReference;
    bool _statusReportRequest;
    unsigned char _protocolIdentifier;
    unsigned char _commandType;
    unsigned char _messageNumber;
    Address _destinationAddress;
    unsigned char _commandDataLength;
    std::string _commandData;

    // initialize members to sensible values
    void init();
    
  public:
    // constructor, sets sensible default values
    SMSCommandMessage() {init();}

    // constructor with given pdu
    SMSCommandMessage(std::string pdu) throw(GsmException);

    // encode pdu, return hexadecimal pdu string
    virtual std::string encode();

    // create textual representation of SMS
    virtual std::string toString() const;

    // inherited from SMSMessage
    Address address() const;
    Ref<SMSMessage> clone();

    // accessor functions
    unsigned char messageReference() const {return _messageReference;}
    bool statusReportRequest() const {return _statusReportRequest;}
    unsigned char protocolIdentifier() const {return _protocolIdentifier;}
    unsigned char commandType() const {return _commandType;}
    unsigned char messageNumber() const {return _messageNumber;}
    Address destinationAddress() const {return _destinationAddress;}
    unsigned char commandDataLength() const {return _commandDataLength;}
    std::string commandData() const {return _commandData;}

    void setMessageReference(unsigned char x) {_messageReference = x;}
    void setStatusReportRequest(bool x) {_statusReportRequest = x;}
    void setProtocolIdentifier(unsigned char x) {_protocolIdentifier = x;}
    void setCommandType(unsigned char x) {_commandType = x;}
    void setMessageNumber(unsigned char x) {_messageNumber = x;}
    void setDestinationAddress(Address &x) {_destinationAddress = x;}
    void setCommandDataLength(unsigned char x) {_commandDataLength = x;}
    void setCommandData(std::string x) {_commandData = x;}

    virtual ~SMSCommandMessage() {}
  };

  // SMS-DELIVER-REPORT TPDU for RP-ACK
  class SMSDeliverReportMessage : public SMSMessage
  {
  private:
    // SMS-DELIVER-REPORT PDU (see GSM 03.40 section 9.2.2.1a (II))
    bool _protocolIdentifierPresent; // parameter indicator
    bool _dataCodingSchemePresent;
    bool _userDataLengthPresent;
    unsigned char _protocolIdentifier;
    
    // initialize members to sensible values
    void init();
    
  public:
    // constructor, sets sensible default values
    SMSDeliverReportMessage() {init();}

    // constructor with given pdu
    SMSDeliverReportMessage(std::string pdu) throw(GsmException);

    // encode pdu, return hexadecimal pdu string
    virtual std::string encode();

    // create textual representation of SMS
    virtual std::string toString() const;

    // inherited from SMSMessage
    Address address() const;
    Ref<SMSMessage> clone();

    // accessor functions
    bool protocolIdentifierPresent() const {return _protocolIdentifierPresent;}
    bool dataCodingSchemePresent() const {return _dataCodingSchemePresent;}
    bool userDataLengthPresent() const {return _userDataLengthPresent;}
    unsigned char protocolIdentifier() const
      {assert(_protocolIdentifierPresent); return _protocolIdentifier;}
    DataCodingScheme dataCodingScheme() const
      {assert(_dataCodingSchemePresent); return _dataCodingScheme;}
    UserDataHeader userDataHeader() const
      {assert(_userDataLengthPresent); return _userDataHeader;}
    std::string userData() const
      {assert(_userDataLengthPresent); return _userData;}
    
    void setProtocolIdentifier(unsigned char x)
      {_protocolIdentifierPresent = true; _protocolIdentifier = x;}
    void setDataCodingScheme(DataCodingScheme x)
      {_dataCodingSchemePresent = true; _dataCodingScheme = x;}
    void setUserDataHeader(UserDataHeader x)
    {
      _userDataLengthPresent = true;
      _userDataHeader = x;
    }
    void setUserData(std::string x)
    {
      _userDataLengthPresent = true;
      _userData = x;
    }
    
    virtual ~SMSDeliverReportMessage() {}
  };

  // SMS-SUBMIT-REPORT TPDU for RP-ACK
  class SMSSubmitReportMessage : public SMSMessage
  {
  private:
    // SMS-SUBMIT-REPORT PDU (see GSM 03.40 section 9.2.2.2a (II))
    Timestamp _serviceCentreTimestamp;
    bool _protocolIdentifierPresent; // parameter indicator
    bool _dataCodingSchemePresent;
    bool _userDataLengthPresent;
    unsigned char _protocolIdentifier;
    DataCodingScheme _dataCodingScheme;

    // initialize members to sensible values
    void init();
    
  public:
    // constructor, sets sensible default values
    SMSSubmitReportMessage() {init();}

    // constructor with given pdu
    SMSSubmitReportMessage(std::string pdu) throw(GsmException);

    // encode pdu, return hexadecimal pdu string
    virtual std::string encode();

    // create textual representation of SMS
    virtual std::string toString() const;

    // inherited from SMSMessage
    Address address() const;
    Ref<SMSMessage> clone();

    // accessor functions
    Timestamp serviceCentreTimestamp() const {return _serviceCentreTimestamp;}
    bool protocolIdentifierPresent() const {return _protocolIdentifierPresent;}
    bool dataCodingSchemePresent() const {return _dataCodingSchemePresent;}
    bool userDataLengthPresent() const {return _userDataLengthPresent;}
    unsigned char protocolIdentifier() const
      {assert(_protocolIdentifierPresent); return _protocolIdentifier;}
    DataCodingScheme dataCodingScheme() const
      {assert(_dataCodingSchemePresent); return _dataCodingScheme;}
    UserDataHeader userDataHeader() const
      {assert(_userDataLengthPresent); return _userDataHeader;}
    std::string userData() const
      {assert(_userDataLengthPresent); return _userData;}

    void setServiceCentreTimestamp(Timestamp &x) {_serviceCentreTimestamp = x;}
    void setProtocolIdentifier(unsigned char x)
      {_protocolIdentifierPresent = true; _protocolIdentifier = x;}
    void setDataCodingScheme(DataCodingScheme x)
      {_dataCodingSchemePresent = true; _dataCodingScheme = x;}
    void setUserDataHeader(UserDataHeader x)
    {
      _userDataLengthPresent = true;
      _userDataHeader = x;
    }
    void setUserData(std::string x)
    {
      _userDataLengthPresent = true;
      _userData = x;
    }
    virtual ~SMSSubmitReportMessage() {}
  };

  // some useful typdefs
  typedef Ref<SMSMessage> SMSMessageRef;
};

#endif // GSM_SMS_H