aa850c3a0da7ebeda51803a260312d4185f1f67a
[strongswan.git] / Source / charon / message.c
1 /**
2 * @file message.c
3 *
4 * @brief Class message_t. Object of this type represents an IKEv2-Message.
5 *
6 */
7
8 /*
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23 #include <stdlib.h>
24
25 #include "message.h"
26
27 #include "types.h"
28 #include "globals.h"
29 #include "ike_sa_id.h"
30 #include "generator.h"
31 #include "utils/linked_list.h"
32 #include "utils/allocator.h"
33 #include "utils/logger_manager.h"
34 #include "payloads/encodings.h"
35 #include "payloads/payload.h"
36 #include "parser.h"
37
38
39 /**
40 * Supported payload entry used in message_rule_t
41 *
42 */
43 typedef struct supported_payload_entry_s supported_payload_entry_t;
44
45 struct supported_payload_entry_s {
46 /**
47 * Payload type
48 */
49 payload_type_t payload_type;
50
51 /**
52 * Minimal occurence of this payload
53 */
54 size_t min_occurence;
55
56 /**
57 * Max occurence of this payload
58 */
59 size_t max_occurence;
60 };
61
62 /**
63 * Message Rule used to find out which payloads are supported by each message type
64 *
65 */
66 typedef struct message_rule_s message_rule_t;
67
68 struct message_rule_s {
69 /**
70 * Type of message
71 */
72 exchange_type_t exchange_type;
73
74 /**
75 * Is message a request or response
76 */
77 bool is_request;
78 /**
79 * Number of supported payloads
80 */
81 size_t supported_payloads_count;
82 /**
83 * Pointer to first supported payload entry
84 */
85 supported_payload_entry_t *supported_payloads;
86 };
87
88
89 static supported_payload_entry_t supported_ike_sa_init_i_payloads[] =
90 {
91 {SECURITY_ASSOCIATION,1,1},
92 {KEY_EXCHANGE,1,1},
93 {NONCE,1,1},
94 };
95
96 static supported_payload_entry_t supported_ike_sa_init_r_payloads[] =
97 {
98 {SECURITY_ASSOCIATION,1,1},
99 {KEY_EXCHANGE,1,1},
100 {NONCE,1,1},
101 };
102
103 static message_rule_t message_rules[] = {
104 {IKE_SA_INIT,TRUE,(sizeof(supported_ike_sa_init_i_payloads)/sizeof(supported_payload_entry_t)),supported_ike_sa_init_i_payloads},
105 {IKE_SA_INIT,FALSE,(sizeof(supported_ike_sa_init_r_payloads)/sizeof(supported_payload_entry_t)),supported_ike_sa_init_r_payloads}
106 };
107
108 /**
109 * Entry for a payload in the internal used linked list
110 *
111 */
112 typedef struct payload_entry_s payload_entry_t;
113
114 struct payload_entry_s {
115 /**
116 * Type of payload
117 */
118 payload_type_t payload_type;
119 /**
120 * Data struct holding the data of given payload
121 */
122 void *data_struct;
123 };
124
125
126 /**
127 * Private data of an message_t object
128 */
129 typedef struct private_message_s private_message_t;
130
131 struct private_message_s {
132
133 /**
134 * Public part of a message_t object
135 */
136 message_t public;
137
138
139 /**
140 * Minor version of message
141 */
142 u_int8_t major_version;
143
144 /**
145 * Major version of message
146 */
147 u_int8_t minor_version;
148
149 /**
150 * First Payload in message
151 */
152 payload_type_t first_payload;
153
154 /**
155 * Assigned exchange type
156 */
157 exchange_type_t exchange_type;
158
159
160 /**
161 * TRUE if message is request.
162 * FALSE if message is reply.
163 */
164 bool is_request;
165
166 /**
167 * Message ID of this message
168 */
169 u_int32_t message_id;
170
171 /**
172 * ID of assigned IKE_SA
173 */
174 ike_sa_id_t *ike_sa_id;
175
176 /**
177 * Assigned UDP packet.
178 *
179 * Stores incoming packet or last generated one.
180 */
181 packet_t *packet;
182
183 /**
184 * Linked List where payload data are stored in
185 */
186 linked_list_t *payloads;
187
188 /**
189 * Assigned parser to parse Header and Body of this message
190 */
191 parser_t *parser;
192
193 /**
194 * logger for this message
195 */
196 logger_t *logger;
197
198 /**
199 * Gets a list of supported payloads of this message type
200 *
201 * @param this calling object
202 * @param[out] supported_payloads first entry of supported payloads
203 * @param[out] supported_payloads_count number of supported payload entries
204 *
205 * @return SUCCESS
206 * NOT_FOUND if no supported payload definition could be found
207 */
208 status_t (*get_supported_payloads) (private_message_t *this, supported_payload_entry_t **supported_payloads,size_t *supported_payloads_count);
209
210 };
211
212 /**
213 * Implements private_message_t's get_supported_payloads function.
214 * See #private_message_t.get_supported_payloads.
215 */
216 status_t get_supported_payloads (private_message_t *this, supported_payload_entry_t **supported_payloads,size_t *supported_payloads_count)
217 {
218 int i;
219 exchange_type_t exchange_type = this->public.get_exchange_type(&(this->public));
220 bool is_request = this->public.get_request(&(this->public));
221
222
223 for (i = 0; i < (sizeof(message_rules) / sizeof(message_rule_t)); i++)
224 {
225 if ((exchange_type == message_rules[i].exchange_type) &&
226 (is_request == message_rules[i].is_request))
227 {
228 /* found rule for given exchange_type*/
229 *supported_payloads = message_rules[i].supported_payloads;
230 *supported_payloads_count = message_rules[i].supported_payloads_count;
231
232 return SUCCESS;
233 }
234
235
236 }
237 *supported_payloads = NULL;
238 *supported_payloads_count = 0;
239 return NOT_FOUND;
240 }
241
242 /**
243 * Implements message_t's set_ike_sa_id function.
244 * See #message_s.set_ike_sa_id.
245 */
246 static status_t set_ike_sa_id (private_message_t *this,ike_sa_id_t *ike_sa_id)
247 {
248 status_t status;
249 status = ike_sa_id->clone(ike_sa_id,&(this->ike_sa_id));
250 return status;
251 }
252
253 /**
254 * Implements message_t's get_ike_sa_id function.
255 * See #message_s.get_ike_sa_id.
256 */
257 static status_t get_ike_sa_id (private_message_t *this,ike_sa_id_t **ike_sa_id)
258 {
259 status_t status;
260 if (this->ike_sa_id == NULL)
261 {
262 return FAILED;
263 }
264 status = this->ike_sa_id->clone(this->ike_sa_id,ike_sa_id);
265 return status;
266 }
267
268
269 /**
270 * Implements message_t's set_message_id function.
271 * See #message_s.set_message_id.
272 */
273 static status_t set_message_id (private_message_t *this,u_int32_t message_id)
274 {
275 this->message_id = message_id;
276 return SUCCESS;
277 }
278
279
280 /**
281 * Implements message_t's set_message_id function.
282 * See #message_s.set_message_id.
283 */
284 static u_int32_t get_message_id (private_message_t *this)
285 {
286 return this->message_id;
287 }
288
289 /**
290 * Implements message_t's set_major_version function.
291 * See #message_s.set_major_version.
292 */
293 static status_t set_major_version (private_message_t *this,u_int8_t major_version)
294 {
295 this->major_version = major_version;
296 return SUCCESS;
297 }
298
299
300 /**
301 * Implements message_t's get_major_version function.
302 * See #message_s.get_major_version.
303 */
304 static u_int8_t get_major_version (private_message_t *this)
305 {
306 return this->major_version;
307 }
308
309 /**
310 * Implements message_t's set_minor_version function.
311 * See #message_s.set_minor_version.
312 */
313 static status_t set_minor_version (private_message_t *this,u_int8_t minor_version)
314 {
315 this->minor_version = minor_version;
316 return SUCCESS;
317 }
318
319
320 /**
321 * Implements message_t's get_minor_version function.
322 * See #message_s.get_minor_version.
323 */
324 static u_int8_t get_minor_version (private_message_t *this)
325 {
326 return this->minor_version;
327 }
328
329 /**
330 * Implements message_t's set_exchange_type function.
331 * See #message_s.set_exchange_type.
332 */
333 static status_t set_exchange_type (private_message_t *this,exchange_type_t exchange_type)
334 {
335 this->exchange_type = exchange_type;
336 return SUCCESS;
337 }
338
339
340 /**
341 * Implements message_t's get_exchange_type function.
342 * See #message_s.get_exchange_type.
343 */
344 static exchange_type_t get_exchange_type (private_message_t *this)
345 {
346 return this->exchange_type;
347 }
348
349
350 /**
351 * Implements message_t's set_request function.
352 * See #message_s.set_request.
353 */
354 static status_t set_request (private_message_t *this,bool request)
355 {
356 this->is_request = request;
357 return SUCCESS;
358 }
359
360 /**
361 * Implements message_t's get_request function.
362 * See #message_s.get_request.
363 */
364 static exchange_type_t get_request (private_message_t *this)
365 {
366 return this->is_request;
367 }
368
369 static status_t add_payload(private_message_t *this, payload_t *payload)
370 {
371 payload_t *last_payload;
372 if ((this->payloads->get_count(this->payloads) > 0) &&
373 (this->payloads->get_last(this->payloads,(void **) &last_payload) != SUCCESS))
374 {
375 return OUT_OF_RES;
376 }
377
378 if (this->payloads->insert_last(this->payloads, payload) != SUCCESS)
379 {
380 return OUT_OF_RES;
381 }
382 if (this->payloads->get_count(this->payloads) == 1)
383 {
384 this->first_payload = payload->get_type(payload);
385 }
386 else
387 {
388 last_payload->set_next_type(last_payload,payload->get_type(payload));
389 }
390
391 return SUCCESS;
392 }
393
394 static status_t set_source(private_message_t *this, host_t *host)
395 {
396 if (this->packet->source != NULL)
397 {
398 this->packet->source->destroy(this->packet->source);
399 }
400 this->packet->source = host;
401 return SUCCESS;
402 }
403
404 static status_t set_destination(private_message_t *this, host_t *host)
405 {
406 if (this->packet->destination != NULL)
407 {
408 this->packet->destination->destroy(this->packet->destination);
409 }
410 this->packet->destination = host;
411 return SUCCESS;
412 }
413
414 static status_t get_source(private_message_t *this, host_t **host)
415 {
416 *host = this->packet->source;
417 return SUCCESS;
418 }
419
420 static status_t get_destination(private_message_t *this, host_t **host)
421 {
422 *host = this->packet->destination;
423 return SUCCESS;
424 }
425
426
427 static status_t get_payload_iterator(private_message_t *this, linked_list_iterator_t **iterator)
428 {
429 return this->payloads->create_iterator(this->payloads, iterator, TRUE);
430 }
431
432
433 /**
434 * Implements message_t's generate function.
435 * See #message_s.generate.
436 */
437 static status_t generate(private_message_t *this, packet_t **packet)
438 {
439 generator_t *generator;
440 ike_header_t *ike_header;
441 payload_t *payload, *next_payload;
442 linked_list_iterator_t *iterator;
443 status_t status;
444
445 if (this->packet != NULL)
446 {
447 /* already generated packet is just cloned */
448 this->packet->clone(this->packet, packet);
449 }
450
451 if (this->exchange_type == EXCHANGE_TYPE_UNDEFINED)
452 {
453 return INVALID_STATE;
454 }
455
456 if (this->packet->source == NULL ||
457 this->packet->destination == NULL)
458 {
459 return INVALID_STATE;
460 }
461
462 ike_header = ike_header_create();
463 if (ike_header == NULL)
464 {
465 return OUT_OF_RES;
466 }
467
468
469 ike_header->set_exchange_type(ike_header, this->exchange_type);
470 ike_header->set_message_id(ike_header, this->message_id);
471 ike_header->set_response_flag(ike_header, !this->is_request);
472 ike_header->set_initiator_flag(ike_header, this->ike_sa_id->is_initiator(this->ike_sa_id));
473 ike_header->set_initiator_spi(ike_header, this->ike_sa_id->get_initiator_spi(this->ike_sa_id));
474 ike_header->set_responder_spi(ike_header, this->ike_sa_id->get_responder_spi(this->ike_sa_id));
475
476 generator = generator_create();
477 if (generator == NULL)
478 {
479 return OUT_OF_RES;
480 }
481
482 payload = (payload_t*)ike_header;
483
484 if (this->payloads->create_iterator(this->payloads, &iterator, TRUE) != SUCCESS)
485 {
486 generator->destroy(generator);
487 ike_header->destroy(ike_header);
488 return OUT_OF_RES;
489 }
490 while(iterator->has_next(iterator))
491 {
492 iterator->current(iterator, (void**)&next_payload);
493 payload->set_next_type(payload, next_payload->get_type(next_payload));
494 status = generator->generate_payload(generator, payload);
495 if (status != SUCCESS)
496 {
497 generator->destroy(generator);
498 ike_header->destroy(ike_header);
499 return status;
500 }
501 payload = next_payload;
502 }
503 iterator->destroy(iterator);
504
505 payload->set_next_type(payload, NO_PAYLOAD);
506 status = generator->generate_payload(generator, payload);
507 if (status != SUCCESS)
508 {
509 generator->destroy(generator);
510 ike_header->destroy(ike_header);
511 return status;
512 }
513
514 ike_header->destroy(ike_header);
515
516
517
518 if (this->packet->data.ptr != NULL)
519 {
520 allocator_free(this->packet->data.ptr);
521 }
522
523 status = generator->write_to_chunk(generator, &(this->packet->data));
524 if (status != SUCCESS)
525 {
526 generator->destroy(generator);
527 return status;
528 }
529
530 this->packet->clone(this->packet, packet);
531
532 generator->destroy(generator);
533 return SUCCESS;
534 }
535
536 /**
537 * Implements message_t's parse_header function.
538 * See #message_s.parse_header.
539 */
540 static status_t parse_header (private_message_t *this)
541 {
542 ike_header_t *ike_header;
543 status_t status;
544
545 this->parser->reset_context(this->parser);
546 status = this->parser->parse_payload(this->parser,HEADER,(payload_t **) &ike_header);
547 if (status != SUCCESS)
548 {
549 this->logger->log(this->logger, ERROR, "Header could not be parsed");
550 return status;
551
552 }
553
554 /* verify payload */
555 status = ike_header->payload_interface.verify(&(ike_header->payload_interface));
556 if (status != SUCCESS)
557 {
558 this->logger->log(this->logger, ERROR, "Header could not be verified");
559 return status;
560 }
561
562 if (this->ike_sa_id != NULL)
563 {
564 this->ike_sa_id->destroy(this->ike_sa_id);
565 }
566
567 this->ike_sa_id = ike_sa_id_create(ike_header->get_initiator_spi(ike_header),
568 ike_header->get_responder_spi(ike_header),
569 !ike_header->get_initiator_flag(ike_header));
570 if (this->ike_sa_id == NULL)
571 {
572 this->logger->log(this->logger, ERROR, "Could not creaee ike_sa_id object");
573 ike_header->destroy(ike_header);
574 return OUT_OF_RES;
575 }
576 this->exchange_type = ike_header->get_exchange_type(ike_header);
577 this->message_id = ike_header->get_message_id(ike_header);
578 this->is_request = (!(ike_header->get_response_flag(ike_header)));
579 this->major_version = ike_header->get_maj_version(ike_header);
580 this->minor_version = ike_header->get_min_version(ike_header);
581 this->first_payload = ike_header->payload_interface.get_next_type(&(ike_header->payload_interface));
582
583 ike_header->destroy(ike_header);
584 return SUCCESS;
585 }
586
587 /**
588 * Implements message_t's parse_body function.
589 * See #message_s.parse_body.
590 */
591 static status_t parse_body (private_message_t *this)
592 {
593 status_t status = SUCCESS;
594 int i;
595 payload_type_t current_payload_type = this->first_payload;
596 supported_payload_entry_t *supported_payloads;
597 size_t supported_payloads_count;
598
599
600 if (this->get_supported_payloads (this,&supported_payloads,&supported_payloads_count) != SUCCESS)
601 {
602 this->logger->log(this->logger, ERROR, "could not get supported payloads");
603 /* message type is not supported */
604 return FAILED;
605 }
606
607
608 this->logger->log(this->logger, ERROR, "first payload %s", mapping_find(payload_type_m, current_payload_type));
609
610 while (current_payload_type != NO_PAYLOAD)
611 {
612 payload_t *current_payload;
613 bool supported = FALSE;
614
615 this->logger->log(this->logger, ERROR, "Start parsing payload of type %s", mapping_find(payload_type_m, current_payload_type));
616 for (i = 0; i < supported_payloads_count;i++)
617 {
618 if (supported_payloads[i].payload_type == current_payload_type)
619 {
620 supported = TRUE;
621 break;
622 }
623 }
624 if (!supported && (current_payload_type != NO_PAYLOAD))
625 {
626 /* type not supported */
627 status = NOT_SUPPORTED;
628 this->logger->log(this->logger, ERROR, "Payload type %s not supported",mapping_find(payload_type_m,current_payload_type));
629 break;
630 }
631
632 status = this->parser->parse_payload(this->parser,current_payload_type,(payload_t **) &current_payload);
633 if (status != SUCCESS)
634 {
635 this->logger->log(this->logger, ERROR, "Payload type %s could not be parsed",mapping_find(payload_type_m,current_payload_type));
636 break;
637 }
638
639 status = current_payload->verify(current_payload);
640 if (status != SUCCESS)
641 {
642 this->logger->log(this->logger, ERROR, "Payload type %s could not be verified",mapping_find(payload_type_m,current_payload_type));
643 status = VERIFY_ERROR;
644 break;
645 }
646
647 /* get next payload type */
648 current_payload_type = current_payload->get_next_type(current_payload);
649
650 status = this->payloads->insert_last(this->payloads,current_payload);
651 if (status != SUCCESS)
652 {
653 this->logger->log(this->logger, ERROR, "Could not insert current payload to internal list cause of ressource exhausting");
654 break;
655 }
656
657 }
658 if (status != SUCCESS)
659 {
660 /* already parsed payload is destroyed later in destroy call from outside this object */
661 }
662 else
663 {
664 linked_list_iterator_t *iterator;
665
666 status = this->payloads->create_iterator(this->payloads,&iterator,TRUE);
667 if (status != SUCCESS)
668 {
669 this->logger->log(this->logger, ERROR, "Could not create iterator to check supported payloads");
670 return status;
671 }
672
673
674 /* check for payloads with wrong count*/
675 for (i = 0; i < supported_payloads_count;i++)
676 {
677 size_t min_occurence = supported_payloads[i].min_occurence;
678 size_t max_occurence = supported_payloads[i].max_occurence;
679 payload_type_t payload_type = supported_payloads[i].payload_type;
680 size_t found_payloads = 0;
681
682 iterator->reset(iterator);
683
684 while(iterator->has_next(iterator))
685 {
686 payload_t *current_payload;
687 status = iterator->current(iterator,(void **)&current_payload);
688 if (status != SUCCESS)
689 {
690 this->logger->log(this->logger, CONTROL|MORE, "Could not get payload from internal list");
691 iterator->destroy(iterator);
692 return status;
693 }
694 if (current_payload->get_type(current_payload) == payload_type)
695 {
696 found_payloads++;
697 if (found_payloads > max_occurence)
698 {
699 this->logger->log(this->logger, CONTROL|MORE, "Payload of type %s more than %d times (%d) occured in current message",
700 mapping_find(payload_type_m,current_payload->get_type(current_payload)),max_occurence,found_payloads);
701 iterator->destroy(iterator);
702 return NOT_SUPPORTED;
703 }
704 }
705
706 }
707 if (found_payloads < min_occurence)
708 {
709 this->logger->log(this->logger, CONTROL|MORE, "Payload of type %s not occured %d times",
710 mapping_find(payload_type_m,payload_type),min_occurence);
711 iterator->destroy(iterator);
712 return NOT_SUPPORTED;
713 }
714
715 }
716 iterator->destroy(iterator);
717 }
718 return status;
719 }
720
721
722
723 /**
724 * Implements message_t's destroy function.
725 * See #message_s.destroy.
726 */
727 static status_t destroy (private_message_t *this)
728 {
729 linked_list_iterator_t *iterator;
730
731 if (this->packet != NULL)
732 {
733 this->packet->destroy(this->packet);
734 }
735 if (this->ike_sa_id != NULL)
736 {
737 this->ike_sa_id->destroy(this->ike_sa_id);
738 }
739
740 this->payloads->create_iterator(this->payloads, &iterator, TRUE);
741 while (iterator->has_next(iterator))
742 {
743 payload_t *payload;
744 iterator->current(iterator, (void**)&payload);
745 this->logger->log(this->logger, CONTROL|MORE, "Destroying payload of type %s",
746 mapping_find(payload_type_m, payload->get_type(payload)));
747 payload->destroy(payload);
748 }
749 iterator->destroy(iterator);
750 this->payloads->destroy(this->payloads);
751 this->parser->destroy(this->parser);
752
753 allocator_free(this);
754 return SUCCESS;
755 }
756
757 /*
758 * Described in Header-File
759 */
760 message_t *message_create_from_packet(packet_t *packet)
761 {
762 private_message_t *this = allocator_alloc_thing(private_message_t);
763 if (this == NULL)
764 {
765 return NULL;
766 }
767
768 /* public functions */
769 this->public.set_major_version = (status_t(*)(message_t*, u_int8_t))set_major_version;
770 this->public.get_major_version = (u_int8_t(*)(message_t*))get_major_version;
771 this->public.set_minor_version = (status_t(*)(message_t*, u_int8_t))set_minor_version;
772 this->public.get_minor_version = (u_int8_t(*)(message_t*))get_minor_version;
773 this->public.set_message_id = (status_t(*)(message_t*, u_int32_t))set_message_id;
774 this->public.get_message_id = (u_int32_t(*)(message_t*))get_message_id;
775 this->public.set_ike_sa_id = (status_t(*)(message_t*, ike_sa_id_t *))set_ike_sa_id;
776 this->public.get_ike_sa_id = (status_t(*)(message_t*, ike_sa_id_t **))get_ike_sa_id;
777 this->public.set_exchange_type = (status_t(*)(message_t*, exchange_type_t))set_exchange_type;
778 this->public.get_exchange_type = (exchange_type_t(*)(message_t*))get_exchange_type;
779 this->public.set_request = (status_t(*)(message_t*, bool))set_request;
780 this->public.get_request = (bool(*)(message_t*))get_request;
781 this->public.add_payload = (status_t(*)(message_t*,payload_t*))add_payload;
782 this->public.generate = (status_t (*) (message_t *, packet_t**)) generate;
783 this->public.set_source = (status_t (*) (message_t*,host_t*)) set_source;
784 this->public.get_source = (status_t (*) (message_t*,host_t**)) get_source;
785 this->public.set_destination = (status_t (*) (message_t*,host_t*)) set_destination;
786 this->public.get_destination = (status_t (*) (message_t*,host_t**)) get_destination;
787 this->public.get_payload_iterator = (status_t (*) (message_t *, linked_list_iterator_t **)) get_payload_iterator;
788 this->public.parse_header = (status_t (*) (message_t *)) parse_header;
789 this->public.parse_body = (status_t (*) (message_t *)) parse_body;
790 this->public.destroy = (status_t(*)(message_t*))destroy;
791
792 /* public values */
793 this->exchange_type = EXCHANGE_TYPE_UNDEFINED;
794 this->is_request = TRUE;
795 this->ike_sa_id = NULL;
796 this->first_payload = NO_PAYLOAD;
797 this->message_id = 0;
798
799 /* private functions */
800 this->get_supported_payloads = get_supported_payloads;
801
802 /* private values */
803 if (packet == NULL)
804 {
805 packet = packet_create();
806 }
807 if (packet == NULL)
808 {
809 allocator_free(this);
810 return NULL;
811 }
812 this->packet = packet;
813 this->payloads = linked_list_create();
814 if (this->payloads == NULL)
815 {
816 allocator_free(this);
817 return NULL;
818 }
819
820 /* parser is created from data of packet */
821 this->parser = parser_create(this->packet->data);
822 if (this->parser == NULL)
823 {
824 this->payloads->destroy(this->payloads);
825 allocator_free(this);
826 return NULL;
827 }
828
829 this->logger = global_logger_manager->create_logger(global_logger_manager, MESSAGE, NULL);
830 if (this->logger == NULL)
831 {
832 this->parser->destroy(this->parser);
833 this->payloads->destroy(this->payloads);
834 allocator_free(this);
835 return NULL;
836 }
837
838 return (&this->public);
839 }
840
841 /*
842 * Described in Header-File
843 */
844 message_t *message_create()
845 {
846 return message_create_from_packet(NULL);
847 }