1
2 /*****
3 *
4 * Copyright (C) 2004-2015 CS-SI. All Rights Reserved.
5 * Author: Yoann Vandoorselaere <yoann.v@prelude-ids.com>
6 * Author: Nicolas Delon <nicolas.delon@prelude-ids.com>
7 *
8 * This file is part of the Prelude library.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option)
13 * any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 *
24 *****/
25
26 /* Auto-generated by the GenerateIDMEFMessagePrintC package */
27
28 #include "config.h"
29 #include "libmissing.h"
30
31 #include <stdio.h>
32
33 #include "idmef.h"
34 #include "idmef-tree-wrap.h"
35 #include "idmef-message-print.h"
36
37
38 static int indent = 0;
39
print_indent(prelude_io_t * fd)40 static void print_indent(prelude_io_t *fd)
41 {
42 int cnt;
43
44 for ( cnt = 0; cnt < indent; cnt++ )
45 prelude_io_write(fd, " ", 1);
46 }
47
48
49
print_string(prelude_string_t * string,prelude_io_t * fd)50 static void print_string(prelude_string_t *string, prelude_io_t *fd)
51 {
52 if ( prelude_string_is_empty(string) )
53 prelude_io_write(fd, "<empty>", 7);
54 else
55 prelude_io_write(fd, prelude_string_get_string(string), prelude_string_get_len(string));
56 }
57
58
59
print_uint8(uint8_t i,prelude_io_t * fd)60 static void print_uint8(uint8_t i, prelude_io_t *fd)
61 {
62 int len;
63 char buf[sizeof("255")];
64
65 /*
66 * %hh convertion specifier is not portable.
67 */
68 len = snprintf(buf, sizeof(buf), "%u", (unsigned int) i);
69 prelude_io_write(fd, buf, len);
70 }
71
72
print_uint16(uint16_t i,prelude_io_t * fd)73 static void print_uint16(uint16_t i, prelude_io_t *fd)
74 {
75 int len;
76 char buf[sizeof("65535")];
77
78 len = snprintf(buf, sizeof(buf), "%hu", i);
79 prelude_io_write(fd, buf, len);
80 }
81
82
print_int32(int32_t i,prelude_io_t * fd)83 static void print_int32(int32_t i, prelude_io_t *fd)
84 {
85 int len;
86 char buf[sizeof("4294967296")];
87
88 len = snprintf(buf, sizeof(buf), "%d", i);
89 prelude_io_write(fd, buf, len);
90 }
91
92
print_uint32(uint32_t i,prelude_io_t * fd)93 static void print_uint32(uint32_t i, prelude_io_t *fd)
94 {
95 int len;
96 char buf[sizeof("4294967296")];
97
98 len = snprintf(buf, sizeof(buf), "%u", i);
99 prelude_io_write(fd, buf, len);
100 }
101
102
103
print_uint64(uint64_t i,prelude_io_t * fd)104 static void print_uint64(uint64_t i, prelude_io_t *fd)
105 {
106 int len;
107 char buf[sizeof("18446744073709551616")];
108
109 len = snprintf(buf, sizeof(buf), "%" PRELUDE_PRIu64, i);
110 prelude_io_write(fd, buf, len);
111 }
112
113
114
print_float(float f,prelude_io_t * fd)115 static void print_float(float f, prelude_io_t *fd)
116 {
117 int len;
118 char buf[32];
119
120 len = snprintf(buf, sizeof(buf), "%f", f);
121 prelude_io_write(fd, buf, len);
122 }
123
124
125
126
print_time(idmef_time_t * t,prelude_io_t * fd)127 static void print_time(idmef_time_t *t, prelude_io_t *fd)
128 {
129 int len;
130 time_t _time;
131 struct tm _tm;
132 char tmp[32], buf[128];
133
134 _time = idmef_time_get_sec(t) + idmef_time_get_gmt_offset(t);
135
136 if ( ! gmtime_r(&_time, &_tm) )
137 return;
138
139 len = strftime(tmp, sizeof(tmp), "%d/%m/%Y %H:%M:%S", &_tm);
140 if ( len == 0 )
141 return;
142
143 len = snprintf(buf, sizeof(buf), "%s.%u %+.2d:%.2d",
144 tmp, idmef_time_get_usec(t), idmef_time_get_gmt_offset(t) / 3600,
145 idmef_time_get_gmt_offset(t) % 3600 / 60);
146
147 prelude_io_write(fd, buf, len);
148 }
149
150
151
152 /* print data as a string */
153
print_data(idmef_data_t * data,prelude_io_t * fd)154 static int print_data(idmef_data_t *data, prelude_io_t *fd)
155 {
156 int ret;
157 prelude_string_t *out;
158
159 ret = prelude_string_new(&out);
160 if ( ret < 0 )
161 return ret;
162
163 ret = idmef_data_to_string(data, out);
164 if ( ret < 0 ) {
165 prelude_string_destroy(out);
166 return ret;
167 }
168
169 prelude_io_write(fd, prelude_string_get_string(out), prelude_string_get_len(out));
170 prelude_string_destroy(out);
171
172 return 0;
173 }
174
175
176
print_enum(const char * s,int i,prelude_io_t * fd)177 static void print_enum(const char *s, int i, prelude_io_t *fd)
178 {
179 int len;
180 char buf[512];
181
182 if ( ! s )
183 s = "<invalid enum value>";
184
185 len = snprintf(buf, sizeof(buf), "%s (%d)", s, i);
186 prelude_io_write(fd, buf, len);
187 }
188
189
190 /**
191 * idmef_additional_data_print:
192 * @ptr: Pointer to an idmef_additional_data_t object.
193 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
194 *
195 * This function will convert @ptr to a string suitable for writing,
196 * and write it to the provided @fd descriptor.
197 */
idmef_additional_data_print(idmef_additional_data_t * ptr,prelude_io_t * fd)198 void idmef_additional_data_print(idmef_additional_data_t *ptr, prelude_io_t *fd)
199 {
200 if ( ! ptr )
201 return;
202
203 indent += 8;
204
205 {
206 prelude_string_t *field;
207 const char tmp[] = "meaning: ";
208
209 field = idmef_additional_data_get_meaning(ptr);
210
211 if ( field ) {
212 print_indent(fd);
213 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
214 print_string(field, fd);
215 prelude_io_write(fd, "\n", sizeof("\n") - 1);
216 }
217 }
218
219 {
220 int i = idmef_additional_data_get_type(ptr);
221
222
223
224 {
225 print_indent(fd);
226 prelude_io_write(fd, "type: ", sizeof("type: ") - 1);
227 print_enum(idmef_additional_data_type_to_string(i), i, fd);
228 prelude_io_write(fd, "\n", sizeof("\n") - 1);
229 }
230 }
231
232 {
233 idmef_data_t *field;
234 const char tmp[] = "data: ";
235
236 field = idmef_additional_data_get_data(ptr);
237
238 if ( field ) {
239 print_indent(fd);
240 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
241
242 if ( idmef_additional_data_get_type(ptr) != IDMEF_ADDITIONAL_DATA_TYPE_NTPSTAMP )
243 print_data(field, fd);
244
245 else {
246 int ret;
247 uint64_t i;
248 prelude_string_t *out;
249
250 ret = prelude_string_new(&out);
251 if ( ret < 0 )
252 return;
253
254 i = idmef_data_get_int(field);
255 ret = prelude_string_sprintf(out, "0x%" PRELUDE_PRIx32 ".0x%" PRELUDE_PRIx32 "", (uint32_t) (i >> 32), (uint32_t) i);
256 if ( ret < 0 ) {
257 prelude_string_destroy(out);
258 return;
259 }
260
261 prelude_io_write(fd, prelude_string_get_string(out), prelude_string_get_len(out));
262 prelude_string_destroy(out);
263 }
264 prelude_io_write(fd, "\n", sizeof("\n") - 1);
265 }
266 }
267
268 indent -= 8;
269 }
270
271 /**
272 * idmef_reference_print:
273 * @ptr: Pointer to an idmef_reference_t object.
274 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
275 *
276 * This function will convert @ptr to a string suitable for writing,
277 * and write it to the provided @fd descriptor.
278 */
idmef_reference_print(idmef_reference_t * ptr,prelude_io_t * fd)279 void idmef_reference_print(idmef_reference_t *ptr, prelude_io_t *fd)
280 {
281 if ( ! ptr )
282 return;
283
284 indent += 8;
285
286 {
287 int i = idmef_reference_get_origin(ptr);
288
289
290
291 {
292 print_indent(fd);
293 prelude_io_write(fd, "origin: ", sizeof("origin: ") - 1);
294 print_enum(idmef_reference_origin_to_string(i), i, fd);
295 prelude_io_write(fd, "\n", sizeof("\n") - 1);
296 }
297 }
298
299 {
300 prelude_string_t *field;
301 const char tmp[] = "name: ";
302
303 field = idmef_reference_get_name(ptr);
304
305 if ( field ) {
306 print_indent(fd);
307 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
308 print_string(field, fd);
309 prelude_io_write(fd, "\n", sizeof("\n") - 1);
310 }
311 }
312
313 {
314 prelude_string_t *field;
315 const char tmp[] = "url: ";
316
317 field = idmef_reference_get_url(ptr);
318
319 if ( field ) {
320 print_indent(fd);
321 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
322 print_string(field, fd);
323 prelude_io_write(fd, "\n", sizeof("\n") - 1);
324 }
325 }
326
327 {
328 prelude_string_t *field;
329 const char tmp[] = "meaning: ";
330
331 field = idmef_reference_get_meaning(ptr);
332
333 if ( field ) {
334 print_indent(fd);
335 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
336 print_string(field, fd);
337 prelude_io_write(fd, "\n", sizeof("\n") - 1);
338 }
339 }
340
341 indent -= 8;
342 }
343
344 /**
345 * idmef_classification_print:
346 * @ptr: Pointer to an idmef_classification_t object.
347 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
348 *
349 * This function will convert @ptr to a string suitable for writing,
350 * and write it to the provided @fd descriptor.
351 */
idmef_classification_print(idmef_classification_t * ptr,prelude_io_t * fd)352 void idmef_classification_print(idmef_classification_t *ptr, prelude_io_t *fd)
353 {
354 if ( ! ptr )
355 return;
356
357 indent += 8;
358
359 {
360 prelude_string_t *field;
361 const char tmp[] = "ident: ";
362
363 field = idmef_classification_get_ident(ptr);
364
365 if ( field ) {
366 print_indent(fd);
367 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
368 print_string(field, fd);
369 prelude_io_write(fd, "\n", sizeof("\n") - 1);
370 }
371 }
372
373 {
374 prelude_string_t *field;
375 const char tmp[] = "text: ";
376
377 field = idmef_classification_get_text(ptr);
378
379 if ( field ) {
380 print_indent(fd);
381 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
382 print_string(field, fd);
383 prelude_io_write(fd, "\n", sizeof("\n") - 1);
384 }
385 }
386
387 {
388 char buf[128];
389 idmef_reference_t *elem = NULL;
390 int cnt = 0, len;
391
392 while ( (elem = idmef_classification_get_next_reference(ptr, elem)) ) {
393 print_indent(fd);
394
395 len = snprintf(buf, sizeof(buf), "reference(%d): \n", cnt);
396 prelude_io_write(fd, buf, len);
397 idmef_reference_print(elem, fd);
398
399 cnt++;
400 }
401 }
402
403 indent -= 8;
404 }
405
406 /**
407 * idmef_user_id_print:
408 * @ptr: Pointer to an idmef_user_id_t object.
409 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
410 *
411 * This function will convert @ptr to a string suitable for writing,
412 * and write it to the provided @fd descriptor.
413 */
idmef_user_id_print(idmef_user_id_t * ptr,prelude_io_t * fd)414 void idmef_user_id_print(idmef_user_id_t *ptr, prelude_io_t *fd)
415 {
416 if ( ! ptr )
417 return;
418
419 indent += 8;
420
421 {
422 prelude_string_t *field;
423 const char tmp[] = "ident: ";
424
425 field = idmef_user_id_get_ident(ptr);
426
427 if ( field ) {
428 print_indent(fd);
429 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
430 print_string(field, fd);
431 prelude_io_write(fd, "\n", sizeof("\n") - 1);
432 }
433 }
434
435 {
436 int i = idmef_user_id_get_type(ptr);
437
438
439
440 {
441 print_indent(fd);
442 prelude_io_write(fd, "type: ", sizeof("type: ") - 1);
443 print_enum(idmef_user_id_type_to_string(i), i, fd);
444 prelude_io_write(fd, "\n", sizeof("\n") - 1);
445 }
446 }
447
448 {
449 prelude_string_t *field;
450 const char tmp[] = "tty: ";
451
452 field = idmef_user_id_get_tty(ptr);
453
454 if ( field ) {
455 print_indent(fd);
456 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
457 print_string(field, fd);
458 prelude_io_write(fd, "\n", sizeof("\n") - 1);
459 }
460 }
461
462 {
463 prelude_string_t *field;
464 const char tmp[] = "name: ";
465
466 field = idmef_user_id_get_name(ptr);
467
468 if ( field ) {
469 print_indent(fd);
470 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
471 print_string(field, fd);
472 prelude_io_write(fd, "\n", sizeof("\n") - 1);
473 }
474 }
475
476 {
477 uint32_t *field;
478 const char tmp[] = "number: ";
479
480 field = idmef_user_id_get_number(ptr);
481
482 if ( field ) {
483 print_indent(fd);
484 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
485 print_uint32(*field, fd);
486 prelude_io_write(fd, "\n", sizeof("\n") - 1);
487 }
488 }
489
490 indent -= 8;
491 }
492
493 /**
494 * idmef_user_print:
495 * @ptr: Pointer to an idmef_user_t object.
496 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
497 *
498 * This function will convert @ptr to a string suitable for writing,
499 * and write it to the provided @fd descriptor.
500 */
idmef_user_print(idmef_user_t * ptr,prelude_io_t * fd)501 void idmef_user_print(idmef_user_t *ptr, prelude_io_t *fd)
502 {
503 if ( ! ptr )
504 return;
505
506 indent += 8;
507
508 {
509 prelude_string_t *field;
510 const char tmp[] = "ident: ";
511
512 field = idmef_user_get_ident(ptr);
513
514 if ( field ) {
515 print_indent(fd);
516 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
517 print_string(field, fd);
518 prelude_io_write(fd, "\n", sizeof("\n") - 1);
519 }
520 }
521
522 {
523 int i = idmef_user_get_category(ptr);
524
525
526
527 {
528 print_indent(fd);
529 prelude_io_write(fd, "category: ", sizeof("category: ") - 1);
530 print_enum(idmef_user_category_to_string(i), i, fd);
531 prelude_io_write(fd, "\n", sizeof("\n") - 1);
532 }
533 }
534
535 {
536 char buf[128];
537 idmef_user_id_t *elem = NULL;
538 int cnt = 0, len;
539
540 while ( (elem = idmef_user_get_next_user_id(ptr, elem)) ) {
541 print_indent(fd);
542
543 len = snprintf(buf, sizeof(buf), "user_id(%d): \n", cnt);
544 prelude_io_write(fd, buf, len);
545 idmef_user_id_print(elem, fd);
546
547 cnt++;
548 }
549 }
550
551 indent -= 8;
552 }
553
554 /**
555 * idmef_address_print:
556 * @ptr: Pointer to an idmef_address_t object.
557 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
558 *
559 * This function will convert @ptr to a string suitable for writing,
560 * and write it to the provided @fd descriptor.
561 */
idmef_address_print(idmef_address_t * ptr,prelude_io_t * fd)562 void idmef_address_print(idmef_address_t *ptr, prelude_io_t *fd)
563 {
564 if ( ! ptr )
565 return;
566
567 indent += 8;
568
569 {
570 prelude_string_t *field;
571 const char tmp[] = "ident: ";
572
573 field = idmef_address_get_ident(ptr);
574
575 if ( field ) {
576 print_indent(fd);
577 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
578 print_string(field, fd);
579 prelude_io_write(fd, "\n", sizeof("\n") - 1);
580 }
581 }
582
583 {
584 int i = idmef_address_get_category(ptr);
585
586
587
588 {
589 print_indent(fd);
590 prelude_io_write(fd, "category: ", sizeof("category: ") - 1);
591 print_enum(idmef_address_category_to_string(i), i, fd);
592 prelude_io_write(fd, "\n", sizeof("\n") - 1);
593 }
594 }
595
596 {
597 prelude_string_t *field;
598 const char tmp[] = "vlan_name: ";
599
600 field = idmef_address_get_vlan_name(ptr);
601
602 if ( field ) {
603 print_indent(fd);
604 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
605 print_string(field, fd);
606 prelude_io_write(fd, "\n", sizeof("\n") - 1);
607 }
608 }
609
610 {
611 int32_t *field;
612 const char tmp[] = "vlan_num: ";
613
614 field = idmef_address_get_vlan_num(ptr);
615
616 if ( field ) {
617 print_indent(fd);
618 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
619 print_int32(*field, fd);
620 prelude_io_write(fd, "\n", sizeof("\n") - 1);
621 }
622 }
623
624 {
625 prelude_string_t *field;
626 const char tmp[] = "address: ";
627
628 field = idmef_address_get_address(ptr);
629
630 if ( field ) {
631 print_indent(fd);
632 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
633 print_string(field, fd);
634 prelude_io_write(fd, "\n", sizeof("\n") - 1);
635 }
636 }
637
638 {
639 prelude_string_t *field;
640 const char tmp[] = "netmask: ";
641
642 field = idmef_address_get_netmask(ptr);
643
644 if ( field ) {
645 print_indent(fd);
646 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
647 print_string(field, fd);
648 prelude_io_write(fd, "\n", sizeof("\n") - 1);
649 }
650 }
651
652 indent -= 8;
653 }
654
655 /**
656 * idmef_process_print:
657 * @ptr: Pointer to an idmef_process_t object.
658 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
659 *
660 * This function will convert @ptr to a string suitable for writing,
661 * and write it to the provided @fd descriptor.
662 */
idmef_process_print(idmef_process_t * ptr,prelude_io_t * fd)663 void idmef_process_print(idmef_process_t *ptr, prelude_io_t *fd)
664 {
665 if ( ! ptr )
666 return;
667
668 indent += 8;
669
670 {
671 prelude_string_t *field;
672 const char tmp[] = "ident: ";
673
674 field = idmef_process_get_ident(ptr);
675
676 if ( field ) {
677 print_indent(fd);
678 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
679 print_string(field, fd);
680 prelude_io_write(fd, "\n", sizeof("\n") - 1);
681 }
682 }
683
684 {
685 prelude_string_t *field;
686 const char tmp[] = "name: ";
687
688 field = idmef_process_get_name(ptr);
689
690 if ( field ) {
691 print_indent(fd);
692 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
693 print_string(field, fd);
694 prelude_io_write(fd, "\n", sizeof("\n") - 1);
695 }
696 }
697
698 {
699 uint32_t *field;
700 const char tmp[] = "pid: ";
701
702 field = idmef_process_get_pid(ptr);
703
704 if ( field ) {
705 print_indent(fd);
706 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
707 print_uint32(*field, fd);
708 prelude_io_write(fd, "\n", sizeof("\n") - 1);
709 }
710 }
711
712 {
713 prelude_string_t *field;
714 const char tmp[] = "path: ";
715
716 field = idmef_process_get_path(ptr);
717
718 if ( field ) {
719 print_indent(fd);
720 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
721 print_string(field, fd);
722 prelude_io_write(fd, "\n", sizeof("\n") - 1);
723 }
724 }
725
726 {
727 char buf[128];
728 prelude_string_t *elem = NULL;
729 int cnt = 0, len;
730
731 while ( (elem = idmef_process_get_next_arg(ptr, elem)) ) {
732 print_indent(fd);
733
734 len = snprintf(buf, sizeof(buf), "arg(%d): ", cnt);
735 prelude_io_write(fd, buf, len);
736 print_string(elem, fd);
737 prelude_io_write(fd, "\n", sizeof("\n") - 1);
738
739 cnt++;
740 }
741 }
742
743 {
744 char buf[128];
745 prelude_string_t *elem = NULL;
746 int cnt = 0, len;
747
748 while ( (elem = idmef_process_get_next_env(ptr, elem)) ) {
749 print_indent(fd);
750
751 len = snprintf(buf, sizeof(buf), "env(%d): ", cnt);
752 prelude_io_write(fd, buf, len);
753 print_string(elem, fd);
754 prelude_io_write(fd, "\n", sizeof("\n") - 1);
755
756 cnt++;
757 }
758 }
759
760 indent -= 8;
761 }
762
763 /**
764 * idmef_web_service_print:
765 * @ptr: Pointer to an idmef_web_service_t object.
766 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
767 *
768 * This function will convert @ptr to a string suitable for writing,
769 * and write it to the provided @fd descriptor.
770 */
idmef_web_service_print(idmef_web_service_t * ptr,prelude_io_t * fd)771 void idmef_web_service_print(idmef_web_service_t *ptr, prelude_io_t *fd)
772 {
773 if ( ! ptr )
774 return;
775
776 indent += 8;
777
778 {
779 prelude_string_t *field;
780 const char tmp[] = "url: ";
781
782 field = idmef_web_service_get_url(ptr);
783
784 if ( field ) {
785 print_indent(fd);
786 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
787 print_string(field, fd);
788 prelude_io_write(fd, "\n", sizeof("\n") - 1);
789 }
790 }
791
792 {
793 prelude_string_t *field;
794 const char tmp[] = "cgi: ";
795
796 field = idmef_web_service_get_cgi(ptr);
797
798 if ( field ) {
799 print_indent(fd);
800 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
801 print_string(field, fd);
802 prelude_io_write(fd, "\n", sizeof("\n") - 1);
803 }
804 }
805
806 {
807 prelude_string_t *field;
808 const char tmp[] = "http_method: ";
809
810 field = idmef_web_service_get_http_method(ptr);
811
812 if ( field ) {
813 print_indent(fd);
814 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
815 print_string(field, fd);
816 prelude_io_write(fd, "\n", sizeof("\n") - 1);
817 }
818 }
819
820 {
821 char buf[128];
822 prelude_string_t *elem = NULL;
823 int cnt = 0, len;
824
825 while ( (elem = idmef_web_service_get_next_arg(ptr, elem)) ) {
826 print_indent(fd);
827
828 len = snprintf(buf, sizeof(buf), "arg(%d): ", cnt);
829 prelude_io_write(fd, buf, len);
830 print_string(elem, fd);
831 prelude_io_write(fd, "\n", sizeof("\n") - 1);
832
833 cnt++;
834 }
835 }
836
837 indent -= 8;
838 }
839
840 /**
841 * idmef_snmp_service_print:
842 * @ptr: Pointer to an idmef_snmp_service_t object.
843 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
844 *
845 * This function will convert @ptr to a string suitable for writing,
846 * and write it to the provided @fd descriptor.
847 */
idmef_snmp_service_print(idmef_snmp_service_t * ptr,prelude_io_t * fd)848 void idmef_snmp_service_print(idmef_snmp_service_t *ptr, prelude_io_t *fd)
849 {
850 if ( ! ptr )
851 return;
852
853 indent += 8;
854
855 {
856 prelude_string_t *field;
857 const char tmp[] = "oid: ";
858
859 field = idmef_snmp_service_get_oid(ptr);
860
861 if ( field ) {
862 print_indent(fd);
863 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
864 print_string(field, fd);
865 prelude_io_write(fd, "\n", sizeof("\n") - 1);
866 }
867 }
868
869 {
870 uint32_t *field;
871 const char tmp[] = "message_processing_model: ";
872
873 field = idmef_snmp_service_get_message_processing_model(ptr);
874
875 if ( field ) {
876 print_indent(fd);
877 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
878 print_uint32(*field, fd);
879 prelude_io_write(fd, "\n", sizeof("\n") - 1);
880 }
881 }
882
883 {
884 uint32_t *field;
885 const char tmp[] = "security_model: ";
886
887 field = idmef_snmp_service_get_security_model(ptr);
888
889 if ( field ) {
890 print_indent(fd);
891 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
892 print_uint32(*field, fd);
893 prelude_io_write(fd, "\n", sizeof("\n") - 1);
894 }
895 }
896
897 {
898 prelude_string_t *field;
899 const char tmp[] = "security_name: ";
900
901 field = idmef_snmp_service_get_security_name(ptr);
902
903 if ( field ) {
904 print_indent(fd);
905 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
906 print_string(field, fd);
907 prelude_io_write(fd, "\n", sizeof("\n") - 1);
908 }
909 }
910
911 {
912 uint32_t *field;
913 const char tmp[] = "security_level: ";
914
915 field = idmef_snmp_service_get_security_level(ptr);
916
917 if ( field ) {
918 print_indent(fd);
919 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
920 print_uint32(*field, fd);
921 prelude_io_write(fd, "\n", sizeof("\n") - 1);
922 }
923 }
924
925 {
926 prelude_string_t *field;
927 const char tmp[] = "context_name: ";
928
929 field = idmef_snmp_service_get_context_name(ptr);
930
931 if ( field ) {
932 print_indent(fd);
933 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
934 print_string(field, fd);
935 prelude_io_write(fd, "\n", sizeof("\n") - 1);
936 }
937 }
938
939 {
940 prelude_string_t *field;
941 const char tmp[] = "context_engine_id: ";
942
943 field = idmef_snmp_service_get_context_engine_id(ptr);
944
945 if ( field ) {
946 print_indent(fd);
947 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
948 print_string(field, fd);
949 prelude_io_write(fd, "\n", sizeof("\n") - 1);
950 }
951 }
952
953 {
954 prelude_string_t *field;
955 const char tmp[] = "command: ";
956
957 field = idmef_snmp_service_get_command(ptr);
958
959 if ( field ) {
960 print_indent(fd);
961 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
962 print_string(field, fd);
963 prelude_io_write(fd, "\n", sizeof("\n") - 1);
964 }
965 }
966
967 {
968 prelude_string_t *field;
969 const char tmp[] = "community: ";
970
971 field = idmef_snmp_service_get_community(ptr);
972
973 if ( field ) {
974 print_indent(fd);
975 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
976 print_string(field, fd);
977 prelude_io_write(fd, "\n", sizeof("\n") - 1);
978 }
979 }
980
981 indent -= 8;
982 }
983
984 /**
985 * idmef_service_print:
986 * @ptr: Pointer to an idmef_service_t object.
987 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
988 *
989 * This function will convert @ptr to a string suitable for writing,
990 * and write it to the provided @fd descriptor.
991 */
idmef_service_print(idmef_service_t * ptr,prelude_io_t * fd)992 void idmef_service_print(idmef_service_t *ptr, prelude_io_t *fd)
993 {
994 if ( ! ptr )
995 return;
996
997 indent += 8;
998
999 {
1000 prelude_string_t *field;
1001 const char tmp[] = "ident: ";
1002
1003 field = idmef_service_get_ident(ptr);
1004
1005 if ( field ) {
1006 print_indent(fd);
1007 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1008 print_string(field, fd);
1009 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1010 }
1011 }
1012
1013 {
1014 uint8_t *field;
1015 const char tmp[] = "ip_version: ";
1016
1017 field = idmef_service_get_ip_version(ptr);
1018
1019 if ( field ) {
1020 print_indent(fd);
1021 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1022 print_uint8(*field, fd);
1023 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1024 }
1025 }
1026
1027 {
1028 uint8_t *field;
1029 const char tmp[] = "iana_protocol_number: ";
1030
1031 field = idmef_service_get_iana_protocol_number(ptr);
1032
1033 if ( field ) {
1034 print_indent(fd);
1035 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1036 print_uint8(*field, fd);
1037 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1038 }
1039 }
1040
1041 {
1042 prelude_string_t *field;
1043 const char tmp[] = "iana_protocol_name: ";
1044
1045 field = idmef_service_get_iana_protocol_name(ptr);
1046
1047 if ( field ) {
1048 print_indent(fd);
1049 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1050 print_string(field, fd);
1051 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1052 }
1053 }
1054
1055 {
1056 prelude_string_t *field;
1057 const char tmp[] = "name: ";
1058
1059 field = idmef_service_get_name(ptr);
1060
1061 if ( field ) {
1062 print_indent(fd);
1063 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1064 print_string(field, fd);
1065 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1066 }
1067 }
1068
1069 {
1070 uint16_t *field;
1071 const char tmp[] = "port: ";
1072
1073 field = idmef_service_get_port(ptr);
1074
1075 if ( field ) {
1076 print_indent(fd);
1077 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1078 print_uint16(*field, fd);
1079 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1080 }
1081 }
1082
1083 {
1084 prelude_string_t *field;
1085 const char tmp[] = "portlist: ";
1086
1087 field = idmef_service_get_portlist(ptr);
1088
1089 if ( field ) {
1090 print_indent(fd);
1091 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1092 print_string(field, fd);
1093 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1094 }
1095 }
1096
1097 {
1098 prelude_string_t *field;
1099 const char tmp[] = "protocol: ";
1100
1101 field = idmef_service_get_protocol(ptr);
1102
1103 if ( field ) {
1104 print_indent(fd);
1105 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1106 print_string(field, fd);
1107 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1108 }
1109 }
1110
1111 switch ( idmef_service_get_type(ptr) ) {
1112 case IDMEF_SERVICE_TYPE_WEB:
1113 print_indent(fd);
1114 prelude_io_write(fd, "web_service:\n", sizeof("web_service:\n") - 1);
1115 idmef_web_service_print(idmef_service_get_web_service(ptr), fd);
1116 break;
1117
1118 case IDMEF_SERVICE_TYPE_SNMP:
1119 print_indent(fd);
1120 prelude_io_write(fd, "snmp_service:\n", sizeof("snmp_service:\n") - 1);
1121 idmef_snmp_service_print(idmef_service_get_snmp_service(ptr), fd);
1122 break;
1123
1124 default:
1125 break;
1126 }
1127
1128 indent -= 8;
1129 }
1130
1131 /**
1132 * idmef_node_print:
1133 * @ptr: Pointer to an idmef_node_t object.
1134 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
1135 *
1136 * This function will convert @ptr to a string suitable for writing,
1137 * and write it to the provided @fd descriptor.
1138 */
idmef_node_print(idmef_node_t * ptr,prelude_io_t * fd)1139 void idmef_node_print(idmef_node_t *ptr, prelude_io_t *fd)
1140 {
1141 if ( ! ptr )
1142 return;
1143
1144 indent += 8;
1145
1146 {
1147 prelude_string_t *field;
1148 const char tmp[] = "ident: ";
1149
1150 field = idmef_node_get_ident(ptr);
1151
1152 if ( field ) {
1153 print_indent(fd);
1154 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1155 print_string(field, fd);
1156 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1157 }
1158 }
1159
1160 {
1161 int i = idmef_node_get_category(ptr);
1162
1163
1164
1165 {
1166 print_indent(fd);
1167 prelude_io_write(fd, "category: ", sizeof("category: ") - 1);
1168 print_enum(idmef_node_category_to_string(i), i, fd);
1169 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1170 }
1171 }
1172
1173 {
1174 prelude_string_t *field;
1175 const char tmp[] = "location: ";
1176
1177 field = idmef_node_get_location(ptr);
1178
1179 if ( field ) {
1180 print_indent(fd);
1181 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1182 print_string(field, fd);
1183 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1184 }
1185 }
1186
1187 {
1188 prelude_string_t *field;
1189 const char tmp[] = "name: ";
1190
1191 field = idmef_node_get_name(ptr);
1192
1193 if ( field ) {
1194 print_indent(fd);
1195 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1196 print_string(field, fd);
1197 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1198 }
1199 }
1200
1201 {
1202 char buf[128];
1203 idmef_address_t *elem = NULL;
1204 int cnt = 0, len;
1205
1206 while ( (elem = idmef_node_get_next_address(ptr, elem)) ) {
1207 print_indent(fd);
1208
1209 len = snprintf(buf, sizeof(buf), "address(%d): \n", cnt);
1210 prelude_io_write(fd, buf, len);
1211 idmef_address_print(elem, fd);
1212
1213 cnt++;
1214 }
1215 }
1216
1217 indent -= 8;
1218 }
1219
1220 /**
1221 * idmef_source_print:
1222 * @ptr: Pointer to an idmef_source_t object.
1223 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
1224 *
1225 * This function will convert @ptr to a string suitable for writing,
1226 * and write it to the provided @fd descriptor.
1227 */
idmef_source_print(idmef_source_t * ptr,prelude_io_t * fd)1228 void idmef_source_print(idmef_source_t *ptr, prelude_io_t *fd)
1229 {
1230 if ( ! ptr )
1231 return;
1232
1233 indent += 8;
1234
1235 {
1236 prelude_string_t *field;
1237 const char tmp[] = "ident: ";
1238
1239 field = idmef_source_get_ident(ptr);
1240
1241 if ( field ) {
1242 print_indent(fd);
1243 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1244 print_string(field, fd);
1245 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1246 }
1247 }
1248
1249 {
1250 int i = idmef_source_get_spoofed(ptr);
1251
1252
1253
1254 {
1255 print_indent(fd);
1256 prelude_io_write(fd, "spoofed: ", sizeof("spoofed: ") - 1);
1257 print_enum(idmef_source_spoofed_to_string(i), i, fd);
1258 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1259 }
1260 }
1261
1262 {
1263 prelude_string_t *field;
1264 const char tmp[] = "interface: ";
1265
1266 field = idmef_source_get_interface(ptr);
1267
1268 if ( field ) {
1269 print_indent(fd);
1270 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1271 print_string(field, fd);
1272 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1273 }
1274 }
1275
1276 {
1277 idmef_node_t *field;
1278
1279 field = idmef_source_get_node(ptr);
1280
1281 if ( field ) {
1282 print_indent(fd);
1283 prelude_io_write(fd, "node:\n", sizeof("node:\n") - 1);
1284 idmef_node_print(field, fd);
1285 }
1286 }
1287
1288 {
1289 idmef_user_t *field;
1290
1291 field = idmef_source_get_user(ptr);
1292
1293 if ( field ) {
1294 print_indent(fd);
1295 prelude_io_write(fd, "user:\n", sizeof("user:\n") - 1);
1296 idmef_user_print(field, fd);
1297 }
1298 }
1299
1300 {
1301 idmef_process_t *field;
1302
1303 field = idmef_source_get_process(ptr);
1304
1305 if ( field ) {
1306 print_indent(fd);
1307 prelude_io_write(fd, "process:\n", sizeof("process:\n") - 1);
1308 idmef_process_print(field, fd);
1309 }
1310 }
1311
1312 {
1313 idmef_service_t *field;
1314
1315 field = idmef_source_get_service(ptr);
1316
1317 if ( field ) {
1318 print_indent(fd);
1319 prelude_io_write(fd, "service:\n", sizeof("service:\n") - 1);
1320 idmef_service_print(field, fd);
1321 }
1322 }
1323
1324 indent -= 8;
1325 }
1326
1327 /**
1328 * idmef_file_access_print:
1329 * @ptr: Pointer to an idmef_file_access_t object.
1330 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
1331 *
1332 * This function will convert @ptr to a string suitable for writing,
1333 * and write it to the provided @fd descriptor.
1334 */
idmef_file_access_print(idmef_file_access_t * ptr,prelude_io_t * fd)1335 void idmef_file_access_print(idmef_file_access_t *ptr, prelude_io_t *fd)
1336 {
1337 if ( ! ptr )
1338 return;
1339
1340 indent += 8;
1341
1342 {
1343 idmef_user_id_t *field;
1344
1345 field = idmef_file_access_get_user_id(ptr);
1346
1347 if ( field ) {
1348 print_indent(fd);
1349 prelude_io_write(fd, "user_id:\n", sizeof("user_id:\n") - 1);
1350 idmef_user_id_print(field, fd);
1351 }
1352 }
1353
1354 {
1355 char buf[128];
1356 prelude_string_t *elem = NULL;
1357 int cnt = 0, len;
1358
1359 while ( (elem = idmef_file_access_get_next_permission(ptr, elem)) ) {
1360 print_indent(fd);
1361
1362 len = snprintf(buf, sizeof(buf), "permission(%d): ", cnt);
1363 prelude_io_write(fd, buf, len);
1364 print_string(elem, fd);
1365 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1366
1367 cnt++;
1368 }
1369 }
1370
1371 indent -= 8;
1372 }
1373
1374 /**
1375 * idmef_inode_print:
1376 * @ptr: Pointer to an idmef_inode_t object.
1377 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
1378 *
1379 * This function will convert @ptr to a string suitable for writing,
1380 * and write it to the provided @fd descriptor.
1381 */
idmef_inode_print(idmef_inode_t * ptr,prelude_io_t * fd)1382 void idmef_inode_print(idmef_inode_t *ptr, prelude_io_t *fd)
1383 {
1384 if ( ! ptr )
1385 return;
1386
1387 indent += 8;
1388
1389 {
1390 idmef_time_t *field;
1391 const char tmp[] = "change_time: ";
1392
1393 field = idmef_inode_get_change_time(ptr);
1394
1395 if ( field ) {
1396 print_indent(fd);
1397 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1398 print_time(field, fd);
1399 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1400 }
1401 }
1402
1403 {
1404 uint32_t *field;
1405 const char tmp[] = "number: ";
1406
1407 field = idmef_inode_get_number(ptr);
1408
1409 if ( field ) {
1410 print_indent(fd);
1411 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1412 print_uint32(*field, fd);
1413 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1414 }
1415 }
1416
1417 {
1418 uint32_t *field;
1419 const char tmp[] = "major_device: ";
1420
1421 field = idmef_inode_get_major_device(ptr);
1422
1423 if ( field ) {
1424 print_indent(fd);
1425 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1426 print_uint32(*field, fd);
1427 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1428 }
1429 }
1430
1431 {
1432 uint32_t *field;
1433 const char tmp[] = "minor_device: ";
1434
1435 field = idmef_inode_get_minor_device(ptr);
1436
1437 if ( field ) {
1438 print_indent(fd);
1439 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1440 print_uint32(*field, fd);
1441 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1442 }
1443 }
1444
1445 {
1446 uint32_t *field;
1447 const char tmp[] = "c_major_device: ";
1448
1449 field = idmef_inode_get_c_major_device(ptr);
1450
1451 if ( field ) {
1452 print_indent(fd);
1453 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1454 print_uint32(*field, fd);
1455 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1456 }
1457 }
1458
1459 {
1460 uint32_t *field;
1461 const char tmp[] = "c_minor_device: ";
1462
1463 field = idmef_inode_get_c_minor_device(ptr);
1464
1465 if ( field ) {
1466 print_indent(fd);
1467 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1468 print_uint32(*field, fd);
1469 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1470 }
1471 }
1472
1473 indent -= 8;
1474 }
1475
1476 /**
1477 * idmef_checksum_print:
1478 * @ptr: Pointer to an idmef_checksum_t object.
1479 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
1480 *
1481 * This function will convert @ptr to a string suitable for writing,
1482 * and write it to the provided @fd descriptor.
1483 */
idmef_checksum_print(idmef_checksum_t * ptr,prelude_io_t * fd)1484 void idmef_checksum_print(idmef_checksum_t *ptr, prelude_io_t *fd)
1485 {
1486 if ( ! ptr )
1487 return;
1488
1489 indent += 8;
1490
1491 {
1492 prelude_string_t *field;
1493 const char tmp[] = "value: ";
1494
1495 field = idmef_checksum_get_value(ptr);
1496
1497 if ( field ) {
1498 print_indent(fd);
1499 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1500 print_string(field, fd);
1501 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1502 }
1503 }
1504
1505 {
1506 prelude_string_t *field;
1507 const char tmp[] = "key: ";
1508
1509 field = idmef_checksum_get_key(ptr);
1510
1511 if ( field ) {
1512 print_indent(fd);
1513 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1514 print_string(field, fd);
1515 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1516 }
1517 }
1518
1519 {
1520 int i = idmef_checksum_get_algorithm(ptr);
1521
1522
1523
1524 {
1525 print_indent(fd);
1526 prelude_io_write(fd, "algorithm: ", sizeof("algorithm: ") - 1);
1527 print_enum(idmef_checksum_algorithm_to_string(i), i, fd);
1528 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1529 }
1530 }
1531
1532 indent -= 8;
1533 }
1534
1535 /**
1536 * idmef_file_print:
1537 * @ptr: Pointer to an idmef_file_t object.
1538 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
1539 *
1540 * This function will convert @ptr to a string suitable for writing,
1541 * and write it to the provided @fd descriptor.
1542 */
idmef_file_print(idmef_file_t * ptr,prelude_io_t * fd)1543 void idmef_file_print(idmef_file_t *ptr, prelude_io_t *fd)
1544 {
1545 if ( ! ptr )
1546 return;
1547
1548 indent += 8;
1549
1550 {
1551 prelude_string_t *field;
1552 const char tmp[] = "ident: ";
1553
1554 field = idmef_file_get_ident(ptr);
1555
1556 if ( field ) {
1557 print_indent(fd);
1558 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1559 print_string(field, fd);
1560 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1561 }
1562 }
1563
1564 {
1565 prelude_string_t *field;
1566 const char tmp[] = "name: ";
1567
1568 field = idmef_file_get_name(ptr);
1569
1570 if ( field ) {
1571 print_indent(fd);
1572 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1573 print_string(field, fd);
1574 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1575 }
1576 }
1577
1578 {
1579 prelude_string_t *field;
1580 const char tmp[] = "path: ";
1581
1582 field = idmef_file_get_path(ptr);
1583
1584 if ( field ) {
1585 print_indent(fd);
1586 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1587 print_string(field, fd);
1588 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1589 }
1590 }
1591
1592 {
1593 idmef_time_t *field;
1594 const char tmp[] = "create_time: ";
1595
1596 field = idmef_file_get_create_time(ptr);
1597
1598 if ( field ) {
1599 print_indent(fd);
1600 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1601 print_time(field, fd);
1602 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1603 }
1604 }
1605
1606 {
1607 idmef_time_t *field;
1608 const char tmp[] = "modify_time: ";
1609
1610 field = idmef_file_get_modify_time(ptr);
1611
1612 if ( field ) {
1613 print_indent(fd);
1614 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1615 print_time(field, fd);
1616 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1617 }
1618 }
1619
1620 {
1621 idmef_time_t *field;
1622 const char tmp[] = "access_time: ";
1623
1624 field = idmef_file_get_access_time(ptr);
1625
1626 if ( field ) {
1627 print_indent(fd);
1628 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1629 print_time(field, fd);
1630 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1631 }
1632 }
1633
1634 {
1635 uint64_t *field;
1636 const char tmp[] = "data_size: ";
1637
1638 field = idmef_file_get_data_size(ptr);
1639
1640 if ( field ) {
1641 print_indent(fd);
1642 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1643 print_uint64(*field, fd);
1644 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1645 }
1646 }
1647
1648 {
1649 uint64_t *field;
1650 const char tmp[] = "disk_size: ";
1651
1652 field = idmef_file_get_disk_size(ptr);
1653
1654 if ( field ) {
1655 print_indent(fd);
1656 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1657 print_uint64(*field, fd);
1658 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1659 }
1660 }
1661
1662 {
1663 char buf[128];
1664 idmef_file_access_t *elem = NULL;
1665 int cnt = 0, len;
1666
1667 while ( (elem = idmef_file_get_next_file_access(ptr, elem)) ) {
1668 print_indent(fd);
1669
1670 len = snprintf(buf, sizeof(buf), "file_access(%d): \n", cnt);
1671 prelude_io_write(fd, buf, len);
1672 idmef_file_access_print(elem, fd);
1673
1674 cnt++;
1675 }
1676 }
1677
1678 {
1679 char buf[128];
1680 idmef_linkage_t *elem = NULL;
1681 int cnt = 0, len;
1682
1683 while ( (elem = idmef_file_get_next_linkage(ptr, elem)) ) {
1684 print_indent(fd);
1685
1686 len = snprintf(buf, sizeof(buf), "linkage(%d): \n", cnt);
1687 prelude_io_write(fd, buf, len);
1688 idmef_linkage_print(elem, fd);
1689
1690 cnt++;
1691 }
1692 }
1693
1694 {
1695 idmef_inode_t *field;
1696
1697 field = idmef_file_get_inode(ptr);
1698
1699 if ( field ) {
1700 print_indent(fd);
1701 prelude_io_write(fd, "inode:\n", sizeof("inode:\n") - 1);
1702 idmef_inode_print(field, fd);
1703 }
1704 }
1705
1706 {
1707 char buf[128];
1708 idmef_checksum_t *elem = NULL;
1709 int cnt = 0, len;
1710
1711 while ( (elem = idmef_file_get_next_checksum(ptr, elem)) ) {
1712 print_indent(fd);
1713
1714 len = snprintf(buf, sizeof(buf), "checksum(%d): \n", cnt);
1715 prelude_io_write(fd, buf, len);
1716 idmef_checksum_print(elem, fd);
1717
1718 cnt++;
1719 }
1720 }
1721
1722 {
1723 int i = idmef_file_get_category(ptr);
1724
1725
1726
1727 {
1728 print_indent(fd);
1729 prelude_io_write(fd, "category: ", sizeof("category: ") - 1);
1730 print_enum(idmef_file_category_to_string(i), i, fd);
1731 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1732 }
1733 }
1734
1735 {
1736 int *i = idmef_file_get_fstype(ptr);
1737
1738
1739 if ( i )
1740
1741
1742 {
1743 print_indent(fd);
1744 prelude_io_write(fd, "fstype: ", sizeof("fstype: ") - 1);
1745 print_enum(idmef_file_fstype_to_string(*i), *i, fd);
1746 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1747 }
1748 }
1749
1750 {
1751 prelude_string_t *field;
1752 const char tmp[] = "file_type: ";
1753
1754 field = idmef_file_get_file_type(ptr);
1755
1756 if ( field ) {
1757 print_indent(fd);
1758 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1759 print_string(field, fd);
1760 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1761 }
1762 }
1763
1764 indent -= 8;
1765 }
1766
1767 /**
1768 * idmef_linkage_print:
1769 * @ptr: Pointer to an idmef_linkage_t object.
1770 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
1771 *
1772 * This function will convert @ptr to a string suitable for writing,
1773 * and write it to the provided @fd descriptor.
1774 */
idmef_linkage_print(idmef_linkage_t * ptr,prelude_io_t * fd)1775 void idmef_linkage_print(idmef_linkage_t *ptr, prelude_io_t *fd)
1776 {
1777 if ( ! ptr )
1778 return;
1779
1780 indent += 8;
1781
1782 {
1783 int i = idmef_linkage_get_category(ptr);
1784
1785
1786
1787 {
1788 print_indent(fd);
1789 prelude_io_write(fd, "category: ", sizeof("category: ") - 1);
1790 print_enum(idmef_linkage_category_to_string(i), i, fd);
1791 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1792 }
1793 }
1794
1795 {
1796 prelude_string_t *field;
1797 const char tmp[] = "name: ";
1798
1799 field = idmef_linkage_get_name(ptr);
1800
1801 if ( field ) {
1802 print_indent(fd);
1803 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1804 print_string(field, fd);
1805 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1806 }
1807 }
1808
1809 {
1810 prelude_string_t *field;
1811 const char tmp[] = "path: ";
1812
1813 field = idmef_linkage_get_path(ptr);
1814
1815 if ( field ) {
1816 print_indent(fd);
1817 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1818 print_string(field, fd);
1819 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1820 }
1821 }
1822
1823 {
1824 idmef_file_t *field;
1825
1826 field = idmef_linkage_get_file(ptr);
1827
1828 if ( field ) {
1829 print_indent(fd);
1830 prelude_io_write(fd, "file:\n", sizeof("file:\n") - 1);
1831 idmef_file_print(field, fd);
1832 }
1833 }
1834
1835 indent -= 8;
1836 }
1837
1838 /**
1839 * idmef_target_print:
1840 * @ptr: Pointer to an idmef_target_t object.
1841 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
1842 *
1843 * This function will convert @ptr to a string suitable for writing,
1844 * and write it to the provided @fd descriptor.
1845 */
idmef_target_print(idmef_target_t * ptr,prelude_io_t * fd)1846 void idmef_target_print(idmef_target_t *ptr, prelude_io_t *fd)
1847 {
1848 if ( ! ptr )
1849 return;
1850
1851 indent += 8;
1852
1853 {
1854 prelude_string_t *field;
1855 const char tmp[] = "ident: ";
1856
1857 field = idmef_target_get_ident(ptr);
1858
1859 if ( field ) {
1860 print_indent(fd);
1861 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1862 print_string(field, fd);
1863 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1864 }
1865 }
1866
1867 {
1868 int i = idmef_target_get_decoy(ptr);
1869
1870
1871
1872 {
1873 print_indent(fd);
1874 prelude_io_write(fd, "decoy: ", sizeof("decoy: ") - 1);
1875 print_enum(idmef_target_decoy_to_string(i), i, fd);
1876 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1877 }
1878 }
1879
1880 {
1881 prelude_string_t *field;
1882 const char tmp[] = "interface: ";
1883
1884 field = idmef_target_get_interface(ptr);
1885
1886 if ( field ) {
1887 print_indent(fd);
1888 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1889 print_string(field, fd);
1890 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1891 }
1892 }
1893
1894 {
1895 idmef_node_t *field;
1896
1897 field = idmef_target_get_node(ptr);
1898
1899 if ( field ) {
1900 print_indent(fd);
1901 prelude_io_write(fd, "node:\n", sizeof("node:\n") - 1);
1902 idmef_node_print(field, fd);
1903 }
1904 }
1905
1906 {
1907 idmef_user_t *field;
1908
1909 field = idmef_target_get_user(ptr);
1910
1911 if ( field ) {
1912 print_indent(fd);
1913 prelude_io_write(fd, "user:\n", sizeof("user:\n") - 1);
1914 idmef_user_print(field, fd);
1915 }
1916 }
1917
1918 {
1919 idmef_process_t *field;
1920
1921 field = idmef_target_get_process(ptr);
1922
1923 if ( field ) {
1924 print_indent(fd);
1925 prelude_io_write(fd, "process:\n", sizeof("process:\n") - 1);
1926 idmef_process_print(field, fd);
1927 }
1928 }
1929
1930 {
1931 idmef_service_t *field;
1932
1933 field = idmef_target_get_service(ptr);
1934
1935 if ( field ) {
1936 print_indent(fd);
1937 prelude_io_write(fd, "service:\n", sizeof("service:\n") - 1);
1938 idmef_service_print(field, fd);
1939 }
1940 }
1941
1942 {
1943 char buf[128];
1944 idmef_file_t *elem = NULL;
1945 int cnt = 0, len;
1946
1947 while ( (elem = idmef_target_get_next_file(ptr, elem)) ) {
1948 print_indent(fd);
1949
1950 len = snprintf(buf, sizeof(buf), "file(%d): \n", cnt);
1951 prelude_io_write(fd, buf, len);
1952 idmef_file_print(elem, fd);
1953
1954 cnt++;
1955 }
1956 }
1957
1958 indent -= 8;
1959 }
1960
1961 /**
1962 * idmef_analyzer_print:
1963 * @ptr: Pointer to an idmef_analyzer_t object.
1964 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
1965 *
1966 * This function will convert @ptr to a string suitable for writing,
1967 * and write it to the provided @fd descriptor.
1968 */
idmef_analyzer_print(idmef_analyzer_t * ptr,prelude_io_t * fd)1969 void idmef_analyzer_print(idmef_analyzer_t *ptr, prelude_io_t *fd)
1970 {
1971 if ( ! ptr )
1972 return;
1973
1974 indent += 8;
1975
1976 {
1977 prelude_string_t *field;
1978 const char tmp[] = "analyzerid: ";
1979
1980 field = idmef_analyzer_get_analyzerid(ptr);
1981
1982 if ( field ) {
1983 print_indent(fd);
1984 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1985 print_string(field, fd);
1986 prelude_io_write(fd, "\n", sizeof("\n") - 1);
1987 }
1988 }
1989
1990 {
1991 prelude_string_t *field;
1992 const char tmp[] = "name: ";
1993
1994 field = idmef_analyzer_get_name(ptr);
1995
1996 if ( field ) {
1997 print_indent(fd);
1998 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
1999 print_string(field, fd);
2000 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2001 }
2002 }
2003
2004 {
2005 prelude_string_t *field;
2006 const char tmp[] = "manufacturer: ";
2007
2008 field = idmef_analyzer_get_manufacturer(ptr);
2009
2010 if ( field ) {
2011 print_indent(fd);
2012 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
2013 print_string(field, fd);
2014 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2015 }
2016 }
2017
2018 {
2019 prelude_string_t *field;
2020 const char tmp[] = "model: ";
2021
2022 field = idmef_analyzer_get_model(ptr);
2023
2024 if ( field ) {
2025 print_indent(fd);
2026 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
2027 print_string(field, fd);
2028 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2029 }
2030 }
2031
2032 {
2033 prelude_string_t *field;
2034 const char tmp[] = "version: ";
2035
2036 field = idmef_analyzer_get_version(ptr);
2037
2038 if ( field ) {
2039 print_indent(fd);
2040 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
2041 print_string(field, fd);
2042 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2043 }
2044 }
2045
2046 {
2047 prelude_string_t *field;
2048 const char tmp[] = "class: ";
2049
2050 field = idmef_analyzer_get_class(ptr);
2051
2052 if ( field ) {
2053 print_indent(fd);
2054 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
2055 print_string(field, fd);
2056 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2057 }
2058 }
2059
2060 {
2061 prelude_string_t *field;
2062 const char tmp[] = "ostype: ";
2063
2064 field = idmef_analyzer_get_ostype(ptr);
2065
2066 if ( field ) {
2067 print_indent(fd);
2068 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
2069 print_string(field, fd);
2070 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2071 }
2072 }
2073
2074 {
2075 prelude_string_t *field;
2076 const char tmp[] = "osversion: ";
2077
2078 field = idmef_analyzer_get_osversion(ptr);
2079
2080 if ( field ) {
2081 print_indent(fd);
2082 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
2083 print_string(field, fd);
2084 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2085 }
2086 }
2087
2088 {
2089 idmef_node_t *field;
2090
2091 field = idmef_analyzer_get_node(ptr);
2092
2093 if ( field ) {
2094 print_indent(fd);
2095 prelude_io_write(fd, "node:\n", sizeof("node:\n") - 1);
2096 idmef_node_print(field, fd);
2097 }
2098 }
2099
2100 {
2101 idmef_process_t *field;
2102
2103 field = idmef_analyzer_get_process(ptr);
2104
2105 if ( field ) {
2106 print_indent(fd);
2107 prelude_io_write(fd, "process:\n", sizeof("process:\n") - 1);
2108 idmef_process_print(field, fd);
2109 }
2110 }
2111
2112 indent -= 8;
2113 }
2114
2115 /**
2116 * idmef_alertident_print:
2117 * @ptr: Pointer to an idmef_alertident_t object.
2118 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
2119 *
2120 * This function will convert @ptr to a string suitable for writing,
2121 * and write it to the provided @fd descriptor.
2122 */
idmef_alertident_print(idmef_alertident_t * ptr,prelude_io_t * fd)2123 void idmef_alertident_print(idmef_alertident_t *ptr, prelude_io_t *fd)
2124 {
2125 if ( ! ptr )
2126 return;
2127
2128 indent += 8;
2129
2130 {
2131 prelude_string_t *field;
2132 const char tmp[] = "alertident: ";
2133
2134 field = idmef_alertident_get_alertident(ptr);
2135
2136 if ( field ) {
2137 print_indent(fd);
2138 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
2139 print_string(field, fd);
2140 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2141 }
2142 }
2143
2144 {
2145 prelude_string_t *field;
2146 const char tmp[] = "analyzerid: ";
2147
2148 field = idmef_alertident_get_analyzerid(ptr);
2149
2150 if ( field ) {
2151 print_indent(fd);
2152 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
2153 print_string(field, fd);
2154 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2155 }
2156 }
2157
2158 indent -= 8;
2159 }
2160
2161 /**
2162 * idmef_impact_print:
2163 * @ptr: Pointer to an idmef_impact_t object.
2164 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
2165 *
2166 * This function will convert @ptr to a string suitable for writing,
2167 * and write it to the provided @fd descriptor.
2168 */
idmef_impact_print(idmef_impact_t * ptr,prelude_io_t * fd)2169 void idmef_impact_print(idmef_impact_t *ptr, prelude_io_t *fd)
2170 {
2171 if ( ! ptr )
2172 return;
2173
2174 indent += 8;
2175
2176 {
2177 int *i = idmef_impact_get_severity(ptr);
2178
2179
2180 if ( i )
2181
2182
2183 {
2184 print_indent(fd);
2185 prelude_io_write(fd, "severity: ", sizeof("severity: ") - 1);
2186 print_enum(idmef_impact_severity_to_string(*i), *i, fd);
2187 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2188 }
2189 }
2190
2191 {
2192 int *i = idmef_impact_get_completion(ptr);
2193
2194
2195 if ( i )
2196
2197
2198 {
2199 print_indent(fd);
2200 prelude_io_write(fd, "completion: ", sizeof("completion: ") - 1);
2201 print_enum(idmef_impact_completion_to_string(*i), *i, fd);
2202 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2203 }
2204 }
2205
2206 {
2207 int i = idmef_impact_get_type(ptr);
2208
2209
2210
2211 {
2212 print_indent(fd);
2213 prelude_io_write(fd, "type: ", sizeof("type: ") - 1);
2214 print_enum(idmef_impact_type_to_string(i), i, fd);
2215 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2216 }
2217 }
2218
2219 {
2220 prelude_string_t *field;
2221 const char tmp[] = "description: ";
2222
2223 field = idmef_impact_get_description(ptr);
2224
2225 if ( field ) {
2226 print_indent(fd);
2227 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
2228 print_string(field, fd);
2229 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2230 }
2231 }
2232
2233 indent -= 8;
2234 }
2235
2236 /**
2237 * idmef_action_print:
2238 * @ptr: Pointer to an idmef_action_t object.
2239 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
2240 *
2241 * This function will convert @ptr to a string suitable for writing,
2242 * and write it to the provided @fd descriptor.
2243 */
idmef_action_print(idmef_action_t * ptr,prelude_io_t * fd)2244 void idmef_action_print(idmef_action_t *ptr, prelude_io_t *fd)
2245 {
2246 if ( ! ptr )
2247 return;
2248
2249 indent += 8;
2250
2251 {
2252 int i = idmef_action_get_category(ptr);
2253
2254
2255
2256 {
2257 print_indent(fd);
2258 prelude_io_write(fd, "category: ", sizeof("category: ") - 1);
2259 print_enum(idmef_action_category_to_string(i), i, fd);
2260 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2261 }
2262 }
2263
2264 {
2265 prelude_string_t *field;
2266 const char tmp[] = "description: ";
2267
2268 field = idmef_action_get_description(ptr);
2269
2270 if ( field ) {
2271 print_indent(fd);
2272 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
2273 print_string(field, fd);
2274 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2275 }
2276 }
2277
2278 indent -= 8;
2279 }
2280
2281 /**
2282 * idmef_confidence_print:
2283 * @ptr: Pointer to an idmef_confidence_t object.
2284 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
2285 *
2286 * This function will convert @ptr to a string suitable for writing,
2287 * and write it to the provided @fd descriptor.
2288 */
idmef_confidence_print(idmef_confidence_t * ptr,prelude_io_t * fd)2289 void idmef_confidence_print(idmef_confidence_t *ptr, prelude_io_t *fd)
2290 {
2291 if ( ! ptr )
2292 return;
2293
2294 indent += 8;
2295
2296 {
2297 int i = idmef_confidence_get_rating(ptr);
2298
2299
2300
2301 {
2302 print_indent(fd);
2303 prelude_io_write(fd, "rating: ", sizeof("rating: ") - 1);
2304 print_enum(idmef_confidence_rating_to_string(i), i, fd);
2305 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2306 }
2307 }
2308
2309 print_indent(fd);
2310 prelude_io_write(fd, "confidence: ", sizeof("confidence: ") - 1);
2311 print_float(idmef_confidence_get_confidence(ptr), fd);
2312 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2313
2314 indent -= 8;
2315 }
2316
2317 /**
2318 * idmef_assessment_print:
2319 * @ptr: Pointer to an idmef_assessment_t object.
2320 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
2321 *
2322 * This function will convert @ptr to a string suitable for writing,
2323 * and write it to the provided @fd descriptor.
2324 */
idmef_assessment_print(idmef_assessment_t * ptr,prelude_io_t * fd)2325 void idmef_assessment_print(idmef_assessment_t *ptr, prelude_io_t *fd)
2326 {
2327 if ( ! ptr )
2328 return;
2329
2330 indent += 8;
2331
2332 {
2333 idmef_impact_t *field;
2334
2335 field = idmef_assessment_get_impact(ptr);
2336
2337 if ( field ) {
2338 print_indent(fd);
2339 prelude_io_write(fd, "impact:\n", sizeof("impact:\n") - 1);
2340 idmef_impact_print(field, fd);
2341 }
2342 }
2343
2344 {
2345 char buf[128];
2346 idmef_action_t *elem = NULL;
2347 int cnt = 0, len;
2348
2349 while ( (elem = idmef_assessment_get_next_action(ptr, elem)) ) {
2350 print_indent(fd);
2351
2352 len = snprintf(buf, sizeof(buf), "action(%d): \n", cnt);
2353 prelude_io_write(fd, buf, len);
2354 idmef_action_print(elem, fd);
2355
2356 cnt++;
2357 }
2358 }
2359
2360 {
2361 idmef_confidence_t *field;
2362
2363 field = idmef_assessment_get_confidence(ptr);
2364
2365 if ( field ) {
2366 print_indent(fd);
2367 prelude_io_write(fd, "confidence:\n", sizeof("confidence:\n") - 1);
2368 idmef_confidence_print(field, fd);
2369 }
2370 }
2371
2372 indent -= 8;
2373 }
2374
2375 /**
2376 * idmef_tool_alert_print:
2377 * @ptr: Pointer to an idmef_tool_alert_t object.
2378 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
2379 *
2380 * This function will convert @ptr to a string suitable for writing,
2381 * and write it to the provided @fd descriptor.
2382 */
idmef_tool_alert_print(idmef_tool_alert_t * ptr,prelude_io_t * fd)2383 void idmef_tool_alert_print(idmef_tool_alert_t *ptr, prelude_io_t *fd)
2384 {
2385 if ( ! ptr )
2386 return;
2387
2388 indent += 8;
2389
2390 {
2391 prelude_string_t *field;
2392 const char tmp[] = "name: ";
2393
2394 field = idmef_tool_alert_get_name(ptr);
2395
2396 if ( field ) {
2397 print_indent(fd);
2398 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
2399 print_string(field, fd);
2400 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2401 }
2402 }
2403
2404 {
2405 prelude_string_t *field;
2406 const char tmp[] = "command: ";
2407
2408 field = idmef_tool_alert_get_command(ptr);
2409
2410 if ( field ) {
2411 print_indent(fd);
2412 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
2413 print_string(field, fd);
2414 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2415 }
2416 }
2417
2418 {
2419 char buf[128];
2420 idmef_alertident_t *elem = NULL;
2421 int cnt = 0, len;
2422
2423 while ( (elem = idmef_tool_alert_get_next_alertident(ptr, elem)) ) {
2424 print_indent(fd);
2425
2426 len = snprintf(buf, sizeof(buf), "alertident(%d): \n", cnt);
2427 prelude_io_write(fd, buf, len);
2428 idmef_alertident_print(elem, fd);
2429
2430 cnt++;
2431 }
2432 }
2433
2434 indent -= 8;
2435 }
2436
2437 /**
2438 * idmef_correlation_alert_print:
2439 * @ptr: Pointer to an idmef_correlation_alert_t object.
2440 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
2441 *
2442 * This function will convert @ptr to a string suitable for writing,
2443 * and write it to the provided @fd descriptor.
2444 */
idmef_correlation_alert_print(idmef_correlation_alert_t * ptr,prelude_io_t * fd)2445 void idmef_correlation_alert_print(idmef_correlation_alert_t *ptr, prelude_io_t *fd)
2446 {
2447 if ( ! ptr )
2448 return;
2449
2450 indent += 8;
2451
2452 {
2453 prelude_string_t *field;
2454 const char tmp[] = "name: ";
2455
2456 field = idmef_correlation_alert_get_name(ptr);
2457
2458 if ( field ) {
2459 print_indent(fd);
2460 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
2461 print_string(field, fd);
2462 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2463 }
2464 }
2465
2466 {
2467 char buf[128];
2468 idmef_alertident_t *elem = NULL;
2469 int cnt = 0, len;
2470
2471 while ( (elem = idmef_correlation_alert_get_next_alertident(ptr, elem)) ) {
2472 print_indent(fd);
2473
2474 len = snprintf(buf, sizeof(buf), "alertident(%d): \n", cnt);
2475 prelude_io_write(fd, buf, len);
2476 idmef_alertident_print(elem, fd);
2477
2478 cnt++;
2479 }
2480 }
2481
2482 indent -= 8;
2483 }
2484
2485 /**
2486 * idmef_overflow_alert_print:
2487 * @ptr: Pointer to an idmef_overflow_alert_t object.
2488 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
2489 *
2490 * This function will convert @ptr to a string suitable for writing,
2491 * and write it to the provided @fd descriptor.
2492 */
idmef_overflow_alert_print(idmef_overflow_alert_t * ptr,prelude_io_t * fd)2493 void idmef_overflow_alert_print(idmef_overflow_alert_t *ptr, prelude_io_t *fd)
2494 {
2495 if ( ! ptr )
2496 return;
2497
2498 indent += 8;
2499
2500 {
2501 prelude_string_t *field;
2502 const char tmp[] = "program: ";
2503
2504 field = idmef_overflow_alert_get_program(ptr);
2505
2506 if ( field ) {
2507 print_indent(fd);
2508 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
2509 print_string(field, fd);
2510 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2511 }
2512 }
2513
2514 {
2515 uint32_t *field;
2516 const char tmp[] = "size: ";
2517
2518 field = idmef_overflow_alert_get_size(ptr);
2519
2520 if ( field ) {
2521 print_indent(fd);
2522 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
2523 print_uint32(*field, fd);
2524 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2525 }
2526 }
2527
2528 {
2529 idmef_data_t *field;
2530 const char tmp[] = "buffer: ";
2531
2532 field = idmef_overflow_alert_get_buffer(ptr);
2533
2534 if ( field ) {
2535 print_indent(fd);
2536 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
2537 print_data(field, fd);
2538 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2539 }
2540 }
2541
2542 indent -= 8;
2543 }
2544
2545 /**
2546 * idmef_alert_print:
2547 * @ptr: Pointer to an idmef_alert_t object.
2548 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
2549 *
2550 * This function will convert @ptr to a string suitable for writing,
2551 * and write it to the provided @fd descriptor.
2552 */
idmef_alert_print(idmef_alert_t * ptr,prelude_io_t * fd)2553 void idmef_alert_print(idmef_alert_t *ptr, prelude_io_t *fd)
2554 {
2555 if ( ! ptr )
2556 return;
2557
2558 indent += 8;
2559
2560 {
2561 prelude_string_t *field;
2562 const char tmp[] = "messageid: ";
2563
2564 field = idmef_alert_get_messageid(ptr);
2565
2566 if ( field ) {
2567 print_indent(fd);
2568 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
2569 print_string(field, fd);
2570 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2571 }
2572 }
2573
2574 {
2575 char buf[128];
2576 idmef_analyzer_t *elem = NULL;
2577 int cnt = 0, len;
2578
2579 while ( (elem = idmef_alert_get_next_analyzer(ptr, elem)) ) {
2580 print_indent(fd);
2581
2582 len = snprintf(buf, sizeof(buf), "analyzer(%d): \n", cnt);
2583 prelude_io_write(fd, buf, len);
2584 idmef_analyzer_print(elem, fd);
2585
2586 cnt++;
2587 }
2588 }
2589
2590 {
2591 idmef_time_t *field;
2592 const char tmp[] = "create_time: ";
2593
2594 field = idmef_alert_get_create_time(ptr);
2595
2596 if ( field ) {
2597 print_indent(fd);
2598 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
2599 print_time(field, fd);
2600 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2601 }
2602 }
2603
2604 {
2605 idmef_classification_t *field;
2606
2607 field = idmef_alert_get_classification(ptr);
2608
2609 if ( field ) {
2610 print_indent(fd);
2611 prelude_io_write(fd, "classification:\n", sizeof("classification:\n") - 1);
2612 idmef_classification_print(field, fd);
2613 }
2614 }
2615
2616 {
2617 idmef_time_t *field;
2618 const char tmp[] = "detect_time: ";
2619
2620 field = idmef_alert_get_detect_time(ptr);
2621
2622 if ( field ) {
2623 print_indent(fd);
2624 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
2625 print_time(field, fd);
2626 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2627 }
2628 }
2629
2630 {
2631 idmef_time_t *field;
2632 const char tmp[] = "analyzer_time: ";
2633
2634 field = idmef_alert_get_analyzer_time(ptr);
2635
2636 if ( field ) {
2637 print_indent(fd);
2638 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
2639 print_time(field, fd);
2640 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2641 }
2642 }
2643
2644 {
2645 char buf[128];
2646 idmef_source_t *elem = NULL;
2647 int cnt = 0, len;
2648
2649 while ( (elem = idmef_alert_get_next_source(ptr, elem)) ) {
2650 print_indent(fd);
2651
2652 len = snprintf(buf, sizeof(buf), "source(%d): \n", cnt);
2653 prelude_io_write(fd, buf, len);
2654 idmef_source_print(elem, fd);
2655
2656 cnt++;
2657 }
2658 }
2659
2660 {
2661 char buf[128];
2662 idmef_target_t *elem = NULL;
2663 int cnt = 0, len;
2664
2665 while ( (elem = idmef_alert_get_next_target(ptr, elem)) ) {
2666 print_indent(fd);
2667
2668 len = snprintf(buf, sizeof(buf), "target(%d): \n", cnt);
2669 prelude_io_write(fd, buf, len);
2670 idmef_target_print(elem, fd);
2671
2672 cnt++;
2673 }
2674 }
2675
2676 {
2677 idmef_assessment_t *field;
2678
2679 field = idmef_alert_get_assessment(ptr);
2680
2681 if ( field ) {
2682 print_indent(fd);
2683 prelude_io_write(fd, "assessment:\n", sizeof("assessment:\n") - 1);
2684 idmef_assessment_print(field, fd);
2685 }
2686 }
2687
2688 {
2689 char buf[128];
2690 idmef_additional_data_t *elem = NULL;
2691 int cnt = 0, len;
2692
2693 while ( (elem = idmef_alert_get_next_additional_data(ptr, elem)) ) {
2694 print_indent(fd);
2695
2696 len = snprintf(buf, sizeof(buf), "additional_data(%d): \n", cnt);
2697 prelude_io_write(fd, buf, len);
2698 idmef_additional_data_print(elem, fd);
2699
2700 cnt++;
2701 }
2702 }
2703
2704 switch ( idmef_alert_get_type(ptr) ) {
2705 case IDMEF_ALERT_TYPE_TOOL:
2706 print_indent(fd);
2707 prelude_io_write(fd, "tool_alert:\n", sizeof("tool_alert:\n") - 1);
2708 idmef_tool_alert_print(idmef_alert_get_tool_alert(ptr), fd);
2709 break;
2710
2711 case IDMEF_ALERT_TYPE_CORRELATION:
2712 print_indent(fd);
2713 prelude_io_write(fd, "correlation_alert:\n", sizeof("correlation_alert:\n") - 1);
2714 idmef_correlation_alert_print(idmef_alert_get_correlation_alert(ptr), fd);
2715 break;
2716
2717 case IDMEF_ALERT_TYPE_OVERFLOW:
2718 print_indent(fd);
2719 prelude_io_write(fd, "overflow_alert:\n", sizeof("overflow_alert:\n") - 1);
2720 idmef_overflow_alert_print(idmef_alert_get_overflow_alert(ptr), fd);
2721 break;
2722
2723 default:
2724 break;
2725 }
2726
2727 indent -= 8;
2728 }
2729
2730 /**
2731 * idmef_heartbeat_print:
2732 * @ptr: Pointer to an idmef_heartbeat_t object.
2733 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
2734 *
2735 * This function will convert @ptr to a string suitable for writing,
2736 * and write it to the provided @fd descriptor.
2737 */
idmef_heartbeat_print(idmef_heartbeat_t * ptr,prelude_io_t * fd)2738 void idmef_heartbeat_print(idmef_heartbeat_t *ptr, prelude_io_t *fd)
2739 {
2740 if ( ! ptr )
2741 return;
2742
2743 indent += 8;
2744
2745 {
2746 prelude_string_t *field;
2747 const char tmp[] = "messageid: ";
2748
2749 field = idmef_heartbeat_get_messageid(ptr);
2750
2751 if ( field ) {
2752 print_indent(fd);
2753 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
2754 print_string(field, fd);
2755 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2756 }
2757 }
2758
2759 {
2760 char buf[128];
2761 idmef_analyzer_t *elem = NULL;
2762 int cnt = 0, len;
2763
2764 while ( (elem = idmef_heartbeat_get_next_analyzer(ptr, elem)) ) {
2765 print_indent(fd);
2766
2767 len = snprintf(buf, sizeof(buf), "analyzer(%d): \n", cnt);
2768 prelude_io_write(fd, buf, len);
2769 idmef_analyzer_print(elem, fd);
2770
2771 cnt++;
2772 }
2773 }
2774
2775 {
2776 idmef_time_t *field;
2777 const char tmp[] = "create_time: ";
2778
2779 field = idmef_heartbeat_get_create_time(ptr);
2780
2781 if ( field ) {
2782 print_indent(fd);
2783 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
2784 print_time(field, fd);
2785 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2786 }
2787 }
2788
2789 {
2790 idmef_time_t *field;
2791 const char tmp[] = "analyzer_time: ";
2792
2793 field = idmef_heartbeat_get_analyzer_time(ptr);
2794
2795 if ( field ) {
2796 print_indent(fd);
2797 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
2798 print_time(field, fd);
2799 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2800 }
2801 }
2802
2803 {
2804 uint32_t *field;
2805 const char tmp[] = "heartbeat_interval: ";
2806
2807 field = idmef_heartbeat_get_heartbeat_interval(ptr);
2808
2809 if ( field ) {
2810 print_indent(fd);
2811 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
2812 print_uint32(*field, fd);
2813 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2814 }
2815 }
2816
2817 {
2818 char buf[128];
2819 idmef_additional_data_t *elem = NULL;
2820 int cnt = 0, len;
2821
2822 while ( (elem = idmef_heartbeat_get_next_additional_data(ptr, elem)) ) {
2823 print_indent(fd);
2824
2825 len = snprintf(buf, sizeof(buf), "additional_data(%d): \n", cnt);
2826 prelude_io_write(fd, buf, len);
2827 idmef_additional_data_print(elem, fd);
2828
2829 cnt++;
2830 }
2831 }
2832
2833 indent -= 8;
2834 }
2835
2836 /**
2837 * idmef_message_print:
2838 * @ptr: Pointer to an idmef_message_t object.
2839 * @fd: Pointer to a #prelude_io_t object where to print @ptr to.
2840 *
2841 * This function will convert @ptr to a string suitable for writing,
2842 * and write it to the provided @fd descriptor.
2843 */
idmef_message_print(idmef_message_t * ptr,prelude_io_t * fd)2844 void idmef_message_print(idmef_message_t *ptr, prelude_io_t *fd)
2845 {
2846 if ( ! ptr )
2847 return;
2848
2849
2850 {
2851 prelude_string_t *field;
2852 const char tmp[] = "version: ";
2853
2854 field = idmef_message_get_version(ptr);
2855
2856 if ( field ) {
2857 print_indent(fd);
2858 prelude_io_write(fd, tmp, sizeof(tmp) - 1);
2859 print_string(field, fd);
2860 prelude_io_write(fd, "\n", sizeof("\n") - 1);
2861 }
2862 }
2863
2864 switch ( idmef_message_get_type(ptr) ) {
2865 case IDMEF_MESSAGE_TYPE_ALERT:
2866 print_indent(fd);
2867 prelude_io_write(fd, "alert:\n", sizeof("alert:\n") - 1);
2868 idmef_alert_print(idmef_message_get_alert(ptr), fd);
2869 break;
2870
2871 case IDMEF_MESSAGE_TYPE_HEARTBEAT:
2872 print_indent(fd);
2873 prelude_io_write(fd, "heartbeat:\n", sizeof("heartbeat:\n") - 1);
2874 idmef_heartbeat_print(idmef_message_get_heartbeat(ptr), fd);
2875 break;
2876
2877 default:
2878 break;
2879 }
2880 }
2881