1 /*
2 *
3 * Inter Asterisk Exchange 2
4 *
5 * The classes used to hold Information Elements.
6 *
7 * Open Phone Abstraction Library (OPAL)
8 *
9 * Copyright (c) 2005 Indranet Technologies Ltd.
10 *
11 * The contents of this file are subject to the Mozilla Public License
12 * Version 1.0 (the "License"); you may not use this file except in
13 * compliance with the License. You may obtain a copy of the License at
14 * http://www.mozilla.org/MPL/
15 *
16 * Software distributed under the License is distributed on an "AS IS"
17 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
18 * the License for the specific language governing rights and limitations
19 * under the License.
20 *
21 * The Original Code is Open Phone Abstraction Library.
22 *
23 * The Initial Developer of the Original Code is Indranet Technologies Ltd.
24 *
25 * The author of this code is Derek J Smithies
26 *
27 * $Revision: 24625 $
28 * $Author: dereksmithies $
29 * $Date: 2010-08-08 17:41:30 -0500 (Sun, 08 Aug 2010) $
30 */
31
32 #ifndef OPAL_IAX2_IES_H
33 #define OPAL_IAX2_IES_H
34
35 #ifndef _PTLIB_H
36 #include <ptlib.h>
37 #endif
38
39 #include <opal/buildopts.h>
40
41 #if OPAL_IAX2
42
43 #include <ptlib/sockets.h>
44 #include <iax2/iedata.h>
45
46 #ifdef P_USE_PRAGMA
47 #pragma interface
48 #endif
49
50
51 class IAX2Ie;
52 class IAX2Encryption;
53
54 /**Ie class is for handling information elements*/
55 class IAX2Ie : public PObject
56 {
57 PCLASSINFO(IAX2Ie, PObject);
58 public:
59 /** Each of the 45 possible Information Element types */
60 enum IAX2IeTypeCode {
61 ie_calledNumber = 1, /*!< Number or extension that is being being called (string) */
62 ie_callingNumber = 2, /*!< The number of the node initating the call r (string) */
63 ie_callingAni = 3, /*!< The ANI (calling number) to use for billing (string) */
64 ie_callingName = 4, /*!< The callers name (string) */
65 ie_calledContext = 5, /*!< The context we are calling to (string) */
66 ie_userName = 6, /*!< UserName (peer or user) to use in the authentication process (string) */
67 ie_password = 7, /*!< Password - which is used in the authentication process (string) */
68 ie_capability = 8, /*!< Bitmask of the codecs sending end supports or senders capability (unsigned int) */
69 ie_format = 9, /*!< Bitmask of the desired codec (unsigned int) */
70 ie_language = 10, /*!< Sending ends preferred language string) */
71 ie_version = 11, /*!< Sending ends protocol version - typically 2. (short) */
72 ie_adsicpe = 12, /*!< CPE ADSI capability (short) */
73 ie_dnid = 13, /*!< Originally dialed DNID (string) */
74 ie_authMethods = 14, /*!< Bitmask of the available Authentication method(s) (short) */
75 ie_challenge = 15, /*!< The challenge data used in MD5/RSA authentication (string) */
76 ie_md5Result = 16, /*!< MD5 challenge (authentication process) result (string) */
77 ie_rsaResult = 17, /*!< RSA challenge (authentication process) result (string) */
78 ie_apparentAddr = 18, /*!< The peer's apparent address. (struct sockaddr_in) */
79 ie_refresh = 19, /*!< The frequency of on with to refresh registration, in units of seconds (short) */
80 ie_dpStatus = 20, /*!< The dialplan status (short) */
81 ie_callNo = 21, /*!< Call number of the peer (short) */
82 ie_cause = 22, /*!< Description of why hangup or authentication or other failure happened (string) */
83 ie_iaxUnknown = 23, /*!< An IAX command that is unknown (byte) */
84 ie_msgCount = 24, /*!< A report on the number of messages waiting (short) */
85 ie_autoAnswer = 25, /*!< auto-answering is requested (no type required, as this is a request) */
86 ie_musicOnHold = 26, /*!< Demand for music on hold combined with QUELCH (string or none) */
87 ie_transferId = 27, /*!< Identifier for a Transfer Request (int) */
88 ie_rdnis = 28, /*!< DNIS of the referring agent (string) */
89 ie_provisioning = 29, /*!< Info to be used for provisioning (binary data) */
90 ie_aesProvisioning = 30, /*!< Info for provisioning AES (binary data) */
91 ie_dateTime = 31, /*!< Date and Time (which is stored in binary format defined in IAX2IeDateTime) */
92 ie_deviceType = 32, /*!< The type of device (string) */
93 ie_serviceIdent = 33, /*!< The Identifier for service (string) */
94 ie_firmwareVer = 34, /*!< The version of firmware (unsigned 32 bit number) */
95 ie_fwBlockDesc = 35, /*!< The description for a block of firmware (unsigned 32 bit number ) */
96 ie_fwBlockData = 36, /*!< Binary data for a block of fw () */
97 ie_provVer = 37, /*!< The version of provisiong (unsigned 32 bit number) */
98 ie_callingPres = 38, /*!< Presentation of calling (unsigned 8 bit) */
99 ie_callingTon = 39, /*!< Type of number calling (unsigned 8 bit) */
100 ie_callingTns = 40, /*!< Transit Network Select for calling (unsigned 16 bit) */
101 ie_samplingRate = 41, /*!< Bitmask of supported Rate of sampling . Sampling defaults to 8000 hz, (unsigned 16) */
102 ie_causeCode = 42, /*!< Code value which describes why the registration failed, or call hungup etc (unsigned 8 bit) */
103 ie_encryption = 43, /*!< The method for encrption the remote code wants to use (U16) */
104 ie_encKey = 44, /*!< the Key for ncryption (raw binary data) */
105 ie_codecPrefs = 45, /*!< The codec we would prefer to use (unsigned 8 bit) */
106 ie_recJitter = 46, /*!< From rfc 1889, the received jitter (unsigned 32 bit number) */
107 ie_recLoss = 47, /*!< The received loss rate, where the high byte is the loss packt, low 24 bits loss count, from rfc1889 (unsigned 32 bit)*/
108 ie_recPackets = 48, /*!< Recevied number of frames (total frames received) (unsigned 32 bit) */
109 ie_recDelay = 49, /*!< Received frame largest playout delay (in ms) (unsigned 16 bit)*/
110 ie_recDropped = 50, /*!< The number of dropped received frames by the jitter buf, so it is a measure of the number of late frames (unsigned 32 bit) */
111 ie_recOoo = 51, /*!< The number of received frames which were Out Of Order (unsigned 32 number) */
112 ie_variable = 52, /*!< do remote variables */
113 ie_ospToken = 53, /*!< OSP token */
114 ie_callToken = 54, /*!< For security - do Call number tests */
115 ie_capability2 = 55, /*!< Do the Actual codec capability - u8 version + integer array */
116 ie_format2 = 56, /*!< Desired codec format - u8 version + integer array */
117 ie_countEntries /*!< Report on how many different ie types there are */
118 };
119
120 /**@name construction/destruction*/
121 //@{
122
123 /**Constructor*/
124 IAX2Ie();
125
126 /**Destructor*/
~IAX2Ie()127 virtual ~IAX2Ie() { };
128 //@{
129
130 /**@name Worker methods*/
131 //@{
132 /** Given an arbitrary type code, build & initialise the IAX2Ie descendant class */
133 static IAX2Ie *BuildInformationElement(BYTE _typeCode, BYTE length, BYTE *srcData);
134
135 /** returns true if contains an initialised information element */
IsValid()136 virtual PBoolean IsValid() { return validData; }
137
138 /**return the number of bytes to hold this data element */
GetLengthOfData()139 virtual BYTE GetLengthOfData() { return 0; }
140
141 /**return the number of bytes to hold this Information Element when stored in a packet*/
GetBinarySize()142 int GetBinarySize() { return 2 + GetLengthOfData(); }
143
144 /**print this class (nicely) to the designated stream*/
145 virtual void PrintOn(ostream & str) const;
146
147 /** Get the enum value for this information element class */
GetKeyValue()148 virtual BYTE GetKeyValue() const { return 255; }
149
150 /**Take the supplied data and copy contents into this IE */
SetData(int &)151 void SetData(int &/*newData*/) { PAssertAlways("Ie class cannnot set data value"); };
152
153 /**Read the value of the stored data for this class */
ReadData()154 int ReadData() { PAssertAlways("Ie class cannot read the internal data value"); return 0; };
155
156 /** Take the data from this IAX2Ie and copy into the memory region.
157 When finished, increment the writeIndex appropriately. */
158 void WriteBinary(void *data, PINDEX & writeIndex);
159
160 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData structure.
161 This is done on processing an incoming frame which contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData &)162 virtual void StoreDataIn(IAX2IeData &/*res*/) { PAssertAlways(PUnimplementedFunction); }
163 //@}
164
165 protected:
166 /** Take the data value for this particular IAX2Ie and copy into the memory region.*/
WriteBinary(BYTE *)167 virtual void WriteBinary(BYTE * /*data*/) { PAssertAlways(PUnimplementedFunction); }
168
169 /**A flag indicating if the data was read from the supplied bytes
170 correctly, or if this structure is yet to be initialised */
171 PBoolean validData;
172 };
173
174 /////////////////////////////////////////////////////////////////////////////
175 /**An Information Element that identifies an invalid code in the processed binary data.*/
176 class IAX2IeInvalidElement : public IAX2Ie
177 {
178 PCLASSINFO(IAX2IeInvalidElement, IAX2Ie);
179 public:
IAX2IeInvalidElement()180 IAX2IeInvalidElement() : IAX2Ie() {};
181
182 /**Access function to get the length of data, which is used when
183 writing to network packet*/
GetlengthOfData()184 virtual BYTE GetlengthOfData() { return 0; }
185
186 /**print this class (nicely) to the designated stream*/
PrintOn(ostream & str)187 virtual void PrintOn(ostream & str) const
188 { str << "Invlalid Information Element" << endl; }
189 protected:
190 /** Take the data value for this particular IAX2Ie and copy into the
191 memory region. For an IAX2IeInvalidElement, there is no work
192 done, as the data is invalid. */
WriteBinary(BYTE *)193 virtual void WriteBinary(BYTE * /*data*/) { }
194 };
195 /////////////////////////////////////////////////////////////////////////////
196 /**An Information Element that contains no data. */
197 class IAX2IeNone : public IAX2Ie
198 {
199 PCLASSINFO(IAX2IeNone, IAX2Ie);
200 /**@name construction/destruction*/
201 //@{
202
203 /**Constructor - read data from source array.
204
205 Contents are valid if source array is valid. */
206 IAX2IeNone(BYTE length, BYTE *srcData);
207
208 /**Constructor to an invalid and empty result*/
IAX2IeNone()209 IAX2IeNone() : IAX2Ie() {}
210 //@}
211
212 /**@name Worker methods*/
213 //@{
214 /**return the number of bytes to hold this data element */
GetLengthOfData()215 virtual BYTE GetLengthOfData() { return 0; }
216
217 /**Report the value stored in this class */
GetValue()218 BYTE GetValue() { return 0; }
219
220 /**print this class (nicely) to the designated stream*/
221 virtual void PrintOn(ostream & str) const;
222
223 /**Take the supplied data and copy contents into this IE */
SetData(void *)224 void SetData(void * /*newData*/)
225 { PAssertAlways("IeNone cannot set data"); }
226
227 /**Read the value of the stored data for this class */
ReadData()228 int ReadData() { PAssertAlways("IeNone cannot read the internal data value"); return 0; }
229
230 //@}
231 protected:
232 /** Take the data value for this particular IAX2Ie and copy into the memory region.
233 For this IAX2Ie (IAX2IeNone) there is no work to do as there is no data. */
WriteBinary(BYTE *)234 virtual void WriteBinary(BYTE * /*data*/) { }
235 };
236
237 /////////////////////////////////////////////////////////////////////////////
238 /**An Information Element that contains one byte of data*/
239 class IAX2IeByte : public IAX2Ie
240 {
241 PCLASSINFO(IAX2IeByte, IAX2Ie);
242 /**@name construction/destruction*/
243 //@{
244
245 /**Constructor - read data from source array.
246
247 Contents are valid if source array is valid. */
248 IAX2IeByte(BYTE length, BYTE *srcData);
249
250 /**Constructor to a specific value */
IAX2IeByte(BYTE newValue)251 IAX2IeByte(BYTE newValue) : IAX2Ie() { SetData(newValue); }
252
253 /**Constructor to an invalid and empty result*/
IAX2IeByte()254 IAX2IeByte() : IAX2Ie() { }
255 //@}
256
257 /**@name Worker methods*/
258 //@{
259 /**return the number of bytes to hold this data element */
GetLengthOfData()260 virtual BYTE GetLengthOfData() { return sizeof(dataValue); }
261
262 /**print this class (nicely) to the designated stream*/
263 virtual void PrintOn(ostream & str) const;
264
265 /**Take the supplied data and copy contents into this IE */
SetData(BYTE newData)266 void SetData(BYTE newData) { dataValue = newData; validData = true; }
267
268 /**Report the value of the stored data for this class */
ReadData()269 BYTE ReadData() { return dataValue; }
270
271 //@}
272 protected:
273 /** Take the data value for this particular IAX2Ie and copy into the
274 memory region.*/
WriteBinary(BYTE * data)275 virtual void WriteBinary(BYTE *data) { data[0] = dataValue; }
276
277 /**The actual data stored in a IAX2IeByte class */
278 BYTE dataValue;
279 };
280
281 /////////////////////////////////////////////////////////////////////////////
282 /**An Information Element that contains one character of data*/
283 class IAX2IeChar : public IAX2Ie
284 {
285 PCLASSINFO(IAX2IeChar, IAX2Ie);
286 /**@name construction/destruction*/
287 //@{
288
289 /**Constructor - read data from source array.
290
291 Contents are valid if source array is valid. */
292 IAX2IeChar(BYTE length, BYTE *srcData);
293
294 /**Construct to an initialised value */
IAX2IeChar(char newValue)295 IAX2IeChar(char newValue) : IAX2Ie() { SetData(newValue); }
296
297 /**Constructor to an invalid and empty result*/
IAX2IeChar()298 IAX2IeChar() : IAX2Ie() { }
299 //@}
300
301 /**@name Worker methods*/
302 //@{
303 /**return the number of bytes to hold this data element */
GetLengthOfData()304 virtual BYTE GetLengthOfData() { return sizeof(dataValue); }
305
306 /**print this class (nicely) to the designated stream*/
307 virtual void PrintOn(ostream & str) const;
308
309 /**Take the supplied data and copy contents into this IE */
SetData(char newData)310 void SetData(char newData) { dataValue = newData; validData = true; }
311
312 /**Report the value of the stored data for this class */
ReadData()313 char ReadData() { return dataValue; }
314
315 //@}
316 protected:
317 /** Take the data value for this particular IAX2Ie and copy into the
318 memory region.*/
WriteBinary(BYTE * data)319 virtual void WriteBinary(BYTE *data) { data[0] = dataValue; }
320
321 /**The actual data stored in a IAX2IeChar class */
322 char dataValue;
323 };
324
325 /////////////////////////////////////////////////////////////////////////////
326 /**An Information Element that contains one short (signed 16 bits) of data*/
327 class IAX2IeShort : public IAX2Ie
328 {
329 PCLASSINFO(IAX2IeShort, IAX2Ie);
330 /**@name construction/destruction*/
331 //@{
332
333 /**Constructor - read data from source array.
334
335 Contents are valid if source array is valid. */
336 IAX2IeShort(BYTE length, BYTE *srcData);
337
338 /**Construct to an initialied value */
IAX2IeShort(short newValue)339 IAX2IeShort(short newValue) : IAX2Ie() { SetData(newValue); }
340
341 /**Constructor to an invalid and empty result*/
IAX2IeShort()342 IAX2IeShort() : IAX2Ie() { }
343 //@}
344
345 /**@name Worker methods*/
346 //@{
347 /**return the number of bytes to hold this data element */
GetLengthOfData()348 virtual BYTE GetLengthOfData() { return sizeof(dataValue); }
349
350 /**print this class (nicely) to the designated stream*/
351 virtual void PrintOn(ostream & str) const;
352
353 /**Take the supplied data and copy contents into this IE */
SetData(short newData)354 void SetData(short newData) { dataValue = newData; validData = true; }
355
356 /**Report the value of the stored data for this class */
ReadData()357 short ReadData() { return dataValue; }
358 //@}
359 protected:
360 /** Take the data value for this particular IAX2Ie and copy into the
361 memory region.*/
362 virtual void WriteBinary(BYTE *data);
363
364 /**The actual data stored in a IAX2IeShort class */
365 short dataValue;
366 };
367 /////////////////////////////////////////////////////////////////////////////
368 /**An Information Element that contains one integer (signed 16 bits) of data*/
369 class IAX2IeInt : public IAX2Ie
370 {
371 PCLASSINFO(IAX2IeInt, IAX2Ie);
372 /**@name construction/destruction*/
373 //@{
374
375 /**Constructor - read data from source array.
376
377 Contents are valid if source array is valid. */
378 IAX2IeInt(BYTE length, BYTE *srcData);
379
380 /**Construct to an initialised value */
IAX2IeInt(int newValue)381 IAX2IeInt(int newValue) : IAX2Ie() { SetData(newValue); }
382
383 /**Constructor to an invalid and empty result*/
IAX2IeInt()384 IAX2IeInt() : IAX2Ie() { }
385 //@}
386
387 /**@name Worker methods*/
388 //@{
389 /**return the number of bytes to hold this data element */
GetLengthOfData()390 virtual BYTE GetLengthOfData() { return sizeof(dataValue); }
391
392 /**print this class (nicely) to the designated stream*/
393 virtual void PrintOn(ostream & str) const;
394
395 /**Take the supplied data and copy contents into this IE */
SetData(int newData)396 void SetData(int newData) { dataValue = newData; validData = true; }
397
398 /**Report the value of the stored data for this class */
ReadData()399 int ReadData() { return dataValue; }
400
401 //@}
402 protected:
403 /** Take the data value for this particular IAX2Ie and copy into the
404 memory region.*/
405 virtual void WriteBinary(BYTE *data);
406
407 /**The actual data stored in a IAX2IeInt class */
408 int dataValue;
409 };
410 ////////////////////////////////////////////////////////////////////////////////
411 /**An Information Element that contains an unsigned short (16 bits) of data*/
412 class IAX2IeUShort : public IAX2Ie
413 {
414 PCLASSINFO(IAX2IeUShort, IAX2Ie);
415 /**@name construction/destruction*/
416 //@{
417
418 /**Constructor - read data from source array.
419
420 Contents are valid if source array is valid. */
421 IAX2IeUShort(BYTE length, BYTE *srcData);
422
423 /**Construct to an initialised value */
IAX2IeUShort(unsigned short newValue)424 IAX2IeUShort(unsigned short newValue) : IAX2Ie() { SetData(newValue); }
425
426 /**Constructor to an invalid and empty result*/
IAX2IeUShort()427 IAX2IeUShort() : IAX2Ie() {}
428 //@}
429
430 /**@name Worker methods*/
431 //@{
432 /**return the number of bytes to hold this data element */
GetLengthOfData()433 virtual BYTE GetLengthOfData() { return sizeof(dataValue); }
434
435 /**print this class (nicely) to the designated stream*/
436 virtual void PrintOn(ostream & str) const;
437
438 /**Take the supplied data and copy contents into this IE */
SetData(unsigned short newData)439 void SetData(unsigned short newData) { dataValue = newData; validData = true; }
440
441 /**Report the value of the stored data for this class */
ReadData()442 unsigned short ReadData() { return dataValue; }
443 //@}
444 protected:
445 /** Take the data value for this particular IAX2Ie and copy into the
446 memory region.*/
447 virtual void WriteBinary(BYTE *data);
448
449 /**The actual data stored in a IAX2IeUShort class */
450 unsigned short dataValue;
451 };
452 ////////////////////////////////////////////////////////////////////////////////
453 /**An Information Element that contains an unsigned int (32 bits) of data*/
454 class IAX2IeUInt : public IAX2Ie
455 {
456 PCLASSINFO(IAX2IeUInt, IAX2Ie);
457 /**@name construction/destruction*/
458 //@{
459
460 /**Constructor - read data from source array.
461
462 Contents are valid if source array is valid. */
463 IAX2IeUInt(BYTE length, BYTE *srcData);
464
465 /**Constructor to an invalid and empty result*/
IAX2IeUInt()466 IAX2IeUInt() : IAX2Ie() {}
467
468 /**Constructor to an initialised value, (Typically used prior to transmission)*/
IAX2IeUInt(unsigned int newValue)469 IAX2IeUInt(unsigned int newValue) { SetData(newValue); }
470 //@}
471
472 /**@name Worker methods*/
473 //@{
474 /**return the number of bytes to hold this data element */
GetLengthOfData()475 virtual BYTE GetLengthOfData() { return sizeof(dataValue); }
476
477 /**print this class (nicely) to the designated stream*/
478 virtual void PrintOn(ostream & str) const;
479
480 /**Take the supplied data and copy contents into this IE */
SetData(unsigned int & newData)481 void SetData(unsigned int &newData) { dataValue = newData; validData = true; }
482
483 /**Report the value of the stored data for this class */
ReadData()484 unsigned int ReadData() { return dataValue; }
485 //@}
486
487 protected:
488 /** Take the data value for this particular IAX2Ie and copy into the
489 memory region.*/
490 virtual void WriteBinary(BYTE *data);
491
492 /**The actual data stored in a IAX2IeUInt class */
493 unsigned int dataValue;
494 };
495
496 ////////////////////////////////////////////////////////////////////////////////
497 /**An Information Element that contains an array of characters. */
498 class IAX2IeString : public IAX2Ie
499 {
500 PCLASSINFO(IAX2IeString, IAX2Ie);
501 /**@name construction/destruction*/
502 //@{
503
504 public:
505 /**Constructor - read data from source array.
506
507 Contents are valid if source array is valid. */
508 IAX2IeString(BYTE length, BYTE *srcData);
509
510 /**Construct to an initialised value */
IAX2IeString(const PString & newValue)511 IAX2IeString(const PString & newValue) : IAX2Ie() { SetData(newValue); }
512
513 /**Construct to an initialised value */
IAX2IeString(const char * newValue)514 IAX2IeString(const char * newValue) : IAX2Ie() { SetData(newValue); }
515
516 /**Constructor to an invalid and empty result*/
IAX2IeString()517 IAX2IeString() : IAX2Ie() {}
518 //@}
519
520 /**@name Worker methods*/
521 //@{
522 /**return the number of bytes to hold this data element */
523 virtual BYTE GetLengthOfData();
524
525 /**print this class (nicely) to the designated stream*/
526 void PrintOn(ostream & str) const;
527
528 /**Take the supplied data and copy contents into this IE */
529 void SetData(const PString & newData);
530
531 /**Take the supplied data and copy contents into this IE */
532 void SetData(const char * newData);
533
534 /**Report the value of the stored data for this class */
ReadData()535 PString ReadData() { return dataValue; }
536 //@}
537
538 protected:
539 /** Take the data value for this particular IAX2Ie and copy into the
540 memory region.*/
541 virtual void WriteBinary(BYTE *data);
542
543 /**The actual data stored in a IAX2IeString class */
544 PString dataValue;
545 };
546
547 ////////////////////////////////////////////////////////////////////////////////
548 /**An Information Element that contains numbers which are in the range
549 of 0..255 It is valid to have zero elements in this field. */
550 class IAX2IeBinary : public IAX2Ie
551 {
552 PCLASSINFO(IAX2IeBinary, IAX2Ie);
553 /**@name construction/destruction*/
554 //@{
555
556 public:
557 /**Constructor - read data from source array.
558
559 If the length is zero, the value of srcData is ignored, and an empty
560 array is created. */
561 IAX2IeBinary(BYTE length, BYTE *srcData);
562
563 /**Construct to an initialised value */
IAX2IeBinary(PBYTEArray newValue)564 IAX2IeBinary(PBYTEArray newValue) : IAX2Ie() { SetData(newValue); }
565
566 /**Constructor to an invalid and empty result*/
IAX2IeBinary()567 IAX2IeBinary() : IAX2Ie() {}
568 //@}
569
570 /**@name Worker methods*/
571 //@{
572 /**return the number of bytes to hold this data element */
GetLengthOfData()573 virtual BYTE GetLengthOfData() { return (BYTE)dataValue.GetSize(); }
574
575 /**print this class (nicely) to the designated stream*/
576 virtual void PrintOn(ostream & str) const;
577
578 /**Take the supplied data and copy contents into this IE */
579 void SetData(const PBYTEArray & newData);
580
581 /**Take the internal data and copy it to the parameter */
582 void GetData(PBYTEArray & answer);
583
584 /**Copy the data from the supplied IAX2IeBinary and put it into this
585 instance */
586 void CopyData(IAX2IeBinary *src);
587 //@}
588
589 protected:
590 /** Take the data value for this particular IAX2Ie and copy into the
591 memory region.*/
592 virtual void WriteBinary(BYTE *data);
593
594 /**The actual data stored in a IAX2IeBinary class */
595 PBYTEArray dataValue;
596 };
597
598
599 ////////////////////////////////////////////////////////////////////////////////
600 /**An Information Element that contains the date and time, from a 32 bit long representation*/
601 class IAX2IeDateAndTime : public IAX2Ie
602 {
603 PCLASSINFO(IAX2IeDateAndTime, IAX2Ie);
604 /**@name construction/destruction*/
605 //@{
606
607 public:
608 /**Constructor - read data from source array.
609
610 Contents are valid if source array is valid. */
611 IAX2IeDateAndTime(BYTE length, BYTE *srcData);
612
613 /**Construct to an initialized value */
IAX2IeDateAndTime(const PTime & newValue)614 IAX2IeDateAndTime(const PTime & newValue) : IAX2Ie() { SetData(newValue); }
615
616 /**Constructor to an invalid and empty result*/
IAX2IeDateAndTime()617 IAX2IeDateAndTime() : IAX2Ie() {}
618 //@}
619
620 /**@name Worker methods*/
621 //@{
622 /**print this class (nicely) to the designated stream*/
623 virtual void PrintOn(ostream & str) const;
624
625 /**return the number of bytes to hold this data element */
GetLengthOfData()626 virtual BYTE GetLengthOfData() { return 4; }
627
628 /**Take the supplied data and copy contents into this IE */
SetData(const PTime & newData)629 void SetData(const PTime & newData)
630 { dataValue = newData; validData = true; }
631
632 /**Report the value of the stored data for this class */
ReadData()633 PTime ReadData() { return dataValue; }
634 //@}
635 protected:
636 /** Take the data value for this particular IAX2Ie and copy into the
637 memory region.*/
638 virtual void WriteBinary(BYTE *data);
639
640 /**The actual data stored in a IAX2IeDateAndTime class */
641 PTime dataValue;
642 };
643 ////////////////////////////////////////////////////////////////////////////////
644 /**An Information Element that contains an array of BYTES (with possible nulls in middle) */
645 class IAX2IeBlockOfData : public IAX2Ie
646 {
647 PCLASSINFO(IAX2IeBlockOfData, IAX2Ie);
648 /**@name construction/destruction*/
649 //@{
650
651 public:
652 /**Constructor - read data from source array.
653
654 Contents are valid if source array is valid. */
655 IAX2IeBlockOfData(BYTE length, BYTE *srcData);
656
657 /**Construct to an initialized value */
IAX2IeBlockOfData(const PBYTEArray & newData)658 IAX2IeBlockOfData(const PBYTEArray & newData) : IAX2Ie() { SetData(newData); }
659
660 /**Constructor to an invalid and empty result*/
IAX2IeBlockOfData()661 IAX2IeBlockOfData() : IAX2Ie() {}
662 //@}
663
664 /**@name Worker methods*/
665 //@{
666 /**print this class (nicely) to the designated stream*/
667 virtual void PrintOn(ostream & str) const;
668
669 /**return the number of bytes to hold this data element */
GetLengthOfData()670 virtual BYTE GetLengthOfData() { return (BYTE)dataValue.GetSize(); }
671
672 /**Take the supplied data and copy contents into this IE */
SetData(const PBYTEArray & newData)673 void SetData(const PBYTEArray & newData)
674 { dataValue = newData; validData = true; }
675
676 /**Report the value of the stored data for this class */
ReadData()677 PBYTEArray ReadData() { return dataValue; }
678
679 //@}
680 protected:
681 /** Take the data value for this particular IAX2Ie and copy into the
682 memory region.*/
683 virtual void WriteBinary(BYTE *data);
684
685 /**The actual data stored in a IAX2IeBlockOfData class */
686 PBYTEArray dataValue;
687 };
688 ////////////////////////////////////////////////////////////////////////////////
689 /**An Information Element that contains an Ip address and port */
690 class IAX2IeSockaddrIn : public IAX2Ie
691 {
692 PCLASSINFO(IAX2IeSockaddrIn, IAX2Ie);
693 /**@name construction/destruction*/
694 //@{
695
696 public:
697 /**Constructor - read data from source array.
698
699 Contents are valid if source array is valid. */
700 IAX2IeSockaddrIn(BYTE length, BYTE *srcData);
701
702 /**Construct to an initialized value */
IAX2IeSockaddrIn(const PIPSocket::Address & addr,PINDEX port)703 IAX2IeSockaddrIn(const PIPSocket::Address & addr, PINDEX port) : IAX2Ie()
704 { SetData(addr, port); }
705
706 /**Constructor to an invalid and empty result*/
IAX2IeSockaddrIn()707 IAX2IeSockaddrIn() : IAX2Ie() {}
708
709 /**Destructor*/
~IAX2IeSockaddrIn()710 ~IAX2IeSockaddrIn() { } ;
711 //@}
712
713 /**@name Worker methods*/
714 //@{
715 /**print this class (nicely) to the designated stream*/
716 virtual void PrintOn(ostream & str) const;
717
718 /**return the number of bytes to hold this data element */
GetLengthOfData()719 virtual BYTE GetLengthOfData() { return sizeof(struct sockaddr_in); }
720
721 /**Take the supplied data and copy contents into this IE */
SetData(const PIPSocket::Address & newAddr,PINDEX newPort)722 void SetData(const PIPSocket::Address & newAddr, PINDEX newPort)
723 { dataValue = newAddr; portNumber = newPort; validData = true; }
724
725 /**Report the value of the stored data for this class */
ReadData()726 PIPSocket::Address ReadData() { return dataValue; }
727
728 //@}
729 protected:
730 /** Take the data value for this particular IAX2Ie and copy into the
731 memory region.*/
732 virtual void WriteBinary(BYTE *data);
733
734 /**The actual ip address data stored in a IAX2IeSockaddrIn class */
735 PIPSocket::Address dataValue;
736
737 /**The actual port number data stored in a IAX2IeSockaddrIn class */
738 PINDEX portNumber;
739 };
740
741 ////////////////////////////////////////////////////////////////////////////////
742 /**An Information Element that contains the number/extension being called.*/
743 class IAX2IeCalledNumber : public IAX2IeString
744 {
745 PCLASSINFO(IAX2IeCalledNumber, IAX2IeString);
746 public:
747 /**Constructor from data read from the network.
748
749 Contents are undefined if network data is bogus.*/
IAX2IeCalledNumber(BYTE length,BYTE * srcData)750 IAX2IeCalledNumber(BYTE length, BYTE *srcData)
751 : IAX2IeString(length, srcData) {};
752
753 /**Initialise to the supplied string value */
IAX2IeCalledNumber(const PString & newValue)754 IAX2IeCalledNumber(const PString & newValue) { SetData(newValue); }
755
756 /**print this class (nicely) to the designated stream*/
757 virtual void PrintOn(ostream & str) const;
758
759 /**Get the key value for this particular Information Element class */
GetKeyValue()760 virtual BYTE GetKeyValue() const { return ie_calledNumber; }
761
762 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
763 structure. This is done on processing an incoming frame which
764 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)765 virtual void StoreDataIn(IAX2IeData &res) { res.calledNumber = dataValue; }
766 protected:
767 };
768 ////////////////////////////////////////////////////////////////////////////////
769 /**An Information Element that contains the Calling number (number
770 trying to make call?)*/
771 class IAX2IeCallingNumber : public IAX2IeString
772 {
773 PCLASSINFO(IAX2IeCallingNumber, IAX2IeString);
774 public:
775 /** Constructor from data read from the network.
776
777 Contents are undefined if the network data is bogus. */
IAX2IeCallingNumber(BYTE length,BYTE * srcData)778 IAX2IeCallingNumber(BYTE length, BYTE *srcData)
779 : IAX2IeString(length, srcData) { };
780
781 /**Initialise to the supplied string value */
IAX2IeCallingNumber(const PString & newValue)782 IAX2IeCallingNumber(const PString & newValue) { SetData(newValue); }
783
784 /**print this class (nicely) to the designated stream*/
785 virtual void PrintOn(ostream & str) const;
786
787 /**Get the key value for this particular Information Element class */
GetKeyValue()788 virtual BYTE GetKeyValue() const { return ie_callingNumber; }
789
790 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
791 structure. This is done on processing an incoming frame which
792 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)793 virtual void StoreDataIn(IAX2IeData &res)
794 { res.callingNumber = dataValue; }
795 protected:
796 };
797
798 ///////////////////////////////////////////////////////////////////////
799 /**An Information Element that contains the calling number ANI (for billing)*/
800 class IAX2IeCallingAni : public IAX2IeString
801 {
802 PCLASSINFO(IAX2IeCallingAni, IAX2IeString);
803 public:
804 /** Constructor from data read from the network.
805
806 Contents are undefined if the network data is bogus. */
IAX2IeCallingAni(BYTE length,BYTE * srcData)807 IAX2IeCallingAni(BYTE length, BYTE *srcData)
808 : IAX2IeString(length, srcData) { };
809
810 /**Initialise to the supplied string value */
IAX2IeCallingAni(const PString & newValue)811 IAX2IeCallingAni(const PString & newValue) { SetData(newValue); }
812
813 /**print this class (nicely) to the designated stream*/
814 virtual void PrintOn(ostream & str) const;
815
816 /**Get the key value for this particular Information Element class */
GetKeyValue()817 virtual BYTE GetKeyValue() const { return ie_callingAni; }
818
819 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
820 structure. This is done on processing an incoming frame which
821 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)822 virtual void StoreDataIn(IAX2IeData &res)
823 { res.callingAni = dataValue; }
824 protected:
825 };
826
827 ///////////////////////////////////////////////////////////////////////
828 /**An Information Element that contains name of the the person making the call*/
829 class IAX2IeCallingName : public IAX2IeString
830 {
831 PCLASSINFO(IAX2IeCallingName, IAX2IeString);
832 public:
833 /** Constructor from data read from the network.
834
835 Contents are undefined if the network data is bogus/invalid */
IAX2IeCallingName(BYTE length,BYTE * srcData)836 IAX2IeCallingName(BYTE length, BYTE *srcData)
837 : IAX2IeString(length, srcData) { };
838
839 /**Initialise to the supplied string value */
IAX2IeCallingName(const PString & newValue)840 IAX2IeCallingName(const PString & newValue) { SetData(newValue); }
841
842 /**print this class (nicely) to the designated stream*/
843 virtual void PrintOn(ostream & str) const;
844
845 /**Get the key value for this particular Information Element class */
GetKeyValue()846 virtual BYTE GetKeyValue() const { return ie_callingName; }
847
848 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
849 structure. This is done on processing an incoming frame which
850 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)851 virtual void StoreDataIn(IAX2IeData &res)
852 { res.callingName = dataValue; }
853 protected:
854 };
855
856 ///////////////////////////////////////////////////////////////////////
857 /**An Information Element that contains the context for this number*/
858 class IAX2IeCalledContext : public IAX2IeString
859 {
860 PCLASSINFO(IAX2IeCalledContext, IAX2IeString);
861 public:
862 /** Constructor from data read from the network.
863
864 Contents are undefined if the network data is bogus/invalid */
IAX2IeCalledContext(BYTE length,BYTE * srcData)865 IAX2IeCalledContext(BYTE length, BYTE *srcData) : IAX2IeString(length, srcData) { };
866
867 /**Initialise to the supplied string value */
IAX2IeCalledContext(const PString & newValue)868 IAX2IeCalledContext(const PString & newValue) { SetData(newValue); }
869
870 /**print this class (nicely) to the designated stream*/
871 virtual void PrintOn(ostream & str) const;
872
873 /**Get the key value for this particular Information Element class */
GetKeyValue()874 virtual BYTE GetKeyValue() const { return ie_calledContext; }
875
876 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
877 structure. This is done on processing an incoming frame which
878 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)879 virtual void StoreDataIn(IAX2IeData &res)
880 { res.calledContext = dataValue; }
881 protected:
882 };
883
884 ///////////////////////////////////////////////////////////////////////
885 /**An Information Element that contains the userName (peer or user) for authentication*/
886 class IAX2IeUserName : public IAX2IeString
887 {
888 PCLASSINFO(IAX2IeUserName, IAX2IeString);
889 public:
890 /** Constructor from data read from the network.
891
892 Contents are undefined if the network data is bogus/invalid */
IAX2IeUserName(BYTE length,BYTE * srcData)893 IAX2IeUserName(BYTE length, BYTE *srcData) : IAX2IeString(length, srcData) { };
894
895 /**Initialise to the supplied string value */
IAX2IeUserName(const PString & newValue)896 IAX2IeUserName(const PString & newValue) { SetData(newValue); }
897
898 /**print this class (nicely) to the designated stream*/
899 virtual void PrintOn(ostream & str) const;
900
901 /**Get the key value for this particular Information Element class */
GetKeyValue()902 virtual BYTE GetKeyValue() const { return ie_userName; }
903
904 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
905 structure. This is done on processing an incoming frame which
906 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)907 virtual void StoreDataIn(IAX2IeData &res) { res.userName = dataValue; }
908 protected:
909 };
910
911 ///////////////////////////////////////////////////////////////////////
912 /**An Information Element that contains the password (for authentication)*/
913 class IAX2IePassword : public IAX2IeString
914 {
915 PCLASSINFO(IAX2IePassword, IAX2IeString);
916 public:
917 /** Constructor from data read from the network.
918
919 Contents are undefined if the network data is bogus/invalid */
IAX2IePassword(BYTE length,BYTE * srcData)920 IAX2IePassword(BYTE length, BYTE *srcData) : IAX2IeString(length, srcData) { };
921
922 /**Initialise to the supplied string value */
IAX2IePassword(const PString & newValue)923 IAX2IePassword(const PString & newValue) { SetData(newValue); }
924
925 /**print this class (nicely) to the designated stream*/
926 virtual void PrintOn(ostream & str) const;
927
928 /**Get the key value for this particular Information Element class */
GetKeyValue()929 virtual BYTE GetKeyValue() const { return ie_password; }
930
931 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
932 structure. This is done on processing an incoming frame which
933 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)934 virtual void StoreDataIn(IAX2IeData &res) { res.password = dataValue; }
935 protected:
936 };
937
938 ///////////////////////////////////////////////////////////////////////
939 /**An Information Element that contains the actual codecs available*/
940 class IAX2IeCapability : public IAX2IeUInt
941 {
942 PCLASSINFO(IAX2IeCapability, IAX2IeUInt);
943 public:
944 /** Constructor from data read from the network.
945
946 Contents are undefined if the network data is bogus/invalid */
IAX2IeCapability(BYTE length,BYTE * srcData)947 IAX2IeCapability(BYTE length, BYTE *srcData) : IAX2IeUInt(length, srcData) { };
948
949 /**Construct with a predefined value (Typically used prior to transmission)*/
IAX2IeCapability(unsigned int newValue)950 IAX2IeCapability(unsigned int newValue) : IAX2IeUInt(newValue) { }
951
952 /**print this class (nicely) to the designated stream*/
953 virtual void PrintOn(ostream & str) const;
954
955 /**Get the key value for this particular Information Element class */
GetKeyValue()956 virtual BYTE GetKeyValue() const { return ie_capability; }
957
958 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
959 structure. This is done on processing an incoming frame which
960 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)961 virtual void StoreDataIn(IAX2IeData &res) { res.capability = dataValue; }
962 protected:
963 };
964
965 ///////////////////////////////////////////////////////////////////////
966 /**An Information Element that contains the desired codec format*/
967 class IAX2IeFormat : public IAX2IeUInt
968 {
969 PCLASSINFO(IAX2IeFormat, IAX2IeUInt);
970 public:
971 /** Constructor from data read from the network.
972
973 Contents are undefined if the network data is bogus/invalid */
IAX2IeFormat(BYTE length,BYTE * srcData)974 IAX2IeFormat(BYTE length, BYTE *srcData) : IAX2IeUInt(length, srcData) { };
975
976 /**Construct with a predefined value (Typically used prior to transmission)*/
IAX2IeFormat(unsigned int newValue)977 IAX2IeFormat(unsigned int newValue) : IAX2IeUInt(newValue) { }
978
979 /**print this class (nicely) to the designated stream*/
980 virtual void PrintOn(ostream & str) const;
981
982 /**Get the key value for this particular Information Element class */
GetKeyValue()983 virtual BYTE GetKeyValue() const { return ie_format; }
984
985 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
986 structure. This is done on processing an incoming frame which
987 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)988 virtual void StoreDataIn(IAX2IeData &res) { res.format = dataValue; }
989 protected:
990 };
991
992 ///////////////////////////////////////////////////////////////////////
993 /**An Information Element that contains the desired language*/
994 class IAX2IeLanguage : public IAX2IeString
995 {
996 PCLASSINFO(IAX2IeLanguage, IAX2IeString);
997 public:
998 /** Constructor from data read from the network.
999
1000 Contents are undefined if the network data is bogus/invalid */
IAX2IeLanguage(BYTE length,BYTE * srcData)1001 IAX2IeLanguage(BYTE length, BYTE *srcData) : IAX2IeString(length, srcData) { };
1002
1003 /**Initialise to the supplied string value */
IAX2IeLanguage(const PString & newValue)1004 IAX2IeLanguage(const PString & newValue) { SetData(newValue); }
1005
1006 /**print this class (nicely) to the designated stream*/
1007 virtual void PrintOn(ostream & str) const;
1008
1009 /**Get the key value for this particular Information Element class */
GetKeyValue()1010 virtual BYTE GetKeyValue() const { return ie_language; }
1011
1012 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1013 structure. This is done on processing an incoming frame which
1014 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1015 virtual void StoreDataIn(IAX2IeData &res) { res.language = dataValue; }
1016 protected:
1017 };
1018
1019 //////////////////////////////////////////////////////////////////////
1020 /**An Information Element that contains the protocol version*/
1021 class IAX2IeVersion : public IAX2IeShort
1022 {
1023 PCLASSINFO(IAX2IeVersion, IAX2IeShort);
1024 public:
1025 /** Constructor from data read from the network.
1026
1027 Contents are undefined if the network data is bogus/invalid */
IAX2IeVersion(BYTE length,BYTE * srcData)1028 IAX2IeVersion(BYTE length, BYTE *srcData) : IAX2IeShort(length, srcData) { };
1029
1030 /**Construct to the one possible value - version 2 */
IAX2IeVersion()1031 IAX2IeVersion() { dataValue = 2; validData = true; }
1032
1033 /**print this class (nicely) to the designated stream*/
1034 virtual void PrintOn(ostream & str) const;
1035
1036 /**Get the key value for this particular Information Element class */
GetKeyValue()1037 virtual BYTE GetKeyValue() const { return ie_version; }
1038
1039 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1040 structure. This is done on processing an incoming frame which
1041 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1042 virtual void StoreDataIn(IAX2IeData &res) { res.version = dataValue; }
1043 protected:
1044 };
1045
1046 ///////////////////////////////////////////////////////////////////////
1047 /**An Information Element that contains the CPE ADSI capability*/
1048 class IAX2IeAdsicpe : public IAX2IeShort
1049 {
1050 PCLASSINFO(IAX2IeAdsicpe, IAX2IeShort);
1051 public:
1052 /** Constructor from data read from the network.
1053
1054 Contents are undefined if the network data is bogus/invalid */
IAX2IeAdsicpe(BYTE length,BYTE * srcData)1055 IAX2IeAdsicpe(BYTE length, BYTE *srcData) : IAX2IeShort(length, srcData) { };
1056
1057 /**print this class (nicely) to the designated stream*/
1058 virtual void PrintOn(ostream & str) const;
1059
1060 /**Get the key value for this particular Information Element class */
GetKeyValue()1061 virtual BYTE GetKeyValue() const { return ie_adsicpe; }
1062
1063 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1064 structure. This is done on processing an incoming frame which
1065 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1066 virtual void StoreDataIn(IAX2IeData &res) { res.adsicpe = dataValue; }
1067 protected:
1068 };
1069
1070 ///////////////////////////////////////////////////////////////////////
1071 /**An Information Element that contains the originally dialed DNID*/
1072 class IAX2IeDnid : public IAX2IeString
1073 {
1074 PCLASSINFO(IAX2IeDnid, IAX2IeString);
1075 public:
1076 /** Constructor from data read from the network.
1077
1078 Contents are undefined if the network data is bogus/invalid */
IAX2IeDnid(BYTE length,BYTE * srcData)1079 IAX2IeDnid(BYTE length, BYTE *srcData) : IAX2IeString(length, srcData) { };
1080
1081 /**Initialise to the supplied string value */
IAX2IeDnid(const PString & newValue)1082 IAX2IeDnid(const PString & newValue) { SetData(newValue); }
1083
1084 /**print this class (nicely) to the designated stream*/
1085 virtual void PrintOn(ostream & str) const;
1086
1087 /**Get the key value for this particular Information Element class */
GetKeyValue()1088 virtual BYTE GetKeyValue() const { return ie_dnid; }
1089
1090 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1091 structure. This is done on processing an incoming frame which
1092 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1093 virtual void StoreDataIn(IAX2IeData &res) { res.dnid = dataValue; }
1094 protected:
1095 };
1096
1097 ///////////////////////////////////////////////////////////////////////
1098 /**An Information Element that contains the authentication methods */
1099 class IAX2IeAuthMethods : public IAX2IeShort
1100 {
1101 PCLASSINFO(IAX2IeAuthMethods, IAX2IeShort);
1102 public:
1103 /** Constructor from data read from the network.
1104
1105 Contents are undefined if the network data is bogus/invalid */
IAX2IeAuthMethods(BYTE length,BYTE * srcData)1106 IAX2IeAuthMethods(BYTE length, BYTE *srcData) : IAX2IeShort(length, srcData) { };
1107
1108 /** Initialise to the supplied short value, which is usually done prior to transmission*/
IAX2IeAuthMethods(short newValue)1109 IAX2IeAuthMethods(short newValue) { SetData(newValue); }
1110
1111 /**print this class (nicely) to the designated stream*/
1112 virtual void PrintOn(ostream & str) const;
1113
1114 /**Get the key value for this particular Information Element class */
GetKeyValue()1115 virtual BYTE GetKeyValue() const { return ie_authMethods; }
1116
1117 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1118 structure. This is done on processing an incoming frame which
1119 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1120 virtual void StoreDataIn(IAX2IeData &res) { res.authMethods = dataValue; }
1121
1122 /**Return true if the supplied value has the RSA key on*/
IsRsaAuthentication(short testValue)1123 static PBoolean IsRsaAuthentication(short testValue) { return InternalIsRsa(testValue); }
1124
1125 /**Return true if the supplied value has the MD5 key on*/
IsMd5Authentication(short testValue)1126 static PBoolean IsMd5Authentication(short testValue) { return InternalIsMd5(testValue); }
1127
1128 /**Return true if the supplied value has the plain text key on*/
IsPlainTextAuthentication(short testValue)1129 static PBoolean IsPlainTextAuthentication(short testValue) { return InternalIsPlainText(testValue); }
1130
1131 /**Return true if the internal value has the RSA key on*/
IsRsaAuthentication()1132 PBoolean IsRsaAuthentication() { if (IsValid()) return InternalIsRsa(dataValue); else return false; }
1133
1134 /**Return true if the internal value has the MD5 key on*/
IsMd5Authentication()1135 PBoolean IsMd5Authentication() { if (IsValid()) return InternalIsMd5(dataValue); else return false; }
1136
1137 /**Return true if the internal value has the plain text key on*/
IsPlainTextAuthentication()1138 PBoolean IsPlainTextAuthentication() { if (IsValid()) return InternalIsPlainText(dataValue); else return false; }
1139
1140 protected:
1141
1142 /**Return true if the supplied value has the RSA key on*/
InternalIsRsa(short testValue)1143 static PBoolean InternalIsRsa(short testValue) { return testValue & 0x04; }
1144
1145 /**Return true if the supplied value has the MD5 key on*/
InternalIsMd5(short testValue)1146 static PBoolean InternalIsMd5(short testValue) { return testValue & 0x02; }
1147
1148 /**Return true if the supplied value has the plain text key on*/
InternalIsPlainText(short testValue)1149 static PBoolean InternalIsPlainText(short testValue) { return testValue & 0x01; }
1150 };
1151
1152 ///////////////////////////////////////////////////////////////////////
1153 /**An Information Element that contains the challenge data for MD5/RSA*/
1154 class IAX2IeChallenge : public IAX2IeString
1155 {
1156 PCLASSINFO(IAX2IeChallenge, IAX2IeString);
1157 public:
1158 /** Constructor from data read from the network.
1159
1160 Contents are undefined if the network data is bogus/invalid */
IAX2IeChallenge(BYTE length,BYTE * srcData)1161 IAX2IeChallenge(BYTE length, BYTE *srcData) : IAX2IeString(length, srcData) { };
1162
1163 /**Initialise to the supplied string value */
IAX2IeChallenge(const PString & newValue)1164 IAX2IeChallenge(const PString & newValue) { SetData(newValue); }
1165
1166 /**print this class (nicely) to the designated stream*/
1167 virtual void PrintOn(ostream & str) const;
1168
1169 /**Get the key value for this particular Information Element class */
GetKeyValue()1170 virtual BYTE GetKeyValue() const { return ie_challenge; }
1171
1172 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1173 structure. This is done on processing an incoming frame which
1174 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1175 virtual void StoreDataIn(IAX2IeData &res) { res.challenge = dataValue; }
1176 protected:
1177 };
1178
1179 ///////////////////////////////////////////////////////////////////////
1180 /**An Information Element that contains the MD5 chaallenge result*/
1181 class IAX2IeMd5Result : public IAX2IeString
1182 {
1183 PCLASSINFO(IAX2IeMd5Result, IAX2IeString);
1184 public:
1185 /** Constructor from data read from the network.
1186
1187 Contents are undefined if the network data is bogus/invalid */
IAX2IeMd5Result(BYTE length,BYTE * srcData)1188 IAX2IeMd5Result(BYTE length, BYTE *srcData) : IAX2IeString(length, srcData) { };
1189
1190 /**Initialise to the supplied string value */
IAX2IeMd5Result(const PString & newValue)1191 IAX2IeMd5Result(const PString & newValue) { SetData(newValue); }
1192
1193 /**Take the challenge and password, calculate the result, and store */
1194 IAX2IeMd5Result(const PString & challenge, const PString & password);
1195
1196 /**Take the supplied Iax2Encrption arguement, calculate the result, and store */
1197 IAX2IeMd5Result(IAX2Encryption & encryption);
1198
1199 /**Initialize the internal structurees */
1200 void InitializeChallengePassword(const PString & newChallenge, const PString & newPassword);
1201
1202 /**print this class (nicely) to the designated stream*/
1203 virtual void PrintOn(ostream & str) const;
1204
1205 /**Get the key value for this particular Information Element class */
GetKeyValue()1206 virtual BYTE GetKeyValue() const { return ie_md5Result; }
1207
1208 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1209 structure. This is done on processing an incoming frame which
1210 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1211 virtual void StoreDataIn(IAX2IeData &res) { res.md5Result = dataValue; }
1212
1213 /**GetAccess to the stomach, which is the concatanation of the various
1214 components used to make a key */
GetDataBlock()1215 PBYTEArray & GetDataBlock() { return dataBlock; }
1216
1217 protected:
1218
1219 /**The contents of the stomach in a binary block */
1220 PBYTEArray dataBlock;
1221 };
1222
1223 ///////////////////////////////////////////////////////////////////////
1224 /**An Information Element that contains the RSA challenge result*/
1225 class IAX2IeRsaResult : public IAX2IeString
1226 {
1227 PCLASSINFO(IAX2IeRsaResult, IAX2IeString);
1228 public:
1229 /** Constructor from data read from the network.
1230
1231 Contents are undefined if the network data is bogus/invalid */
IAX2IeRsaResult(BYTE length,BYTE * srcData)1232 IAX2IeRsaResult(BYTE length, BYTE *srcData) : IAX2IeString(length, srcData) { };
1233
1234 /**Initialise to the supplied string value */
IAX2IeRsaResult(const PString & newValue)1235 IAX2IeRsaResult(const PString & newValue) { SetData(newValue); }
1236
1237 /**print this class (nicely) to the designated stream*/
1238 virtual void PrintOn(ostream & str) const;
1239
1240 /**Get the key value for this particular Information Element class */
GetKeyValue()1241 virtual BYTE GetKeyValue() const { return ie_rsaResult; }
1242
1243 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1244 structure. This is done on processing an incoming frame which
1245 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1246 virtual void StoreDataIn(IAX2IeData &res) { res.rsaResult = dataValue; }
1247 protected:
1248 };
1249
1250 ///////////////////////////////////////////////////////////////////////
1251 /**An Information Element that contains the apparent daddress of peer*/
1252 class IAX2IeApparentAddr : public IAX2IeSockaddrIn
1253 {
1254 PCLASSINFO(IAX2IeApparentAddr, IAX2IeSockaddrIn);
1255 public:
1256 /** Constructor from data read from the network.
1257
1258 Contents are undefined if the network data is bogus/invalid */
IAX2IeApparentAddr(BYTE length,BYTE * srcData)1259 IAX2IeApparentAddr(BYTE length, BYTE *srcData) : IAX2IeSockaddrIn(length, srcData) { };
1260
1261 /**Desttructor, which does nothing */
~IAX2IeApparentAddr()1262 ~IAX2IeApparentAddr() { };
1263
1264 /**print this class (nicely) to the designated stream*/
1265 virtual void PrintOn(ostream & str) const;
1266
1267 /**Get the key value for this particular Information Element class */
GetKeyValue()1268 virtual BYTE GetKeyValue() const { return ie_apparentAddr; }
1269
1270 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1271 structure. This is done on processing an incoming frame which
1272 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1273 virtual void StoreDataIn(IAX2IeData &res) { res.apparentAddr = dataValue; }
1274 protected:
1275 };
1276
1277 ///////////////////////////////////////////////////////////////////////
1278 /**An Information Element that contains the time when to refresh registration*/
1279 class IAX2IeRefresh : public IAX2IeShort
1280 {
1281 PCLASSINFO(IAX2IeRefresh, IAX2IeShort);
1282 public:
1283 /** Constructor from data read from the network.
1284
1285 Contents are undefined if the network data is bogus/invalid */
IAX2IeRefresh(BYTE length,BYTE * srcData)1286 IAX2IeRefresh(BYTE length, BYTE *srcData) : IAX2IeShort(length, srcData) { };
1287
1288 /** Constructor for an outgoing refresh information element */
IAX2IeRefresh(short refreshTime)1289 IAX2IeRefresh(short refreshTime) : IAX2IeShort(refreshTime) { };
1290
1291 /**print this class (nicely) to the designated stream*/
1292 virtual void PrintOn(ostream & str) const;
1293
1294 /**Get the key value for this particular Information Element class */
GetKeyValue()1295 virtual BYTE GetKeyValue() const { return ie_refresh; }
1296
1297 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1298 structure. This is done on processing an incoming frame which
1299 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1300 virtual void StoreDataIn(IAX2IeData &res) { res.refresh = dataValue; }
1301 protected:
1302 };
1303
1304 ///////////////////////////////////////////////////////////////////////
1305 /**An Information Element that contains the dial plan status*/
1306 class IAX2IeDpStatus : public IAX2IeShort
1307 {
1308 PCLASSINFO(IAX2IeDpStatus, IAX2IeShort);
1309 public:
1310 /** Constructor from data read from the network.
1311
1312 Contents are undefined if the network data is bogus/invalid */
IAX2IeDpStatus(BYTE length,BYTE * srcData)1313 IAX2IeDpStatus(BYTE length, BYTE *srcData) : IAX2IeShort(length, srcData) { };
1314
1315 /**print this class (nicely) to the designated stream*/
1316 virtual void PrintOn(ostream & str) const;
1317
1318 /**Get the key value for this particular Information Element class */
GetKeyValue()1319 virtual BYTE GetKeyValue() const { return ie_dpStatus; }
1320
1321 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1322 structure. This is done on processing an incoming frame which
1323 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1324 virtual void StoreDataIn(IAX2IeData &res) { res.dpStatus = dataValue; }
1325 protected:
1326 };
1327
1328 ///////////////////////////////////////////////////////////////////////
1329 /**An Information Element that contains the call number of peer*/
1330 class IAX2IeCallNo : public IAX2IeShort
1331 {
1332 PCLASSINFO(IAX2IeCallNo, IAX2IeShort);
1333 public:
1334 /** Constructor from data read from the network.
1335
1336 Contents are undefined if the network data is bogus/invalid */
IAX2IeCallNo(BYTE length,BYTE * srcData)1337 IAX2IeCallNo(BYTE length, BYTE *srcData) : IAX2IeShort(length, srcData) { };
1338
1339 /**print this class (nicely) to the designated stream*/
1340 virtual void PrintOn(ostream & str) const;
1341
1342 /**Get the key value for this particular Information Element class */
GetKeyValue()1343 virtual BYTE GetKeyValue() const { return ie_callNo; }
1344
1345 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1346 structure. This is done on processing an incoming frame which
1347 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1348 virtual void StoreDataIn(IAX2IeData &res) { res.callNo = dataValue; }
1349 protected:
1350 };
1351
1352 ///////////////////////////////////////////////////////////////////////
1353 /**An Information Element that contains the cause*/
1354 class IAX2IeCause : public IAX2IeString
1355 {
1356 PCLASSINFO(IAX2IeCause, IAX2IeString);
1357 public:
1358 /** Constructor from data read from the network.
1359
1360 Contents are undefined if the network data is bogus/invalid */
IAX2IeCause(BYTE length,BYTE * srcData)1361 IAX2IeCause(BYTE length, BYTE *srcData) : IAX2IeString(length, srcData) { };
1362
1363 /**Construct with a predefined value (Typically used prior to transmission)*/
IAX2IeCause(const PString & newValue)1364 IAX2IeCause(const PString & newValue) : IAX2IeString(newValue) { }
1365
1366 /**Construct with a predefined value (Typically used prior to transmission)*/
IAX2IeCause(const char * newValue)1367 IAX2IeCause(const char *newValue) : IAX2IeString(newValue) { }
1368
1369 /**print this class (nicely) to the designated stream*/
1370 virtual void PrintOn(ostream & str) const;
1371
1372 /**Get the key value for this particular Information Element class */
GetKeyValue()1373 virtual BYTE GetKeyValue() const { return ie_cause; }
1374
1375 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1376 structure. This is done on processing an incoming frame which
1377 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1378 virtual void StoreDataIn(IAX2IeData &res) { res.cause = dataValue; }
1379 protected:
1380 };
1381
1382 ///////////////////////////////////////////////////////////////////////
1383 /**An Information Element that contains an unknown IAX command*/
1384 class IAX2IeIaxUnknown : public IAX2IeByte
1385 {
1386 PCLASSINFO(IAX2IeIaxUnknown, IAX2IeByte);
1387 public:
1388 /** Constructor from data read from the network.
1389
1390 Contents are undefined if the network data is bogus/invalid */
IAX2IeIaxUnknown(BYTE length,BYTE * srcData)1391 IAX2IeIaxUnknown(BYTE length, BYTE *srcData) : IAX2IeByte(length, srcData) { };
1392
1393 /**Constructor when sending an unknown message*/
IAX2IeIaxUnknown(BYTE newValue)1394 IAX2IeIaxUnknown(BYTE newValue) : IAX2IeByte(newValue) { }
1395
1396 /**print this class (nicely) to the designated stream*/
1397 virtual void PrintOn(ostream & str) const;
1398
1399 /**Get the key value for this particular Information Element class */
GetKeyValue()1400 virtual BYTE GetKeyValue() const { return ie_iaxUnknown; }
1401
1402 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1403 structure. This is done on processing an incoming frame which
1404 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1405 virtual void StoreDataIn(IAX2IeData &res) { res.iaxUnknown = dataValue; }
1406 protected:
1407 };
1408
1409 ///////////////////////////////////////////////////////////////////////
1410 /**An Information Element that contains how many messages are waiting*/
1411 class IAX2IeMsgCount : public IAX2IeShort
1412 {
1413 PCLASSINFO(IAX2IeMsgCount, IAX2IeShort);
1414 public:
1415 /** Constructor from data read from the network.
1416
1417 Contents are undefined if the network data is bogus/invalid */
IAX2IeMsgCount(BYTE length,BYTE * srcData)1418 IAX2IeMsgCount(BYTE length, BYTE *srcData) : IAX2IeShort(length, srcData) { };
1419
1420 /**print this class (nicely) to the designated stream*/
1421 virtual void PrintOn(ostream & str) const;
1422
1423 /**Get the key value for this particular Information Element class */
GetKeyValue()1424 virtual BYTE GetKeyValue() const { return ie_msgCount; }
1425
1426 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1427 structure. This is done on processing an incoming frame which
1428 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1429 virtual void StoreDataIn(IAX2IeData &res) { res.msgCount = dataValue; }
1430 protected:
1431 };
1432
1433 ///////////////////////////////////////////////////////////////////////
1434 /**An Information Element that contains a request for auto-answering*/
1435 class IAX2IeAutoAnswer : public IAX2IeNone
1436 {
1437 PCLASSINFO(IAX2IeAutoAnswer, IAX2IeNone);
1438 public:
1439 /** Constructor from data read from the network.
1440
1441 Contents are undefined if the network data is bogus/invalid */
IAX2IeAutoAnswer(BYTE length,BYTE * srcData)1442 IAX2IeAutoAnswer(BYTE length, BYTE *srcData) : IAX2IeNone(length, srcData) { };
1443
1444 /**print this class (nicely) to the designated stream*/
1445 virtual void PrintOn(ostream & str) const;
1446
1447 /**Get the key value for this particular Information Element class */
GetKeyValue()1448 virtual BYTE GetKeyValue() const { return ie_autoAnswer; }
1449
1450 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1451 structure. This is done on processing an incoming frame which
1452 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1453 virtual void StoreDataIn(IAX2IeData &res) { res.autoAnswer = true;; }
1454 protected:
1455 };
1456
1457 ///////////////////////////////////////////////////////////////////////
1458 /**An Information Element that contains a request for music on hold with Quelch*/
1459 class IAX2IeMusicOnHold : public IAX2IeNone
1460 {
1461 PCLASSINFO(IAX2IeMusicOnHold, IAX2IeNone);
1462 public:
1463 /** Constructor from data read from the network.
1464
1465 Contents are undefined if the network data is bogus/invalid */
IAX2IeMusicOnHold(BYTE length,BYTE * srcData)1466 IAX2IeMusicOnHold(BYTE length, BYTE *srcData) : IAX2IeNone(length, srcData) { };
1467
1468 /**Construct with a predefined value (Typically used prior to transmission)*/
IAX2IeMusicOnHold()1469 IAX2IeMusicOnHold() : IAX2IeNone() { };
1470
1471 /**print this class (nicely) to the designated stream*/
1472 virtual void PrintOn(ostream & str) const;
1473
1474 /**Get the key value for this particular Information Element class */
GetKeyValue()1475 virtual BYTE GetKeyValue() const { return ie_musicOnHold; }
1476
1477 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1478 structure. This is done on processing an incoming frame which
1479 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1480 virtual void StoreDataIn(IAX2IeData &res) { res.musicOnHold = true; }
1481 protected:
1482 };
1483
1484 ///////////////////////////////////////////////////////////////////////
1485 /**An Information Element that contains a transfer request identifier*/
1486 class IAX2IeTransferId : public IAX2IeInt
1487 {
1488 PCLASSINFO(IAX2IeTransferId, IAX2IeInt);
1489 public:
1490 /** Constructor from data read from the network.
1491
1492 Contents are undefined if the network data is bogus/invalid */
IAX2IeTransferId(BYTE length,BYTE * srcData)1493 IAX2IeTransferId(BYTE length, BYTE *srcData) : IAX2IeInt(length, srcData) { };
1494
1495 /**print this class (nicely) to the designated stream*/
1496 virtual void PrintOn(ostream & str) const;
1497
1498 /**Get the key value for this particular Information Element class */
GetKeyValue()1499 virtual BYTE GetKeyValue() const { return ie_transferId; }
1500
1501 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1502 structure. This is done on processing an incoming frame which
1503 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1504 virtual void StoreDataIn(IAX2IeData &res) { res.transferId = dataValue; }
1505 protected:
1506 };
1507
1508 ///////////////////////////////////////////////////////////////////////
1509 /**An Information Element that contains the referring DNIs*/
1510 class IAX2IeRdnis : public IAX2IeString
1511 {
1512 PCLASSINFO(IAX2IeRdnis, IAX2IeString);
1513 public:
1514 /** Constructor from data read from the network.
1515
1516 Contents are undefined if the network data is bogus/invalid */
IAX2IeRdnis(BYTE length,BYTE * srcData)1517 IAX2IeRdnis(BYTE length, BYTE *srcData) : IAX2IeString(length, srcData) { };
1518
1519 /**print this class (nicely) to the designated stream*/
1520 virtual void PrintOn(ostream & str) const;
1521
1522 /**Get the key value for this particular Information Element class */
GetKeyValue()1523 virtual BYTE GetKeyValue() const { return ie_rdnis; }
1524
1525 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1526 structure. This is done on processing an incoming frame which
1527 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1528 virtual void StoreDataIn(IAX2IeData &res) { res.rdnis = dataValue; }
1529 protected:
1530 };
1531
1532 ///////////////////////////////////////////////////////////////////////
1533 /**An Information Element that contains Provisioning - a great big data block */
1534 class IAX2IeProvisioning : public IAX2IeBlockOfData
1535 {
1536 PCLASSINFO(IAX2IeProvisioning, IAX2IeBlockOfData);
1537 public:
1538 /** Constructor from data read from the network.
1539
1540 Contents are undefined if the network data is bogus/invalid */
IAX2IeProvisioning(BYTE length,BYTE * srcData)1541 IAX2IeProvisioning(BYTE length, BYTE *srcData) : IAX2IeBlockOfData (length, srcData) { };
1542
1543 /**print this class (nicely) to the designated stream*/
1544 virtual void PrintOn(ostream & str) const;
1545
1546 /**Get the key value for this particular Information Element class */
GetKeyValue()1547 virtual BYTE GetKeyValue() const { return ie_provisioning; }
1548
1549 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1550 structure. This is done on processing an incoming frame which
1551 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData &)1552 virtual void StoreDataIn(IAX2IeData &/*res*/) { }
1553 protected:
1554 };
1555
1556 ///////////////////////////////////////////////////////////////////////
1557 /**An Information Element that contains aes provisioning info*/
1558 class IAX2IeAesProvisioning : public IAX2IeNone
1559 {
1560 PCLASSINFO(IAX2IeAesProvisioning, IAX2IeNone);
1561 public:
1562 /** Constructor from data read from the network.
1563
1564 Contents are undefined if the network data is bogus/invalid */
IAX2IeAesProvisioning(BYTE length,BYTE * srcData)1565 IAX2IeAesProvisioning(BYTE length, BYTE *srcData) : IAX2IeNone(length, srcData) { };
1566
1567 /**print this class (nicely) to the designated stream*/
1568 virtual void PrintOn(ostream & str) const;
1569
1570 /**Get the key value for this particular Information Element class */
GetKeyValue()1571 virtual BYTE GetKeyValue() const { return ie_aesProvisioning; }
1572
1573 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1574 structure. This is done on processing an incoming frame which
1575 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData &)1576 virtual void StoreDataIn(IAX2IeData &/*res*/) { }
1577 protected:
1578 };
1579
1580 ///////////////////////////////////////////////////////////////////////
1581 /**An Information Element that contains the date and time (in 32 bits)*/
1582 class IAX2IeDateTime : public IAX2IeDateAndTime
1583 {
1584 PCLASSINFO(IAX2IeDateTime, IAX2IeDateAndTime);
1585 public:
1586 /** Constructor from data read from the network.
1587
1588 Contents are undefined if the network data is bogus/invalid */
IAX2IeDateTime(BYTE length,BYTE * srcData)1589 IAX2IeDateTime(BYTE length, BYTE *srcData) : IAX2IeDateAndTime(length, srcData) { };
1590
1591 /**print this class (nicely) to the designated stream*/
1592 virtual void PrintOn(ostream & str) const;
1593
1594 /**Get the key value for this particular Information Element class */
GetKeyValue()1595 virtual BYTE GetKeyValue() const { return ie_dateTime; }
1596
1597 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1598 structure. This is done on processing an incoming frame which
1599 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1600 virtual void StoreDataIn(IAX2IeData &res) { res.dateTime = dataValue; }
1601 protected:
1602 };
1603
1604 ///////////////////////////////////////////////////////////////////////
1605 /**An Information Element that contains the device type*/
1606 class IAX2IeDeviceType : public IAX2IeString
1607 {
1608 PCLASSINFO(IAX2IeDeviceType, IAX2IeString);
1609 public:
1610 /** Constructor from data read from the network.
1611
1612 Contents are undefined if the network data is bogus/invalid */
IAX2IeDeviceType(BYTE length,BYTE * srcData)1613 IAX2IeDeviceType(BYTE length, BYTE *srcData) : IAX2IeString(length, srcData) { };
1614
1615 /**print this class (nicely) to the designated stream*/
1616 virtual void PrintOn(ostream & str) const;
1617
1618 /**Get the key value for this particular Information Element class */
GetKeyValue()1619 virtual BYTE GetKeyValue() const { return ie_deviceType; }
1620
1621 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1622 structure. This is done on processing an incoming frame which
1623 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1624 virtual void StoreDataIn(IAX2IeData &res) { res.deviceType = dataValue; }
1625 protected:
1626 };
1627
1628 ///////////////////////////////////////////////////////////////////////
1629 /**An Information Element that contains the service identifier*/
1630 class IAX2IeServiceIdent : public IAX2IeString
1631 {
1632 PCLASSINFO(IAX2IeServiceIdent, IAX2IeString);
1633 public:
1634 /** Constructor from data read from the network.
1635
1636 Contents are undefined if the network data is bogus/invalid */
IAX2IeServiceIdent(BYTE length,BYTE * srcData)1637 IAX2IeServiceIdent(BYTE length, BYTE *srcData) : IAX2IeString(length, srcData) { };
1638
1639 /**print this class (nicely) to the designated stream*/
1640 virtual void PrintOn(ostream & str) const;
1641
1642 /**Get the key value for this particular Information Element class */
GetKeyValue()1643 virtual BYTE GetKeyValue() const { return ie_serviceIdent; }
1644
1645 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1646 structure. This is done on processing an incoming frame which
1647 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1648 virtual void StoreDataIn(IAX2IeData &res) { res.serviceIdent = dataValue; }
1649 protected:
1650 };
1651
1652 ///////////////////////////////////////////////////////////////////////
1653 /**An Information Element that contains the firmware version*/
1654 class IAX2IeFirmwareVer : public IAX2IeShort
1655 {
1656 PCLASSINFO(IAX2IeFirmwareVer, IAX2IeShort);
1657 public:
1658 /** Constructor from data read from the network.
1659
1660 Contents are undefined if the network data is bogus/invalid */
IAX2IeFirmwareVer(BYTE length,BYTE * srcData)1661 IAX2IeFirmwareVer(BYTE length, BYTE *srcData) : IAX2IeShort(length, srcData) { };
1662
1663 /**print this class (nicely) to the designated stream*/
1664 virtual void PrintOn(ostream & str) const;
1665
1666 /**Get the key value for this particular Information Element class */
GetKeyValue()1667 virtual BYTE GetKeyValue() const { return ie_firmwareVer; }
1668
1669 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1670 structure. This is done on processing an incoming frame which
1671 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1672 virtual void StoreDataIn(IAX2IeData &res) { res.firmwareVer = dataValue; }
1673 protected:
1674 };
1675
1676 ///////////////////////////////////////////////////////////////////////
1677 /**An Information Element that contains firmware block description*/
1678 class IAX2IeFwBlockDesc : public IAX2IeUInt
1679 {
1680 PCLASSINFO(IAX2IeFwBlockDesc, IAX2IeUInt);
1681 public:
1682 /** Constructor from data read from the network.
1683
1684 Contents are undefined if the network data is bogus/invalid */
IAX2IeFwBlockDesc(BYTE length,BYTE * srcData)1685 IAX2IeFwBlockDesc(BYTE length, BYTE *srcData) : IAX2IeUInt(length, srcData) { };
1686
1687 /**Construct with a predefined value (Typically used prior to transmission)*/
IAX2IeFwBlockDesc(unsigned int newValue)1688 IAX2IeFwBlockDesc(unsigned int newValue) : IAX2IeUInt(newValue) { }
1689
1690 /**print this class (nicely) to the designated stream*/
1691 virtual void PrintOn(ostream & str) const;
1692
1693 /**Get the key value for this particular Information Element class */
GetKeyValue()1694 virtual BYTE GetKeyValue() const { return ie_fwBlockDesc; }
1695
1696 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1697 structure. This is done on processing an incoming frame which
1698 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1699 virtual void StoreDataIn(IAX2IeData &res) { res.fwBlockDesc = dataValue; }
1700 protected:
1701 };
1702
1703 ///////////////////////////////////////////////////////////////////////
1704 /**An Information Element that contains the block of firmware data */
1705 class IAX2IeFwBlockData : public IAX2IeBlockOfData
1706 {
1707 PCLASSINFO(IAX2IeFwBlockData, IAX2IeBlockOfData);
1708 public:
1709 /** Constructor from data read from the network.
1710
1711 Contents are undefined if the network data is bogus/invalid */
IAX2IeFwBlockData(BYTE length,BYTE * srcData)1712 IAX2IeFwBlockData(BYTE length, BYTE *srcData) : IAX2IeBlockOfData(length, srcData) { };
1713
1714 /**print this class (nicely) to the designated stream*/
1715 virtual void PrintOn(ostream & str) const;
1716
1717 /**Get the key value for this particular Information Element class */
GetKeyValue()1718 virtual BYTE GetKeyValue() const { return ie_fwBlockData; }
1719
1720 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1721 structure. This is done on processing an incoming frame which
1722 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1723 virtual void StoreDataIn(IAX2IeData &res) { res.fwBlockData = dataValue; }
1724 protected:
1725 };
1726
1727 ///////////////////////////////////////////////////////////////////////
1728 /**An Information Element that contains the Provisioning version*/
1729 class IAX2IeProvVer : public IAX2IeUInt
1730 {
1731 PCLASSINFO(IAX2IeProvVer, IAX2IeUInt);
1732 public:
1733 /** Constructor from data read from the network.
1734
1735 Contents are undefined if the network data is bogus/invalid */
IAX2IeProvVer(BYTE length,BYTE * srcData)1736 IAX2IeProvVer(BYTE length, BYTE *srcData) : IAX2IeUInt(length, srcData) { };
1737
1738 /**Construct with a predefined value (Typically used prior to transmission)*/
IAX2IeProvVer(unsigned int newValue)1739 IAX2IeProvVer(unsigned int newValue) : IAX2IeUInt(newValue) { }
1740
1741 /**print this class (nicely) to the designated stream*/
1742 virtual void PrintOn(ostream & str) const;
1743
1744 /**Get the key value for this particular Information Element class */
GetKeyValue()1745 virtual BYTE GetKeyValue() const { return ie_provVer; }
1746
1747 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1748 structure. This is done on processing an incoming frame which
1749 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1750 virtual void StoreDataIn(IAX2IeData &res) { res.provVer = dataValue; }
1751 protected:
1752 };
1753
1754 ///////////////////////////////////////////////////////////////////////
1755 /**An Information Element that contains the calling presentation*/
1756 class IAX2IeCallingPres : public IAX2IeByte
1757 {
1758 PCLASSINFO(IAX2IeCallingPres, IAX2IeByte);
1759 public:
1760 /** Constructor from data read from the network.
1761
1762 Contents are undefined if the network data is bogus/invalid */
IAX2IeCallingPres(BYTE length,BYTE * srcData)1763 IAX2IeCallingPres(BYTE length, BYTE *srcData) : IAX2IeByte(length, srcData) { };
1764
1765 /**print this class (nicely) to the designated stream*/
1766 virtual void PrintOn(ostream & str) const;
1767
1768 /**Get the key value for this particular Information Element class */
GetKeyValue()1769 virtual BYTE GetKeyValue() const { return ie_callingPres; }
1770
1771 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1772 structure. This is done on processing an incoming frame which
1773 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1774 virtual void StoreDataIn(IAX2IeData &res) { res.callingPres = dataValue; }
1775 protected:
1776 };
1777
1778 ///////////////////////////////////////////////////////////////////////
1779 /**An Information Element that contains the calling type of number*/
1780 class IAX2IeCallingTon : public IAX2IeByte
1781 {
1782 PCLASSINFO(IAX2IeCallingTon, IAX2IeByte);
1783 public:
1784 /** Constructor from data read from the network.
1785
1786 Contents are undefined if the network data is bogus/invalid */
IAX2IeCallingTon(BYTE length,BYTE * srcData)1787 IAX2IeCallingTon(BYTE length, BYTE *srcData) : IAX2IeByte(length, srcData) { };
1788
1789 /**print this class (nicely) to the designated stream*/
1790 virtual void PrintOn(ostream & str) const;
1791
1792 /**Get the key value for this particular Information Element class */
GetKeyValue()1793 virtual BYTE GetKeyValue() const { return ie_callingTon; }
1794
1795 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1796 structure. This is done on processing an incoming frame which
1797 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1798 virtual void StoreDataIn(IAX2IeData &res) { res.callingTon = dataValue; }
1799 protected:
1800 };
1801
1802 ///////////////////////////////////////////////////////////////////////
1803 /**An Information Element that contains the calling transit network select */
1804 class IAX2IeCallingTns : public IAX2IeUShort
1805 {
1806 PCLASSINFO(IAX2IeCallingTns, IAX2IeUShort);
1807 public:
1808 /** Constructor from data read from the network.
1809
1810 Contents are undefined if the network data is bogus/invalid */
IAX2IeCallingTns(BYTE length,BYTE * srcData)1811 IAX2IeCallingTns(BYTE length, BYTE *srcData) : IAX2IeUShort(length, srcData) { };
1812
1813 /**print this class (nicely) to the designated stream*/
1814 virtual void PrintOn(ostream & str) const;
1815
1816 /**Get the key value for this particular Information Element class */
GetKeyValue()1817 virtual BYTE GetKeyValue() const { return ie_callingTns; }
1818
1819 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1820 structure. This is done on processing an incoming frame which
1821 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1822 virtual void StoreDataIn(IAX2IeData &res) { res.callingTns = dataValue; }
1823 protected:
1824 };
1825
1826 ///////////////////////////////////////////////////////////////////////
1827 /**An Information Element that contains the supported sampling rates*/
1828 class IAX2IeSamplingRate : public IAX2IeUShort
1829 {
1830 PCLASSINFO(IAX2IeSamplingRate, IAX2IeUShort);
1831 public:
1832 /** Constructor from data read from the network.
1833
1834 Contents are undefined if the network data is bogus/invalid */
IAX2IeSamplingRate(BYTE length,BYTE * srcData)1835 IAX2IeSamplingRate(BYTE length, BYTE *srcData) : IAX2IeUShort(length, srcData) { };
1836
1837 /**print this class (nicely) to the designated stream*/
1838 virtual void PrintOn(ostream & str) const;
1839
1840 /**Get the key value for this particular Information Element class */
GetKeyValue()1841 virtual BYTE GetKeyValue() const { return ie_samplingRate; }
1842
1843 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1844 structure. This is done on processing an incoming frame which
1845 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1846 virtual void StoreDataIn(IAX2IeData &res) { res.samplingRate = dataValue; }
1847 protected:
1848 };
1849
1850 ///////////////////////////////////////////////////////////////////////
1851 /**An Information Element that contains the encryption format*/
1852 class IAX2IeEncryption : public IAX2IeUShort
1853 {
1854 PCLASSINFO(IAX2IeEncryption, IAX2IeUShort);
1855 public:
1856 /**Specify the different encryption methods */
1857 enum IAX2IeEncryptionMethod {
1858 encryptAes128 = 1 /*!< Specify to use AES 128 bit encryption */
1859 };
1860
1861 /**Constructor to specify a particular encryption method */
1862 IAX2IeEncryption(IAX2IeEncryptionMethod method = encryptAes128);
1863
1864 /** Constructor from data read from the network.
1865
1866 Contents are undefined if the network data is bogus/invalid */
IAX2IeEncryption(BYTE length,BYTE * srcData)1867 IAX2IeEncryption(BYTE length, BYTE *srcData) : IAX2IeUShort(length, srcData) { };
1868
1869 /**print this class (nicely) to the designated stream*/
1870 virtual void PrintOn(ostream & str) const;
1871
1872 /**Get the key value for this particular Information Element class */
GetKeyValue()1873 virtual BYTE GetKeyValue() const { return ie_encryption; }
1874
1875 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1876 structure. This is done on processing an incoming frame which
1877 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1878 virtual void StoreDataIn(IAX2IeData &res) { res.encryptionMethods = dataValue; }
1879 protected:
1880 };
1881
1882 ///////////////////////////////////////////////////////////////////////
1883 /**An Information Element that contains the encryption key (raw)*/
1884 class IAX2IeEncKey : public IAX2IeString
1885 {
1886 PCLASSINFO(IAX2IeEncKey, IAX2IeString);
1887 public:
1888 /** Constructor from data read from the network.
1889
1890 Contents are undefined if the network data is bogus/invalid */
IAX2IeEncKey(BYTE length,BYTE * srcData)1891 IAX2IeEncKey(BYTE length, BYTE *srcData) : IAX2IeString(length, srcData) { };
1892
1893 /**print this class (nicely) to the designated stream*/
1894 virtual void PrintOn(ostream & str) const;
1895
1896 /**Get the key value for this particular Information Element class */
GetKeyValue()1897 virtual BYTE GetKeyValue() const { return ie_encKey; }
1898
1899 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1900 structure. This is done on processing an incoming frame which
1901 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1902 virtual void StoreDataIn(IAX2IeData &res) { res.encKey = dataValue; }
1903 protected:
1904 };
1905
1906 ///////////////////////////////////////////////////////////////////////
1907 /**An Information Element that contains data for codec negotiation. */
1908 class IAX2IeCodecPrefs : public IAX2IeByte
1909 {
1910 PCLASSINFO(IAX2IeCodecPrefs, IAX2IeByte);
1911 public:
1912 /** Constructor from data read from the network.
1913
1914 Contents are undefined if the network data is bogus/invalid */
IAX2IeCodecPrefs(BYTE length,BYTE * srcData)1915 IAX2IeCodecPrefs(BYTE length, BYTE *srcData) : IAX2IeByte(length, srcData) { };
1916
1917 /**print this class (nicely) to the designated stream*/
1918 virtual void PrintOn(ostream & str) const;
1919
1920 /**Get the key value for this particular Information Element class */
GetKeyValue()1921 virtual BYTE GetKeyValue() const { return ie_codecPrefs; }
1922
1923 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1924 structure. This is done on processing an incoming frame which
1925 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1926 virtual void StoreDataIn(IAX2IeData &res) { res.codecPrefs = dataValue; }
1927 protected:
1928 };
1929
1930 ///////////////////////////////////////////////////////////////////////
1931 /**An Information Element that contains the received jitter */
1932 class IAX2IeReceivedJitter : public IAX2IeUInt
1933 {
1934 PCLASSINFO(IAX2IeReceivedJitter, IAX2IeUInt);
1935 public:
1936 /** Constructor from data read from the network.
1937
1938 Contents are undefined if the network data is bogus/invalid */
IAX2IeReceivedJitter(BYTE length,BYTE * srcData)1939 IAX2IeReceivedJitter(BYTE length, BYTE *srcData) : IAX2IeUInt(length, srcData) { };
1940
1941 /**print this class (nicely) to the designated stream*/
1942 virtual void PrintOn(ostream & str) const;
1943
1944 /**Get the key value for this particular Information Element class */
GetKeyValue()1945 virtual BYTE GetKeyValue() const { return ie_recJitter; }
1946
1947 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1948 structure. This is done on processing an incoming frame which
1949 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1950 virtual void StoreDataIn(IAX2IeData &res) { res.receivedJitter = dataValue; }
1951 protected:
1952 };
1953
1954 ///////////////////////////////////////////////////////////////////////
1955 /**An Information Element that contains the received loss */
1956 class IAX2IeReceivedLoss : public IAX2IeUInt
1957 {
1958 PCLASSINFO(IAX2IeReceivedLoss, IAX2IeUInt);
1959 public:
1960 /** Constructor from data read from the network.
1961
1962 Contents are undefined if the network data is bogus/invalid */
IAX2IeReceivedLoss(BYTE length,BYTE * srcData)1963 IAX2IeReceivedLoss(BYTE length, BYTE *srcData) : IAX2IeUInt(length, srcData) { };
1964
1965 /**print this class (nicely) to the designated stream*/
1966 virtual void PrintOn(ostream & str) const;
1967
1968 /**Get the key value for this particular Information Element class */
GetKeyValue()1969 virtual BYTE GetKeyValue() const { return ie_recLoss; }
1970
1971 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1972 structure. This is done on processing an incoming frame which
1973 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1974 virtual void StoreDataIn(IAX2IeData &res) { res.receivedLoss = dataValue; }
1975 protected:
1976 };
1977
1978 ///////////////////////////////////////////////////////////////////////
1979 /**An Information Element that contains the received frames */
1980 class IAX2IeReceivedFrames : public IAX2IeUInt
1981 {
1982 PCLASSINFO(IAX2IeReceivedFrames, IAX2IeUInt);
1983 public:
1984 /** Constructor from data read from the network.
1985
1986 Contents are undefined if the network data is bogus/invalid */
IAX2IeReceivedFrames(BYTE length,BYTE * srcData)1987 IAX2IeReceivedFrames(BYTE length, BYTE *srcData) : IAX2IeUInt(length, srcData) { };
1988
1989 /**print this class (nicely) to the designated stream*/
1990 virtual void PrintOn(ostream & str) const;
1991
1992 /**Get the key value for this particular Information Element class */
GetKeyValue()1993 virtual BYTE GetKeyValue() const { return ie_recPackets; }
1994
1995 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
1996 structure. This is done on processing an incoming frame which
1997 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)1998 virtual void StoreDataIn(IAX2IeData &res) { res.receivedPackets = dataValue; }
1999 protected:
2000 };
2001
2002 ///////////////////////////////////////////////////////////////////////
2003 /**An Information Element that contains the received delay */
2004 class IAX2IeReceivedDelay : public IAX2IeUShort
2005 {
2006 PCLASSINFO(IAX2IeReceivedDelay, IAX2IeUShort);
2007 public:
2008 /** Constructor from data read from the network.
2009
2010 Contents are undefined if the network data is bogus/invalid */
IAX2IeReceivedDelay(BYTE length,BYTE * srcData)2011 IAX2IeReceivedDelay(BYTE length, BYTE *srcData) : IAX2IeUShort(length, srcData) { };
2012
2013 /**print this class (nicely) to the designated stream*/
2014 virtual void PrintOn(ostream & str) const;
2015
2016 /**Get the key value for this particular Information Element class */
GetKeyValue()2017 virtual BYTE GetKeyValue() const { return ie_recDelay; }
2018
2019 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
2020 structure. This is done on processing an incoming frame which
2021 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)2022 virtual void StoreDataIn(IAX2IeData &res) { res.receivedDelay = dataValue; }
2023 protected:
2024 };
2025
2026 ///////////////////////////////////////////////////////////////////////
2027 /**An Information Element that contains the number of dropped frames */
2028 class IAX2IeDroppedFrames : public IAX2IeUInt
2029 {
2030 PCLASSINFO(IAX2IeDroppedFrames, IAX2IeUInt);
2031 public:
2032 /** Constructor from data read from the network.
2033
2034 Contents are undefined if the network data is bogus/invalid */
IAX2IeDroppedFrames(BYTE length,BYTE * srcData)2035 IAX2IeDroppedFrames(BYTE length, BYTE *srcData) : IAX2IeUInt(length, srcData) { };
2036
2037 /**print this class (nicely) to the designated stream*/
2038 virtual void PrintOn(ostream & str) const;
2039
2040 /**Get the key value for this particular Information Element class */
GetKeyValue()2041 virtual BYTE GetKeyValue() const { return ie_recDropped; }
2042
2043 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
2044 structure. This is done on processing an incoming frame which
2045 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)2046 virtual void StoreDataIn(IAX2IeData &res) { res.receivedDropped = dataValue; }
2047 protected:
2048 };
2049
2050 ///////////////////////////////////////////////////////////////////////
2051 /**An Information Element that contains the number of frames received out of order */
2052 class IAX2IeReceivedOoo : public IAX2IeUInt
2053 {
2054 PCLASSINFO(IAX2IeReceivedOoo, IAX2IeUInt);
2055 public:
2056 /** Constructor from data read from the network.
2057
2058 Contents are undefined if the network data is bogus/invalid */
IAX2IeReceivedOoo(BYTE length,BYTE * srcData)2059 IAX2IeReceivedOoo(BYTE length, BYTE *srcData) : IAX2IeUInt(length, srcData) { };
2060
2061 /**print this class (nicely) to the designated stream*/
2062 virtual void PrintOn(ostream & str) const;
2063
2064 /**Get the key value for this particular Information Element class */
GetKeyValue()2065 virtual BYTE GetKeyValue() const { return ie_recOoo; }
2066
2067 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
2068 structure. This is done on processing an incoming frame which
2069 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)2070 virtual void StoreDataIn(IAX2IeData &res) { res.receivedOoo = dataValue; }
2071 protected:
2072 };
2073
2074 ///////////////////////////////////////////////////////////////////////
2075 /**An Information Element that contains the Call Token - a mechanism to stop
2076 DOS attacks through setting up lots of calls
2077
2078 The IAX2IeCallToken uses the HMAC SHA1 algorithm to secure the
2079 challenge message sent to the initiating computer. With this
2080 approach, it is not feasible for spoofing etc of the reply. You can
2081 readup on hmac-sha1 at http://en.wikipedia.org/wiki/HMAC */
2082 class IAX2IeCallToken : public IAX2IeBinary
2083 {
2084 PCLASSINFO(IAX2IeCallToken, IAX2IeBinary);
2085 public:
2086 /** Constructor from data read from the network. Contents are
2087 undefined if the network data is bogus/invalid */
IAX2IeCallToken(BYTE length,BYTE * srcData)2088 IAX2IeCallToken(BYTE length, BYTE *srcData)
2089 : IAX2IeBinary(length, srcData) { };
2090
2091 /** Build an empty IAX2IeCallToken, which is used in the new packet,
2092 as sent by the node initiating a call */
IAX2IeCallToken()2093 IAX2IeCallToken() : IAX2IeBinary(0, NULL) {};
2094
2095 /**print this class (nicely) to the designated stream*/
2096 virtual void PrintOn(ostream & str) const;
2097
2098 /**Get the key value for this particular Information Element class */
GetKeyValue()2099 virtual BYTE GetKeyValue() const { return ie_callToken; }
2100
2101 /** Take the data from this IAX2Ie, and copy it into the IAX2IeData
2102 structure. This is done on processing an incoming frame which
2103 contains IAX2Ie in the data section. */
StoreDataIn(IAX2IeData & res)2104 virtual void StoreDataIn(IAX2IeData &res) { res.callToken = dataValue; }
2105
2106 /**Initialise the internal key, and the iKeyPad and oKeyPad
2107 variables, for the generation of the SHA1-HMAC keysequence. This
2108 initialisation happens once, at program startup. */
2109 static void InitialiseKey();
2110
2111 /**Fill with a hash key sequence, that we will later verify*/
2112 void WriteKeySequence(PIPSocket::Address & remoteAddress);
2113
2114 /**Examine the hash key sequence in the supplied IE, and see if it
2115 is valid. */
2116 static PBoolean ValidKeySequence (IAX2IeCallToken & cf,
2117 PIPSocket::Address & remote);
2118
2119 protected:
2120 /**Report the key sequence that should be built, provided the
2121 supplied time string and address */
2122 static PString ReportKeySequence(const PString & time, PIPSocket::Address & remote);
2123
2124 /**The internal size of the hmac sha1 key, which the protocol sets
2125 at 64 bytes, as this is a 512 bit hash */
2126 enum {
2127 iKeyValue = 0x36, /*!< Speced in protocol, an ambiguitating value */
2128 oKeyValue = 0x5c, /*!< Same as iKeyValue, bitwise is very different.*/
2129 blockSize = 64 /*!< Size of the cypher. 64 bytes = 512 bits. */
2130 };
2131
2132 /**The key used in generating the SHA1-HMAC hash. Key is required for
2133 handling incoming calls */
2134 static PString secretKey;
2135
2136 /**Used for generating the SHA1-HMAC hash. Initialised at program
2137 startup, saves on time later. */
2138 static BYTE iKeyPad[blockSize];
2139
2140 /**Similar to the iKeyPad, an internal variable*/
2141 static BYTE oKeyPad[blockSize];
2142 };
2143 /////////////////////////////////////////////////////////////////////////////
2144
2145
PDECLARE_LIST(IAX2IeList,IAX2Ie *)2146 PDECLARE_LIST (IAX2IeList, IAX2Ie *)
2147 #ifdef DOC_PLUS_PLUS
2148 /**An array of IE* elements are stored in this list */
2149 class IAX2IeList : public IAX2Ie *
2150 {
2151 #endif
2152 public:
2153 /**Destructor, so all eleents are destroyed on destruction */
2154 ~IAX2IeList();
2155
2156 /**Access method, get pointer to information element at index.
2157 Returns NULL if index is out of bounds.
2158 This will remove the specified IAX2Ie from the list. */
2159 IAX2Ie *RemoveIeAt(PINDEX i);
2160
2161 /**Access method, get pointer to last information element in the list.
2162 Returns NULL if index is out of bounds.
2163 This will remove the specified IAX2Ie from the list. */
2164 IAX2Ie *RemoveLastIe();
2165
2166 /**Initialisation - Objects are not automatically deleted on removal */
2167 void Initialise() { DisallowDeleteObjects(); }
2168
2169 /**Delete item at a particular index */
2170 void DeleteAt(PINDEX idex);
2171
2172 /**Test to see if list is empty - returns true if no elements stored in this list */
2173 PBoolean Empty() const { return GetSize() == 0; }
2174
2175 /**Test to see if list is empty - returns true if no elements stored in this list */
2176 PBoolean IsEmpty() const { return GetSize() == 0; }
2177
2178 /**Add a new IAX2Ie to the list */
2179 void AppendIe(IAX2Ie *newMember) { Append(newMember);}
2180
2181 /**Get the number of bytes to store all these IAX2Ie's in a network packet */
2182 int GetBinaryDataSize() const;
2183
2184 /**Get a pointer to the IAX2Ie which is stored at index i*/
2185 IAX2Ie * GetIeAt(int i) const;
2186
2187 protected:
2188
2189 };
2190
2191
2192 #endif // OPAL_IAX2
2193
2194 #endif // OPAL_IAX2_IES_H
2195
2196 /* The comment below is magic for those who use emacs to edit this file.
2197 * With the comment below, the tab key does auto indent to 2 spaces.
2198 *
2199 * Local Variables:
2200 * mode:c
2201 * c-basic-offset:2
2202 * End:
2203 */
2204