source: trunk/ETSI-Testsuites/ETSI_auto_IOT/adapter/src/libiot_codets.cpp

Last change on this file was 22, checked in by rings, 14 years ago
  • Property svn:executable set to *
File size: 22.3 KB
RevLine 
[22]1#include "gen_classes.h"
2#include "Ports/MessagesIdentifiers.h"
3
4#include <fstream>
5
6
7/* For debugging with MMAGIC
8ofstream myfile;
9myfile.open ("C:\\Temp\\logs.txt", ios::out | ios::app );
10myfile << "CaptureSource::PreEncodeField: " << field_id << std::endl;
11myfile.close();
12  */
13
14namespace t3devlib { namespace gen {
15
16  const char* FncRetCode::msFncRetCodeModes[] = {
17    "e_success",
18    "e_error",
19    "e_timeout",
20    ""
21  };
22
23  const char* IOTExecMode::msExecModes[] = {
24    "e_realtime",
25    "e_offline",
26    ""
27  };
28
29  const char* IOTVerdictType::msVerdictTypes[] = {
30    "e_e2e",
31    "e_conformance",
32    ""
33  };
34
35  const char* RecordMode::msRecordModes[] = {
36    "e_norecord",
37    "e_record",
38    ""
39  };
40
41  const char* ProtocolFilter::msProtocolFilterModes[] = {
42    "e_sip",
43    "e_dns",
44    ""
45  };
46
47
48  void FncRetCode::Encode (Buffer& buffer) throw (EncodeError) {
49
50    Unsigned u8(8);
51    const char ** ppEnum = msFncRetCodeModes;
52    const std::string & val = GetValueString();
53   
54    int i = 0;
55    while (*(ppEnum[i]) && strcmp(ppEnum[i], val.c_str()) != 0)
56      i++;
57   
58    if (*(ppEnum[i]) == 0) {
59      std::string message ("unsupported enum value '");
60      message += val;
61      message += '\n';
62      throw EncodeError (this, message);
63    }
64   
65    u8.SetValue(i);
66    u8.Encode(buffer);
67}
68
69  void FncRetCode::Decode (Buffer& buffer) throw (DecodeError) {
70    Unsigned u8(8);
71    const char ** ppEnum = msFncRetCodeModes;
72   
73    u8.Decode(buffer);
74
75    int i = 0;
76    while (*(ppEnum[i]) && (i != u8.GetValue()) )
77      i++;
78   
79    if (*(ppEnum[i]) == 0) {
80      std::string message ("unsupported enum value '");
81      message += u8.GetValue();
82      message += '\n';
83      throw DecodeError (this, message);
84    } else {
85      SetValueString(ppEnum[i]);
86    }
87   
88  }
89
90
91  void IOTExecMode::Encode (Buffer& buffer) throw (EncodeError) {
92
93    Unsigned u8(8);
94    const char ** ppEnum = msExecModes;
95    const std::string & val = GetValueString();
96   
97    int i = 0;
98    while (*(ppEnum[i]) && strcmp(ppEnum[i], val.c_str()) != 0)
99      i++;
100   
101    if (*(ppEnum[i]) == 0) {
102      std::string message ("unsupported enum value '");
103      message += val;
104      message += '\n';
105      throw EncodeError (this, message);
106    }
107   
108    u8.SetValue(i);
109    u8.Encode(buffer);
110}
111
112  void IOTExecMode::Decode (Buffer& buffer) throw (DecodeError) {
113   
114    Unsigned u8(8);
115    const char ** ppEnum = msExecModes;
116   
117    u8.Decode(buffer);
118
119    int i = 0;
120    while (*(ppEnum[i]) && (i != u8.GetValue()) )
121      i++;
122   
123    if (*(ppEnum[i]) == 0) {
124      std::string message ("unsupported enum value '");
125      message += u8.GetValue();
126      message += '\n';
127      throw DecodeError (this, message);
128    } else {
129      SetValueString(ppEnum[i]);
130    }
131  }
132
133  void IOTVerdictType::Encode (Buffer& buffer) throw (EncodeError) {
134
135    Unsigned u8(8);
136    const char ** ppEnum = msVerdictTypes;
137    const std::string & val = GetValueString();
138   
139    int i = 0;
140    while (*(ppEnum[i]) && strcmp(ppEnum[i], val.c_str()) != 0)
141      i++;
142   
143    if (*(ppEnum[i]) == 0) {
144      std::string message ("unsupported enum value '");
145      message += val;
146      message += '\n';
147      throw EncodeError (this, message);
148    }
149   
150    u8.SetValue(i);
151    u8.Encode(buffer);
152}
153
154  void IOTVerdictType::Decode (Buffer& buffer) throw (DecodeError) {
155   
156    Unsigned u8(8);
157    const char ** ppEnum = msVerdictTypes;
158   
159    u8.Decode(buffer);
160
161    int i = 0;
162    while (*(ppEnum[i]) && (i != u8.GetValue()) )
163      i++;
164   
165    if (*(ppEnum[i]) == 0) {
166      std::string message ("unsupported enum value '");
167      message += u8.GetValue();
168      message += '\n';
169      throw DecodeError (this, message);
170    } else {
171      SetValueString(ppEnum[i]);
172    }
173
174  }
175
176  void RecordMode::Encode (Buffer& buffer) throw (EncodeError) {
177
178    Unsigned u8(8); // 1 octet length
179    // Set Value
180    const char ** ppEnum = msRecordModes;
181    const std::string & val = GetValueString();
182    int i = 0;
183    while (*(ppEnum[i]) && strcmp(ppEnum[i], val.c_str()) != 0)
184      i++;
185    if (*(ppEnum[i]) == 0) {
186      std::string message ("unsupported enum value '");
187      message += val;
188      message += '\n';
189      throw EncodeError (this, message);
190    }
191    u8.SetValue(i);
192    u8.Encode(buffer);
193}
194
195  void RecordMode::Decode (Buffer& buffer) throw (DecodeError) {
196   
197    Unsigned u8(8); // 1 octet length
198    const char ** ppEnum = msRecordModes;
199   
200    u8.Decode(buffer);
201
202    int i = 0;
203    while (*(ppEnum[i]) && (i != u8.GetValue()) )
204      i++;
205   
206    if (*(ppEnum[i]) == 0) {
207      std::string message ("unsupported enum value '");
208      message += u8.GetValue();
209      message += '\n';
210      throw DecodeError (this, message);
211    } else {
212      SetValueString(ppEnum[i]);
213    }
214
215  }
216
217
218  void ProtocolFilter::Encode (Buffer& buffer) throw (EncodeError) {
219
220   Unsigned u8(8); // 1 octet length
221    // Set Value
222    const char ** ppEnum = msProtocolFilterModes;
223    const std::string & val = GetValueString();
224    int i = 0;
225    while (*(ppEnum[i]) && strcmp(ppEnum[i], val.c_str()) != 0)
226      i++;
227    if (*(ppEnum[i]) == 0) {
228      std::string message ("unsupported enum value '");
229      message += val;
230      message += '\n';
231      throw EncodeError (this, message);
232    }
233    u8.SetValue(i);
234    u8.Encode(buffer);
235}
236
237  void ProtocolFilter::Decode (Buffer& buffer) throw (DecodeError) {
238 
239  Unsigned u8(8); // 1 octet length
240  const char ** ppEnum = msProtocolFilterModes;
241 
242  u8.Decode(buffer);
243
244  int i = 0;
245  while (*(ppEnum[i]) && (i != u8.GetValue()) )
246    i++;
247 
248  if (*(ppEnum[i]) == 0) {
249    std::string message ("unsupported enum value '");
250    message += u8.GetValue();
251    message += '\n';
252    throw DecodeError (this, message);
253  } else {
254    SetValueString(ppEnum[i]);
255  }
256}
257
258  void InterfaceInfoList::PreEncode (Buffer& buffer) throw (EncodeError)
259  {
260    // Set the number of parameters.
261    Unsigned fieldLength(8, GetSize());
262    fieldLength.Encode(buffer);
263  }
264
265  void Product::PreEncodeField (int field_id, Buffer& buffer) throw (EncodeError)
266  {
267    Charstring value;
268    Unsigned fieldLength(2 * 8); // 2 octet length
269    switch (field_id) {
270      case id_productName:
271        {
272          // Set the number of parameters.
273          value = Get_productName();
274          std::cout << "Product::PreEncodeField: id_productName value=" << value << " - " << value.GetLength() / 8 << std::endl;
275          fieldLength.SetValue(value.GetLength() / 8);
276        }
277        break;
278      default:
279        std::cerr << "Product::PreEncodeField: Non processed field: " << field_id << std::endl;
280        return;
281    }
282    //std::cout << "Product::PreEncodeField: fieldLength=" << (int)fieldLength.GetValue() << std::endl;
283    fieldLength.Encode(buffer);
284  }
285 
286
287  void InterfaceInfo::PreEncode (Buffer& buffer) throw (EncodeError)
288  {
289    // Set union type
290    Unsigned fieldLength(8, GetChosenId()); // 1 octet length
291    //std::cout << "InterfaceInfo::InterfaceInfo: fieldLength=" << (int)fieldLength.GetValue() << std::endl;
292    fieldLength.Encode(buffer);
293   
294    if (GetChosenId() == id_IpInterfaceInfo)
295    {
296      // Set the number of parameters.
297      IpInterfaceInfoList& list = Get_IpInterfaceInfo();
298      //std::cout << "InterfaceInfo::PreEncode: id_IpInterfaceInfo size=" << list.GetSize() << std::endl;
299      fieldLength.SetValue(list.GetSize());
300      fieldLength.Encode(buffer);
301    }
302  }
303
304  void CaptureMode::PreEncode (Buffer& buffer) throw (EncodeError)
305  {
306    // Set union type
307    Unsigned fieldLength(8, GetChosenId()); // 1 octet length
308    //std::cout << "CaptureMode::PreEncode: fieldLength=" << (int)fieldLength.GetValue() << std::endl;
309    fieldLength.Encode(buffer);
310  }
311 
312  void IpInterfaceInfo::PreEncodeField (int field_id, Buffer& buffer) throw (EncodeError)
313  {
314    Charstring value;
315    Unsigned fieldLength(2 * 8); // 2 octet length
316    switch (field_id) {
317      case id_domainName:
318        {
319          if(IsPresent(id_domainName))
320          {
321            // Set the string length.
322            value = Get_domainName();
323            std::cout << "IpInterfaceInfo::PreEncodeField: id_domainName value=" << value << " - " << value.GetLength() / 8 << std::endl;
324            fieldLength.SetValue(value.GetLength() / 8);
325          }
326          else
327          {
328            fieldLength.SetValue(0);
329          }
330        }
331        break;
332      case id_IpAddress:
333        {
334          value = static_cast<Charstring>(Get_IpAddress());
335          std::cout << "IpInterfaceInfo::PreEncodeField: id_IpAddress value=" << value << " - " << value.GetLength() / 8 << std::endl;
336          fieldLength.SetValue(value.GetLength() / 8);
337        }
338        break;
339      case id_portNumbers:
340        {
341          PortNumberList& ports = Get_portNumbers();
342          std::cout << "IpInterfaceInfo::PreEncodeField: id_portNumbers value=" << ports.GetSize() << std::endl;
343          fieldLength.SetValue(ports.GetSize());
344        }
345        break;
346      default:
347        std::cerr << "IpInterfaceInfo::PreEncodeField: Non processed field: " << field_id << std::endl;
348        return;
349    }
350    //std::cout << "IpInterfaceInfo::PreEncodeField: fieldLength " << (int)fieldLength.GetValue() << std::endl;
351    fieldLength.Encode(buffer);
352  }
353
354  void EutInterfaceInfo::PreEncodeField (int field_id, Buffer& buffer) throw (EncodeError)
355  {
356    Charstring value;
357    Unsigned fieldLength(2 * 8); // 2 octet length
358    switch (field_id) {
359      case id_eut:
360        {
361          // Set the string length.
362          value = Get_eut();
363          std::cout << "EutInterfaceInfo::PreEncodeField: id_eut value=" << value << " - " << value.GetLength() / 8 << std::endl;
364          fieldLength.SetValue(value.GetLength() / 8);
365        }
366        break;
367      case id_ipAddress:
368        {
369          value = static_cast<Charstring>(Get_ipAddress());
370          std::cout << "EutInterfaceInfo::PreEncodeField: id_ipAddress value=" << value << " - " << value.GetLength() / 8 << std::endl;
371          fieldLength.SetValue(value.GetLength() / 8);
372        }
373        break;
374      default:
375        std::cerr << "EutInterfaceInfo::PreEncodeField: Non processed field: " << field_id << std::endl;
376        return;
377    }
378    //std::cout << "EutInterfaceInfo::PreEncodeField: fieldLength " << (int)fieldLength.GetValue() << std::endl;
379    fieldLength.Encode(buffer);
380  }
381
382  void LiveCapture::PreEncodeField (int field_id, Buffer& buffer) throw (EncodeError)
383  {
384    Charstring value;
385    Unsigned fieldLength(2 * 8); // 2 octet length
386    switch (field_id) {
387      case id_physicalInterfaces:
388        {
389          // Set the number of parameters.
390          PhysicalInterfaceList& ifaces = Get_physicalInterfaces();
391          std::cout << "LiveCapture::PreEncodeField: id_physicalInterfaces size=" << ifaces.GetSize() << std::endl;
392          fieldLength.SetValue(ifaces.GetSize());
393        }
394        break;
395      default:
396        std::cerr << "LiveCapture::PreEncodeField: Non processed field: " << field_id << std::endl;
397        return;
398    }
399    //std::cout << "LiveCapture::PreEncodeField: fieldLength=" << (int)fieldLength.GetValue() << std::endl;
400    fieldLength.Encode(buffer);
401  }
402 
403
404  void CaptureSource::PreEncodeField (int field_id, Buffer& buffer) throw (EncodeError)
405  {
406    Charstring value;
407    Unsigned fieldLength(2 * 8); // 2 octet length
408    switch (field_id) {
409      case id_sessionsPath:
410        {
411          // Set the string length.
412          value = Get_sessionsPath();
413          std::cout << "CaptureSource::PreEncodeField: id_sessionsPath value=" << value << " - " << value.GetLength() / 8 << std::endl;
414          fieldLength.SetValue(value.GetLength() / 8);
415        }
416        break;
417      default:
418        std::cerr << "CaptureSource::PreEncodeField: Non processed field: " << field_id << std::endl;
419        return;
420    }
421    //std::cout << "CaptureSource::PreEncodeField: fieldLength " << (int)fieldLength.GetValue() << std::endl;
422    fieldLength.Encode(buffer);
423  }
424
425  void MergeFileList::PreEncodeField (int field_id, Buffer& buffer) throw (EncodeError)
426  {
427    Charstring value;
428    Unsigned fieldLength(2 * 8); // 2 octet length
429    switch (field_id) {
430      case id_mergeFileList:
431        {
432          // Set the number of parameters.
433          FileList& list = Get_mergeFileList();
434          std::cout << "MergeFileList::PreEncodeField: id_mergeFileList value=" << list.GetSize() << std::endl;
435          fieldLength.SetValue(list.GetSize());
436        }
437        break;
438      case id_mergeFilePath:
439        {
440          // Set the string length.
441          value = Get_mergeFilePath();
442          std::cout << "MergeFileList::PreEncodeField: id_mergeFilePath value=" << value << " - " << value.GetLength() / 8 << std::endl;
443          fieldLength.SetValue(value.GetLength() / 8);
444        }
445        break;
446       
447      case id_mergeToolPath:
448        {
449          // Set the string length.
450          value = Get_mergeToolPath();
451          std::cout << "MergeFileList::PreEncodeField: id_mergeToolPath value=" << value << " - " << value.GetLength() / 8 << std::endl;
452          fieldLength.SetValue(value.GetLength() / 8);
453        }
454        break;
455       
456      default:
457        std::cerr << "MergeFileList::PreEncodeField: Non processed field: " << field_id << std::endl;
458        return;
459    }
460    //std::cout << "MergeFileList::PreEncodeField: fieldLength " << (int)fieldLength.GetValue() << std::endl;
461    fieldLength.Encode(buffer);
462  }
463
464  void GeneralConfigurationReq::PreEncode (Buffer & buffer ) throw (EncodeError)
465  {
466    // Get message index
467    unsigned char idx = MessagesIdentifiers::GetIdx(GetTypeName());
468    if (idx == 0xff) {
469      std::string message ("unsupported enum value '");
470      message += GetTypeName();
471      message += '\n';
472      throw EncodeError (this, message);
473    }
474    // Set message index
475    Unsigned fieldLength(8); // 1 octet length
476    fieldLength.SetValue(idx);
477    fieldLength.Encode(buffer);
478  }
479
480  void GeneralConfigurationReq::PreEncodeField (int field_id, Buffer& buffer) throw (EncodeError)
481  {
482    Charstring value;
483    Unsigned fieldLength(2 * 8); // 2 octet length
484    switch (field_id) {
485      case id_captureProcessIpAddress:
486        {
487          value = Get_captureProcessIpAddress();
488          std::cout << "GeneralConfigurationReq::id_captureProcessIpAddress: value " << value << " - " << value.GetLength() / 8 << std::endl;
489          fieldLength.SetValue(value.GetLength() / 8);
490        }
491        break;
492      case id_eutInfoList:
493        {
494          if(IsPresent(id_eutInfoList))
495          {
496            // Set the number of parameters.
497            std::cout << "GeneralConfigurationReq::id_eutInfoList: value " << Get_eutInfoList().GetSize() << std::endl;
498            fieldLength.SetValue(Get_eutInfoList().GetSize());
499          }
500          else
501          {
502            fieldLength.SetValue(0);
503          }
504
505        }
506        break;
507      default:
508        std::cerr << "GeneralConfigurationReq::PreEncodeField: Non processed field: " << field_id << std::endl;
509        return;
510    }
511    //std::cout << "GeneralConfigurationReq::PreEncodeField: fieldLength " << (int)fieldLength.GetValue() << std::endl;
512    fieldLength.Encode(buffer);
513  }
514 
515  void GeneralConfigurationRsp::PreDecode (Buffer& buffer) throw (DecodeError)
516  {
517    // Get message type.
518    Unsigned messageType (8); // One byte length
519    messageType.Decode (buffer);
520    if (MessagesIdentifiers::GetMessage(static_cast<int>(messageType.GetValue())).length() == 0) {
521      std::string message ("unsupported message type '");
522      message += static_cast<int>(messageType.GetValue());
523      message += '\n';
524      throw DecodeError (this, message);
525    }
526  }
527 
528  void EquipmentOperationReq::PreEncode (Buffer & buffer ) throw (EncodeError)
529  {
530    // Get message index
531    unsigned char idx = MessagesIdentifiers::GetIdx(GetTypeName());
532    if (idx == 0xff) {
533      std::string message ("unsupported enum value '");
534      message += GetTypeName();
535      message += '\n';
536      throw EncodeError (this, message);
537    }
538    // Set message index
539    Unsigned fieldLength(8); // 1 octet length
540    fieldLength.SetValue(idx);
541    fieldLength.Encode(buffer);
542  }
543
544  void EquipmentOperationReq::PreEncodeField (int field_id, Buffer& buffer) throw (EncodeError)
545  {
546    Charstring value;
547    Unsigned fieldLength(2 * 8);
548    switch (field_id) {
549      case id_cmd:
550        {
551          value = Get_cmd();
552          std::cout << "EquipmentOperationReq::id_cmd: value " << value << " - " << value.GetLength() / 8 << std::endl;
553          fieldLength.SetValue(value.GetLength() / 8);
554        }
555        break;
556      case id_params:
557        {
558          // Set the number of parameters.
559          //std::cout << "EquipmentOperationReq::id_params: " << Get_params().GetSize() << std::endl;
560          fieldLength.SetValue(Get_params().GetSize());
561        }
562        break;
563      default:
564        std::cerr << "EquipmentOperationReq::PreEncodeField: Non processed field: " << field_id << std::endl;
565        return;
566    }
567    std::cout << "EquipmentOperationReq::PreEncodeField: fieldLength " << (int)fieldLength.GetValue() << std::endl;
568    fieldLength.Encode(buffer);
569  }
570 
571  void EquipmentOperationRsp::PreDecode (Buffer& buffer) throw (DecodeError)
572  {
573    // Get message type.
574    Unsigned messageType (8); // One byte length
575    messageType.Decode (buffer);
576    if (MessagesIdentifiers::GetMessage(static_cast<int>(messageType.GetValue())).length() == 0) {
577      std::string message ("unsupported message type '");
578      message += static_cast<int>(messageType.GetValue());
579      message += '\n';
580      throw DecodeError (this, message);
581    }
582  }
583 
584  void PhysicalInterfaceList::PreEncodeField (int field_id, Buffer& buffer) throw (EncodeError)
585  {
586    Charstring value = GetField(field_id);
587    std::cout << "PhysicalInterfaceList::PreEncodeField: value " << value << " - " << value.GetLength() / 8 << std::endl;
588    Unsigned fieldLength(2 * 8, value.GetLength() / 8);
589    std::cout << "PhysicalInterfaceList::PreEncodeField: fieldLength " << (int)fieldLength.GetValue() << std::endl;
590    fieldLength.Encode(buffer);
591  }
592
593  void FileList::PreEncodeField (int field_id, Buffer& buffer) throw (EncodeError)
594  {
595    Charstring value = GetField(field_id);
596    std::cout << "FileList::PreEncodeField: value " << value << " - " << value.GetLength() / 8 << std::endl;
597    Unsigned fieldLength(2 * 8, value.GetLength() / 8);
598    std::cout << "FileList::PreEncodeField: fieldLength " << (int)fieldLength.GetValue() << std::endl;
599    fieldLength.Encode(buffer);
600  }
601
602  void ParameterList::PreEncodeField (int field_id, Buffer& buffer) throw (EncodeError)
603  {
604    Charstring value = GetField(field_id);
605    std::cout << "ParameterList::PreEncodeField: value " << value << " - " << value.GetLength() / 8 << std::endl;
606    Unsigned fieldLength(2 * 8, value.GetLength() / 8);
607    std::cout << "ParameterList::PreEncodeField: fieldLength " << (int)fieldLength.GetValue() << std::endl;
608    fieldLength.Encode(buffer);
609  }
610
611  void StartTrafficCaptureReq::PreEncode (Buffer & buffer ) throw (EncodeError)
612  {
613    // Set message type
614    // Get message index
615    unsigned char idx = MessagesIdentifiers::GetIdx(GetTypeName());
616    if (idx == 0xff) {
617      std::string message ("unsupported enum value '");
618      message += GetTypeName();
619      message += '\n';
620      throw EncodeError (this, message);
621    }
622    // Set message index
623    Unsigned fieldLength(8); // 1 octet length
624    fieldLength.SetValue(idx);
625    fieldLength.Encode(buffer);
626  }
627
628  void StartTrafficCaptureRsp::PreDecode (Buffer& buffer) throw (DecodeError)
629  {
630    // Get message type.
631    Unsigned messageType (8); // One byte length
632    messageType.Decode (buffer);
633    if (MessagesIdentifiers::GetMessage(static_cast<int>(messageType.GetValue())).length() == 0) {
634      std::string message ("unsupported message type '");
635      message += static_cast<int>(messageType.GetValue());
636      message += '\n';
637      throw DecodeError (this, message);
638    }
639  }
640 
641  void StopTrafficCaptureReq::PreEncode (Buffer & buffer ) throw (EncodeError)
642  {
643    // Get message index
644    unsigned char idx = MessagesIdentifiers::GetIdx(GetTypeName());
645    if (idx == 0xff) {
646      std::string message ("unsupported enum value '");
647      message += GetTypeName();
648      message += '\n';
649      throw EncodeError (this, message);
650    }
651    // Set message index
652    Unsigned fieldLength(8); // 1 octet length
653    fieldLength.SetValue(idx);
654    fieldLength.Encode(buffer);
655  }
656
657  void StopTrafficCaptureRsp::PreDecode (Buffer& buffer) throw (DecodeError)
658  {
659    // Get message type.
660    Unsigned messageType (8); // One byte length
661    messageType.Decode (buffer);
662    if (MessagesIdentifiers::GetMessage(static_cast<int>(messageType.GetValue())).length() == 0) {
663      std::string message ("unsupported message type '");
664      message += static_cast<int>(messageType.GetValue());
665      message += '\n';
666      throw DecodeError (this, message);
667    }
668  }
669 
670  void SetFilterReq::PreEncode (Buffer & buffer ) throw (EncodeError)
671  {
672    // Get message index
673    unsigned char idx = MessagesIdentifiers::GetIdx(GetTypeName());
674    if (idx == 0xff) {
675      std::string message ("unsupported enum value '");
676      message += GetTypeName();
677      message += '\n';
678      throw EncodeError (this, message);
679    }
680    // Set message index
681    Unsigned fieldLength(8); // 1 octet length
682    fieldLength.SetValue(idx);
683    fieldLength.Encode(buffer);
684  }
685 
686  void SetFilterRsp::PreDecode (Buffer& buffer) throw (DecodeError)
687  {
688    // Get message type.
689    Unsigned messageType (8); // One byte length
690    messageType.Decode (buffer);
691    if (MessagesIdentifiers::GetMessage(static_cast<int>(messageType.GetValue())).length() == 0) {
692      std::string message ("unsupported message type '");
693      message += static_cast<int>(messageType.GetValue());
694      message += '\n';
695      throw DecodeError (this, message);
696    }
697  }
698 
699  void Status::PreDecodeField(int field_id, Buffer& buffer) throw (DecodeError)
700  {
701    switch (field_id)
702    {
703      case id_code:
704        break;
705      case id_reason: // Set length
706        {
707          Unsigned reason (2 * 8);
708          reason.Decode (buffer);
709          if (reason.GetValue() == 0)
710          {
711            std::cout << "Status::PreDecodeField: Set reason omitted" << std::endl;
712            SetHypFieldIsPresent(id_reason, 0);
713          }
714          else
715          {
716            std::cout << "Status::PreDecodeField: Set length to " << reason.GetValue() << std::endl;
717            SetHypFieldIsPresent(id_reason, 1);
718            SetHypFieldLength (id_reason, reason.GetValue() * 8);
719          }
720        }
721        break;
722      default:
723        std::cerr << "Status::PreDecodeField: Non processed field: " << field_id << std::endl;
724        return;
725    }
726  }
727
728 
729}} // namespaces
Note: See TracBrowser for help on using the repository browser.