-
Notifications
You must be signed in to change notification settings - Fork 0
/
msg.c
5206 lines (4775 loc) · 149 KB
/
msg.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* msg.c
* The msg object. Implementation of all msg-related functions
*
* File begun on 2007-07-13 by RGerhards (extracted from syslogd.c)
* This file is under development and has not yet arrived at being fully
* self-contained and a real object. So far, it is mostly an excerpt
* of the "old" message code without any modifications. However, it
* helps to have things at the right place one we go to the meat of it.
*
* Copyright 2007-2018 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
* The rsyslog runtime library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The rsyslog runtime library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with the rsyslog runtime library. If not, see <http://www.gnu.org/licenses/>.
*
* A copy of the GPL can be found in the file "COPYING" in this distribution.
* A copy of the LGPL can be found in the file "COPYING.LESSER" in this distribution.
*/
#include "config.h"
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#define SYSLOG_NAMES
#include <string.h>
#include <assert.h>
#include <ctype.h>
#include <sys/socket.h>
#ifdef HAVE_SYSINFO_UPTIME
#include <sys/sysinfo.h>
#endif
#include <netdb.h>
#include <libestr.h>
#include <json.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#ifdef USE_LIBUUID
#include <uuid/uuid.h>
#endif
#include <errno.h>
#include "rsyslog.h"
#include "srUtils.h"
#include "stringbuf.h"
#include "template.h"
#include "msg.h"
#include "datetime.h"
#include "glbl.h"
#include "regexp.h"
#include "atomic.h"
#include "unicode-helper.h"
#include "ruleset.h"
#include "prop.h"
#include "net.h"
#include "var.h"
#include "rsconf.h"
#include "parserif.h"
#include "errmsg.h"
/* inlines */
extern void msgSetPRI(smsg_t *const __restrict__ pMsg, syslog_pri_t pri);
/* TODO: move the global variable root to the config object - had no time to to it
* right now before vacation -- rgerhards, 2013-07-22
*/
static pthread_mutex_t glblVars_lock;
struct json_object *global_var_root = NULL;
/* static data */
DEFobjStaticHelpers
DEFobjCurrIf(datetime)
DEFobjCurrIf(glbl)
DEFobjCurrIf(regexp)
DEFobjCurrIf(prop)
DEFobjCurrIf(net)
DEFobjCurrIf(var)
static const char *one_digit[10] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
static const char *two_digits[100] = {
"00", "01", "02", "03", "04", "05", "06", "07", "08", "09",
"10", "11", "12", "13", "14", "15", "16", "17", "18", "19",
"20", "21", "22", "23", "24", "25", "26", "27", "28", "29",
"30", "31", "32", "33", "34", "35", "36", "37", "38", "39",
"40", "41", "42", "43", "44", "45", "46", "47", "48", "49",
"50", "51", "52", "53", "54", "55", "56", "57", "58", "59",
"60", "61", "62", "63", "64", "65", "66", "67", "68", "69",
"70", "71", "72", "73", "74", "75", "76", "77", "78", "79",
"80", "81", "82", "83", "84", "85", "86", "87", "88", "89",
"90", "91", "92", "93", "94", "95", "96", "97", "98", "99"};
static const char *wdayNames[7] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
/* Table of days in a year, needed for getYearDay */
static const char *daysInYear[366] = {
"001", "002", "003", "004", "005", "006", "007", "008", "009",
"010", "011", "012", "013", "014", "015", "016", "017", "018", "019",
"020", "021", "022", "023", "024", "025", "026", "027", "028", "029",
"030", "031", "032", "033", "034", "035", "036", "037", "038", "039",
"040", "041", "042", "043", "044", "045", "046", "047", "048", "049",
"050", "051", "052", "053", "054", "055", "056", "057", "058", "059",
"060", "061", "062", "063", "064", "065", "066", "067", "068", "069",
"070", "071", "072", "073", "074", "075", "076", "077", "078", "079",
"080", "081", "082", "083", "084", "085", "086", "087", "088", "089",
"090", "091", "092", "093", "094", "095", "096", "097", "098", "099",
"100", "101", "102", "103", "104", "105", "106", "107", "108", "109",
"110", "111", "112", "113", "114", "115", "116", "117", "118", "119",
"120", "121", "122", "123", "124", "125", "126", "127", "128", "129",
"130", "131", "132", "133", "134", "135", "136", "137", "138", "139",
"140", "141", "142", "143", "144", "145", "146", "147", "148", "149",
"150", "151", "152", "153", "154", "155", "156", "157", "158", "159",
"160", "161", "162", "163", "164", "165", "166", "167", "168", "169",
"170", "171", "172", "173", "174", "175", "176", "177", "178", "179",
"180", "181", "182", "183", "184", "185", "186", "187", "188", "189",
"190", "191", "192", "193", "194", "195", "196", "197", "198", "199",
"200", "201", "202", "203", "204", "205", "206", "207", "208", "209",
"210", "211", "212", "213", "214", "215", "216", "217", "218", "219",
"220", "221", "222", "223", "224", "225", "226", "227", "228", "229",
"230", "231", "232", "233", "234", "235", "236", "237", "238", "239",
"240", "241", "242", "243", "244", "245", "246", "247", "248", "249",
"250", "251", "252", "253", "254", "255", "256", "257", "258", "259",
"260", "261", "262", "263", "264", "265", "266", "267", "268", "269",
"270", "271", "272", "273", "274", "275", "276", "277", "278", "279",
"280", "281", "282", "283", "284", "285", "286", "287", "288", "289",
"290", "291", "292", "293", "294", "295", "296", "297", "298", "299",
"300", "301", "302", "303", "304", "305", "306", "307", "308", "309",
"310", "311", "312", "313", "314", "315", "316", "317", "318", "319",
"320", "321", "322", "323", "324", "325", "326", "327", "328", "329",
"330", "331", "332", "333", "334", "335", "336", "337", "338", "339",
"340", "341", "342", "343", "344", "345", "346", "347", "348", "349",
"350", "351", "352", "353", "354", "355", "356", "357", "358", "359",
"360", "361", "362", "363", "364", "365", "366"};
/* The following is a table of supported years. This permits us
* to avoid dynamic memory allocation. Note that the time-based
* algos need to be upgraded after the year 2099 in any case.
* Quite honestly, I don't expect that this is a real problem ;)
*/
static const char *years[] = {
"1967", "1968", "1969", "1970", "1971", "1972", "1973", "1974",
"1975", "1976", "1977", "1978", "1979", "1980", "1981", "1982",
"1983", "1984", "1985", "1986", "1987", "1988", "1989", "1990",
"1991", "1992", "1993", "1994", "1995", "1996", "1997", "1998",
"1999", "2000", "2001", "2002", "2003", "2004", "2005", "2006",
"2007", "2008", "2009", "2010", "2011", "2012", "2013", "2014",
"2015", "2016", "2017", "2018", "2019", "2020", "2021", "2022",
"2023", "2024", "2025", "2026", "2027", "2028", "2029", "2030",
"2031", "2032", "2033", "2034", "2035", "2036", "2037", "2038",
"2039", "2040", "2041", "2042", "2043", "2044", "2045", "2046",
"2047", "2048", "2049", "2050", "2051", "2052", "2053", "2054",
"2055", "2056", "2057", "2058", "2059", "2060", "2061", "2062",
"2063", "2064", "2065", "2066", "2067", "2068", "2069", "2070",
"2071", "2072", "2073", "2074", "2075", "2076", "2077", "2078",
"2079", "2080", "2081", "2082", "2083", "2084", "2085", "2086",
"2087", "2088", "2089", "2090", "2091", "2092", "2093", "2094",
"2095", "2096", "2097", "2098", "2099" };
static struct {
uchar *pszName;
} syslog_pri_names[200] = {
{ UCHAR_CONSTANT("0") },
{ UCHAR_CONSTANT("1") },
{ UCHAR_CONSTANT("2") },
{ UCHAR_CONSTANT("3") },
{ UCHAR_CONSTANT("4") },
{ UCHAR_CONSTANT("5") },
{ UCHAR_CONSTANT("6") },
{ UCHAR_CONSTANT("7") },
{ UCHAR_CONSTANT("8") },
{ UCHAR_CONSTANT("9") },
{ UCHAR_CONSTANT("10") },
{ UCHAR_CONSTANT("11") },
{ UCHAR_CONSTANT("12") },
{ UCHAR_CONSTANT("13") },
{ UCHAR_CONSTANT("14") },
{ UCHAR_CONSTANT("15") },
{ UCHAR_CONSTANT("16") },
{ UCHAR_CONSTANT("17") },
{ UCHAR_CONSTANT("18") },
{ UCHAR_CONSTANT("19") },
{ UCHAR_CONSTANT("20") },
{ UCHAR_CONSTANT("21") },
{ UCHAR_CONSTANT("22") },
{ UCHAR_CONSTANT("23") },
{ UCHAR_CONSTANT("24") },
{ UCHAR_CONSTANT("25") },
{ UCHAR_CONSTANT("26") },
{ UCHAR_CONSTANT("27") },
{ UCHAR_CONSTANT("28") },
{ UCHAR_CONSTANT("29") },
{ UCHAR_CONSTANT("30") },
{ UCHAR_CONSTANT("31") },
{ UCHAR_CONSTANT("32") },
{ UCHAR_CONSTANT("33") },
{ UCHAR_CONSTANT("34") },
{ UCHAR_CONSTANT("35") },
{ UCHAR_CONSTANT("36") },
{ UCHAR_CONSTANT("37") },
{ UCHAR_CONSTANT("38") },
{ UCHAR_CONSTANT("39") },
{ UCHAR_CONSTANT("40") },
{ UCHAR_CONSTANT("41") },
{ UCHAR_CONSTANT("42") },
{ UCHAR_CONSTANT("43") },
{ UCHAR_CONSTANT("44") },
{ UCHAR_CONSTANT("45") },
{ UCHAR_CONSTANT("46") },
{ UCHAR_CONSTANT("47") },
{ UCHAR_CONSTANT("48") },
{ UCHAR_CONSTANT("49") },
{ UCHAR_CONSTANT("50") },
{ UCHAR_CONSTANT("51") },
{ UCHAR_CONSTANT("52") },
{ UCHAR_CONSTANT("53") },
{ UCHAR_CONSTANT("54") },
{ UCHAR_CONSTANT("55") },
{ UCHAR_CONSTANT("56") },
{ UCHAR_CONSTANT("57") },
{ UCHAR_CONSTANT("58") },
{ UCHAR_CONSTANT("59") },
{ UCHAR_CONSTANT("60") },
{ UCHAR_CONSTANT("61") },
{ UCHAR_CONSTANT("62") },
{ UCHAR_CONSTANT("63") },
{ UCHAR_CONSTANT("64") },
{ UCHAR_CONSTANT("65") },
{ UCHAR_CONSTANT("66") },
{ UCHAR_CONSTANT("67") },
{ UCHAR_CONSTANT("68") },
{ UCHAR_CONSTANT("69") },
{ UCHAR_CONSTANT("70") },
{ UCHAR_CONSTANT("71") },
{ UCHAR_CONSTANT("72") },
{ UCHAR_CONSTANT("73") },
{ UCHAR_CONSTANT("74") },
{ UCHAR_CONSTANT("75") },
{ UCHAR_CONSTANT("76") },
{ UCHAR_CONSTANT("77") },
{ UCHAR_CONSTANT("78") },
{ UCHAR_CONSTANT("79") },
{ UCHAR_CONSTANT("80") },
{ UCHAR_CONSTANT("81") },
{ UCHAR_CONSTANT("82") },
{ UCHAR_CONSTANT("83") },
{ UCHAR_CONSTANT("84") },
{ UCHAR_CONSTANT("85") },
{ UCHAR_CONSTANT("86") },
{ UCHAR_CONSTANT("87") },
{ UCHAR_CONSTANT("88") },
{ UCHAR_CONSTANT("89") },
{ UCHAR_CONSTANT("90") },
{ UCHAR_CONSTANT("91") },
{ UCHAR_CONSTANT("92") },
{ UCHAR_CONSTANT("93") },
{ UCHAR_CONSTANT("94") },
{ UCHAR_CONSTANT("95") },
{ UCHAR_CONSTANT("96") },
{ UCHAR_CONSTANT("97") },
{ UCHAR_CONSTANT("98") },
{ UCHAR_CONSTANT("99") },
{ UCHAR_CONSTANT("100") },
{ UCHAR_CONSTANT("101") },
{ UCHAR_CONSTANT("102") },
{ UCHAR_CONSTANT("103") },
{ UCHAR_CONSTANT("104") },
{ UCHAR_CONSTANT("105") },
{ UCHAR_CONSTANT("106") },
{ UCHAR_CONSTANT("107") },
{ UCHAR_CONSTANT("108") },
{ UCHAR_CONSTANT("109") },
{ UCHAR_CONSTANT("110") },
{ UCHAR_CONSTANT("111") },
{ UCHAR_CONSTANT("112") },
{ UCHAR_CONSTANT("113") },
{ UCHAR_CONSTANT("114") },
{ UCHAR_CONSTANT("115") },
{ UCHAR_CONSTANT("116") },
{ UCHAR_CONSTANT("117") },
{ UCHAR_CONSTANT("118") },
{ UCHAR_CONSTANT("119") },
{ UCHAR_CONSTANT("120") },
{ UCHAR_CONSTANT("121") },
{ UCHAR_CONSTANT("122") },
{ UCHAR_CONSTANT("123") },
{ UCHAR_CONSTANT("124") },
{ UCHAR_CONSTANT("125") },
{ UCHAR_CONSTANT("126") },
{ UCHAR_CONSTANT("127") },
{ UCHAR_CONSTANT("128") },
{ UCHAR_CONSTANT("129") },
{ UCHAR_CONSTANT("130") },
{ UCHAR_CONSTANT("131") },
{ UCHAR_CONSTANT("132") },
{ UCHAR_CONSTANT("133") },
{ UCHAR_CONSTANT("134") },
{ UCHAR_CONSTANT("135") },
{ UCHAR_CONSTANT("136") },
{ UCHAR_CONSTANT("137") },
{ UCHAR_CONSTANT("138") },
{ UCHAR_CONSTANT("139") },
{ UCHAR_CONSTANT("140") },
{ UCHAR_CONSTANT("141") },
{ UCHAR_CONSTANT("142") },
{ UCHAR_CONSTANT("143") },
{ UCHAR_CONSTANT("144") },
{ UCHAR_CONSTANT("145") },
{ UCHAR_CONSTANT("146") },
{ UCHAR_CONSTANT("147") },
{ UCHAR_CONSTANT("148") },
{ UCHAR_CONSTANT("149") },
{ UCHAR_CONSTANT("150") },
{ UCHAR_CONSTANT("151") },
{ UCHAR_CONSTANT("152") },
{ UCHAR_CONSTANT("153") },
{ UCHAR_CONSTANT("154") },
{ UCHAR_CONSTANT("155") },
{ UCHAR_CONSTANT("156") },
{ UCHAR_CONSTANT("157") },
{ UCHAR_CONSTANT("158") },
{ UCHAR_CONSTANT("159") },
{ UCHAR_CONSTANT("160") },
{ UCHAR_CONSTANT("161") },
{ UCHAR_CONSTANT("162") },
{ UCHAR_CONSTANT("163") },
{ UCHAR_CONSTANT("164") },
{ UCHAR_CONSTANT("165") },
{ UCHAR_CONSTANT("166") },
{ UCHAR_CONSTANT("167") },
{ UCHAR_CONSTANT("168") },
{ UCHAR_CONSTANT("169") },
{ UCHAR_CONSTANT("170") },
{ UCHAR_CONSTANT("171") },
{ UCHAR_CONSTANT("172") },
{ UCHAR_CONSTANT("173") },
{ UCHAR_CONSTANT("174") },
{ UCHAR_CONSTANT("175") },
{ UCHAR_CONSTANT("176") },
{ UCHAR_CONSTANT("177") },
{ UCHAR_CONSTANT("178") },
{ UCHAR_CONSTANT("179") },
{ UCHAR_CONSTANT("180") },
{ UCHAR_CONSTANT("181") },
{ UCHAR_CONSTANT("182") },
{ UCHAR_CONSTANT("183") },
{ UCHAR_CONSTANT("184") },
{ UCHAR_CONSTANT("185") },
{ UCHAR_CONSTANT("186") },
{ UCHAR_CONSTANT("187") },
{ UCHAR_CONSTANT("188") },
{ UCHAR_CONSTANT("189") },
{ UCHAR_CONSTANT("190") },
{ UCHAR_CONSTANT("191") },
{ UCHAR_CONSTANT("192") },
{ UCHAR_CONSTANT("193") },
{ UCHAR_CONSTANT("194") },
{ UCHAR_CONSTANT("195") },
{ UCHAR_CONSTANT("196") },
{ UCHAR_CONSTANT("197") },
{ UCHAR_CONSTANT("198") },
{ UCHAR_CONSTANT("199") }
};
static char hexdigit[16] =
{'0', '1', '2', '3', '4', '5', '6', '7', '8',
'9', 'A', 'B', 'C', 'D', 'E', 'F' };
#if defined(_AIX)
/* AIXPORT : replace facility names with aso and caa only for AIX */
static char *syslog_fac_names[LOG_NFACILITIES] = { "kern", "user", "mail", "daemon", "auth", "syslog", "lpr",
"news", "uucp", "cron", "authpriv", "ftp", "aso", "audit",
"alert", "caa", "local0", "local1", "local2", "local3",
"local4", "local5", "local6", "local7", "invld" };
/* length of the facility names string (for optimizatiions) */
static short len_syslog_fac_names[LOG_NFACILITIES] = { 4, 4, 4, 6, 4, 6, 3,
4, 4, 4, 8, 3, 3, 5,
5, 3, 6, 6, 6, 6,
6, 6, 6, 6, 5 };
#else
/*syslog facility names (as of RFC5424) */
static const char *syslog_fac_names[LOG_NFACILITIES] = { "kern", "user", "mail", "daemon", "auth", "syslog", "lpr",
"news", "uucp", "cron", "authpriv", "ftp", "ntp", "audit",
"alert", "clock", "local0", "local1", "local2", "local3",
"local4", "local5", "local6", "local7", "invld" };
/* length of the facility names string (for optimizatiions) */
static short len_syslog_fac_names[LOG_NFACILITIES] = { 4, 4, 4, 6, 4, 6, 3,
4, 4, 4, 8, 3, 3, 5,
5, 5, 6, 6, 6, 6,
6, 6, 6, 6, 5 };
#endif
/* table of severity names (in numerical order)*/
static const char *syslog_severity_names[8] = { "emerg", "alert", "crit", "err", "warning", "notice", "info",
"debug" };
static short len_syslog_severity_names[8] = { 5, 5, 4, 3, 7, 6, 4, 5 };
/* numerical values as string - this is the most efficient approach to convert severity
* and facility values to a numerical string... -- rgerhars, 2009-06-17
*/
static const char *syslog_number_names[LOG_NFACILITIES] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
"10", "11", "12", "13", "14",
"15", "16", "17", "18", "19", "20", "21", "22", "23", "24" };
/* global variables */
#if defined(HAVE_MALLOC_TRIM) && !defined(HAVE_ATOMIC_BUILTINS)
static pthread_mutex_t mutTrimCtr; /* mutex to handle malloc trim */
#endif
/* some forward declarations */
static int getAPPNAMELen(smsg_t * const pM, sbool bLockMutex);
static rsRetVal jsonPathFindParent(struct json_object *jroot, uchar *name, uchar *leaf,
struct json_object **parent, int bCreate);
static uchar * jsonPathGetLeaf(uchar *name, int lenName);
static struct json_object *jsonDeepCopy(struct json_object *src);
static json_bool jsonVarExtract(struct json_object* root, const char *key, struct json_object **value);
void getRawMsgAfterPRI(smsg_t * const pM, uchar **pBuf, int *piLen);
/* the locking and unlocking implementations: */
static inline void
MsgLock(smsg_t *pThis)
{
/* DEV debug only! dbgprintf("MsgLock(0x%lx)\n", (unsigned long) pThis); */
pthread_mutex_lock(&pThis->mut);
}
static inline void
MsgUnlock(smsg_t *pThis)
{
/* DEV debug only! dbgprintf("MsgUnlock(0x%lx)\n", (unsigned long) pThis); */
pthread_mutex_unlock(&pThis->mut);
}
/* set RcvFromIP name in msg object WITHOUT calling AddRef.
* rgerhards, 2013-01-22
*/
static inline void
MsgSetRcvFromIPWithoutAddRef(smsg_t *pThis, prop_t *new)
{
if(pThis->pRcvFromIP != NULL)
prop.Destruct(&pThis->pRcvFromIP);
pThis->pRcvFromIP = new;
}
/* set RcvFrom name in msg object WITHOUT calling AddRef.
* rgerhards, 2013-01-22
*/
static void MsgSetRcvFromWithoutAddRef(smsg_t *pThis, prop_t *new)
{
assert(pThis != NULL);
if(pThis->msgFlags & NEEDS_DNSRESOL) {
if(pThis->rcvFrom.pfrominet != NULL)
free(pThis->rcvFrom.pfrominet);
pThis->msgFlags &= ~NEEDS_DNSRESOL;
} else {
if(pThis->rcvFrom.pRcvFrom != NULL)
prop.Destruct(&pThis->rcvFrom.pRcvFrom);
}
pThis->rcvFrom.pRcvFrom = new;
}
/* rgerhards 2012-04-18: set associated ruleset (by ruleset name)
* pRuleset pointer inside msg is updated. If ruleset cannot be found,
* no update is done and an error message emitted.
*/
static void ATTR_NONNULL()
MsgSetRulesetByName(smsg_t * const pMsg, cstr_t *const rulesetName)
{
uchar *const rs_name = rsCStrGetSzStrNoNULL(rulesetName);
const rsRetVal localRet =
rulesetGetRuleset(runConf, &(pMsg->pRuleset), rs_name);
if(localRet != RS_RET_OK) {
LogError(0, localRet, "msg: ruleset '%s' could not be found and could not "
"be assgined to message object. This possibly leads to the message "
"being processed incorrectly. We cannot do anything against this, but "
"wanted to let you know.", rs_name);
}
}
/* do a DNS reverse resolution, if not already done, reflect status
* rgerhards, 2009-11-16
*/
static rsRetVal
resolveDNS(smsg_t * const pMsg) {
rsRetVal localRet;
prop_t *propFromHost = NULL;
prop_t *ip;
prop_t *localName;
DEFiRet;
MsgLock(pMsg);
CHKiRet(objUse(net, CORE_COMPONENT));
if(pMsg->msgFlags & NEEDS_DNSRESOL) {
if (pMsg->msgFlags & PRESERVE_CASE) {
localRet = net.cvthname(pMsg->rcvFrom.pfrominet, NULL, &localName, &ip);
} else {
localRet = net.cvthname(pMsg->rcvFrom.pfrominet, &localName, NULL, &ip);
}
if(localRet == RS_RET_OK) {
/* we pass down the props, so no need for AddRef */
MsgSetRcvFromWithoutAddRef(pMsg, localName);
MsgSetRcvFromIPWithoutAddRef(pMsg, ip);
}
}
finalize_it:
if(iRet != RS_RET_OK) {
/* best we can do: remove property */
MsgSetRcvFromStr(pMsg, UCHAR_CONSTANT(""), 0, &propFromHost);
prop.Destruct(&propFromHost);
}
MsgUnlock(pMsg);
if(propFromHost != NULL)
prop.Destruct(&propFromHost);
RETiRet;
}
void
getInputName(const smsg_t * const pM, uchar **ppsz, int *const plen)
{
if(pM == NULL || pM->pInputName == NULL) {
*ppsz = UCHAR_CONSTANT("");
*plen = 0;
} else {
prop.GetString(pM->pInputName, ppsz, plen);
}
}
static uchar*
getRcvFromIP(smsg_t * const pM)
{
uchar *psz;
int len;
if(pM == NULL) {
psz = UCHAR_CONSTANT("");
} else {
resolveDNS(pM); /* make sure we have a resolved entry */
if(pM->pRcvFromIP == NULL)
psz = UCHAR_CONSTANT("");
else
prop.GetString(pM->pRcvFromIP, &psz, &len);
}
return psz;
}
/* map a property name (string) to a property ID */
rsRetVal
propNameToID(uchar *pName, propid_t *pPropID)
{
DEFiRet;
/* sometimes there are aliases to the original MonitoWare
* property names. These come after || in the ifs below. */
if(!strcasecmp((char*) pName, "msg")) {
*pPropID = PROP_MSG;
} else if(!strcasecmp((char*) pName, "timestamp")
|| !strcasecmp((char*) pName, "timereported")) {
*pPropID = PROP_TIMESTAMP;
} else if(!strcasecmp((char*) pName, "hostname") || !strcasecmp((char*) pName, "source")) {
*pPropID = PROP_HOSTNAME;
} else if(!strcasecmp((char*) pName, "syslogtag")) {
*pPropID = PROP_SYSLOGTAG;
} else if(!strcasecmp((char*) pName, "rawmsg")) {
*pPropID = PROP_RAWMSG;
} else if(!strcasecmp((char*) pName, "rawmsg-after-pri")) {
*pPropID = PROP_RAWMSG_AFTER_PRI;
} else if(!strcasecmp((char*) pName, "inputname")) {
*pPropID = PROP_INPUTNAME;
} else if(!strcasecmp((char*) pName, "fromhost")) {
*pPropID = PROP_FROMHOST;
} else if(!strcasecmp((char*) pName, "fromhost-ip")) {
*pPropID = PROP_FROMHOST_IP;
} else if(!strcasecmp((char*) pName, "pri")) {
*pPropID = PROP_PRI;
} else if(!strcasecmp((char*) pName, "pri-text")) {
*pPropID = PROP_PRI_TEXT;
} else if(!strcasecmp((char*) pName, "iut")) {
*pPropID = PROP_IUT;
} else if(!strcasecmp((char*) pName, "syslogfacility")) {
*pPropID = PROP_SYSLOGFACILITY;
} else if(!strcasecmp((char*) pName, "syslogfacility-text")) {
*pPropID = PROP_SYSLOGFACILITY_TEXT;
} else if(!strcasecmp((char*) pName, "syslogseverity") || !strcasecmp((char*) pName, "syslogpriority")) {
*pPropID = PROP_SYSLOGSEVERITY;
} else if(!strcasecmp((char*) pName, "syslogseverity-text") ||
!strcasecmp((char*) pName, "syslogpriority-text")) {
*pPropID = PROP_SYSLOGSEVERITY_TEXT;
} else if(!strcasecmp((char*) pName, "timegenerated")) {
*pPropID = PROP_TIMEGENERATED;
} else if(!strcasecmp((char*) pName, "programname")) {
*pPropID = PROP_PROGRAMNAME;
} else if(!strcasecmp((char*) pName, "protocol-version")) {
*pPropID = PROP_PROTOCOL_VERSION;
} else if(!strcasecmp((char*) pName, "structured-data")) {
*pPropID = PROP_STRUCTURED_DATA;
} else if(!strcasecmp((char*) pName, "app-name")) {
*pPropID = PROP_APP_NAME;
} else if(!strcasecmp((char*) pName, "procid")) {
*pPropID = PROP_PROCID;
} else if(!strcasecmp((char*) pName, "msgid")) {
*pPropID = PROP_MSGID;
} else if(!strcasecmp((char*) pName, "jsonmesg")) {
*pPropID = PROP_JSONMESG;
} else if(!strcasecmp((char*) pName, "parsesuccess")) {
*pPropID = PROP_PARSESUCCESS;
#ifdef USE_LIBUUID
} else if(!strcasecmp((char*) pName, "uuid")) {
*pPropID = PROP_UUID;
#endif
/* here start system properties (those, that do not relate to the message itself */
} else if(!strcasecmp((char*) pName, "$NOW")) {
*pPropID = PROP_SYS_NOW;
} else if(!strcasecmp((char*) pName, "$YEAR")) {
*pPropID = PROP_SYS_YEAR;
} else if(!strcasecmp((char*) pName, "$MONTH")) {
*pPropID = PROP_SYS_MONTH;
} else if(!strcasecmp((char*) pName, "$DAY")) {
*pPropID = PROP_SYS_DAY;
} else if(!strcasecmp((char*) pName, "$HOUR")) {
*pPropID = PROP_SYS_HOUR;
} else if(!strcasecmp((char*) pName, "$HHOUR")) {
*pPropID = PROP_SYS_HHOUR;
} else if(!strcasecmp((char*) pName, "$QHOUR")) {
*pPropID = PROP_SYS_QHOUR;
} else if(!strcasecmp((char*) pName, "$MINUTE")) {
*pPropID = PROP_SYS_MINUTE;
} else if(!strcasecmp((char*) pName, "$now-utc")) {
*pPropID = PROP_SYS_NOW_UTC;
} else if(!strcasecmp((char*) pName, "$year-utc")) {
*pPropID = PROP_SYS_YEAR_UTC;
} else if(!strcasecmp((char*) pName, "$month-utc")) {
*pPropID = PROP_SYS_MONTH_UTC;
} else if(!strcasecmp((char*) pName, "$day-utc")) {
*pPropID = PROP_SYS_DAY_UTC;
} else if(!strcasecmp((char*) pName, "$hour-utc")) {
*pPropID = PROP_SYS_HOUR_UTC;
} else if(!strcasecmp((char*) pName, "$hhour-utc")) {
*pPropID = PROP_SYS_HHOUR_UTC;
} else if(!strcasecmp((char*) pName, "$qhour-utc")) {
*pPropID = PROP_SYS_QHOUR_UTC;
} else if(!strcasecmp((char*) pName, "$minute-utc")) {
*pPropID = PROP_SYS_MINUTE_UTC;
} else if(!strcasecmp((char*) pName, "$MYHOSTNAME")) {
*pPropID = PROP_SYS_MYHOSTNAME;
} else if(!strcasecmp((char*) pName, "$!all-json")) {
*pPropID = PROP_CEE_ALL_JSON;
} else if(!strcasecmp((char*) pName, "$!all-json-plain")) {
*pPropID = PROP_CEE_ALL_JSON_PLAIN;
} else if(!strcasecmp((char*) pName, "$BOM")) {
*pPropID = PROP_SYS_BOM;
} else if(!strcasecmp((char*) pName, "$UPTIME")) {
*pPropID = PROP_SYS_UPTIME;
} else if(!strncmp((char*) pName, "$!", 2) || pName[0] == '!') {
*pPropID = PROP_CEE;
} else if(!strncmp((char*) pName, "$.", 2) || pName[0] == '.') {
*pPropID = PROP_LOCAL_VAR;
} else if(!strncmp((char*) pName, "$/", 2) || pName[0] == '/') {
*pPropID = PROP_GLOBAL_VAR;
} else {
DBGPRINTF("PROP_INVALID for name '%s'\n", pName);
*pPropID = PROP_INVALID;
iRet = RS_RET_VAR_NOT_FOUND;
}
RETiRet;
}
/* map a property ID to a name string (useful for displaying) */
uchar *propIDToName(propid_t propID)
{
switch(propID) {
case PROP_MSG:
return UCHAR_CONSTANT("msg");
case PROP_TIMESTAMP:
return UCHAR_CONSTANT("timestamp");
case PROP_HOSTNAME:
return UCHAR_CONSTANT("hostname");
case PROP_SYSLOGTAG:
return UCHAR_CONSTANT("syslogtag");
case PROP_RAWMSG:
return UCHAR_CONSTANT("rawmsg");
case PROP_RAWMSG_AFTER_PRI:
return UCHAR_CONSTANT("rawmsg-after-pri");
case PROP_INPUTNAME:
return UCHAR_CONSTANT("inputname");
case PROP_FROMHOST:
return UCHAR_CONSTANT("fromhost");
case PROP_FROMHOST_IP:
return UCHAR_CONSTANT("fromhost-ip");
case PROP_PRI:
return UCHAR_CONSTANT("pri");
case PROP_PRI_TEXT:
return UCHAR_CONSTANT("pri-text");
case PROP_IUT:
return UCHAR_CONSTANT("iut");
case PROP_SYSLOGFACILITY:
return UCHAR_CONSTANT("syslogfacility");
case PROP_SYSLOGFACILITY_TEXT:
return UCHAR_CONSTANT("syslogfacility-text");
case PROP_SYSLOGSEVERITY:
return UCHAR_CONSTANT("syslogseverity");
case PROP_SYSLOGSEVERITY_TEXT:
return UCHAR_CONSTANT("syslogseverity-text");
case PROP_TIMEGENERATED:
return UCHAR_CONSTANT("timegenerated");
case PROP_PROGRAMNAME:
return UCHAR_CONSTANT("programname");
case PROP_PROTOCOL_VERSION:
return UCHAR_CONSTANT("protocol-version");
case PROP_STRUCTURED_DATA:
return UCHAR_CONSTANT("structured-data");
case PROP_APP_NAME:
return UCHAR_CONSTANT("app-name");
case PROP_PROCID:
return UCHAR_CONSTANT("procid");
case PROP_MSGID:
return UCHAR_CONSTANT("msgid");
case PROP_JSONMESG:
return UCHAR_CONSTANT("jsonmesg");
case PROP_PARSESUCCESS:
return UCHAR_CONSTANT("parsesuccess");
#ifdef USE_LIBUUID
case PROP_UUID:
return UCHAR_CONSTANT("uuid");
#endif
case PROP_SYS_NOW:
return UCHAR_CONSTANT("$NOW");
case PROP_SYS_YEAR:
return UCHAR_CONSTANT("$YEAR");
case PROP_SYS_MONTH:
return UCHAR_CONSTANT("$MONTH");
case PROP_SYS_DAY:
return UCHAR_CONSTANT("$DAY");
case PROP_SYS_HOUR:
return UCHAR_CONSTANT("$HOUR");
case PROP_SYS_HHOUR:
return UCHAR_CONSTANT("$HHOUR");
case PROP_SYS_QHOUR:
return UCHAR_CONSTANT("$QHOUR");
case PROP_SYS_MINUTE:
return UCHAR_CONSTANT("$MINUTE");
case PROP_SYS_NOW_UTC:
return UCHAR_CONSTANT("$NOW-UTC");
case PROP_SYS_YEAR_UTC:
return UCHAR_CONSTANT("$YEAR-UTC");
case PROP_SYS_MONTH_UTC:
return UCHAR_CONSTANT("$MONTH-UTC");
case PROP_SYS_DAY_UTC:
return UCHAR_CONSTANT("$DAY-UTC");
case PROP_SYS_HOUR_UTC:
return UCHAR_CONSTANT("$HOUR-UTC");
case PROP_SYS_HHOUR_UTC:
return UCHAR_CONSTANT("$HHOUR-UTC");
case PROP_SYS_QHOUR_UTC:
return UCHAR_CONSTANT("$QHOUR-UTC");
case PROP_SYS_MINUTE_UTC:
return UCHAR_CONSTANT("$MINUTE-UTC");
case PROP_SYS_MYHOSTNAME:
return UCHAR_CONSTANT("$MYHOSTNAME");
case PROP_CEE_ALL_JSON:
return UCHAR_CONSTANT("$!all-json");
case PROP_CEE_ALL_JSON_PLAIN:
return UCHAR_CONSTANT("$!all-json-plain");
case PROP_SYS_BOM:
return UCHAR_CONSTANT("$BOM");
case PROP_SYS_UPTIME:
return UCHAR_CONSTANT("$UPTIME");
case PROP_CEE:
return UCHAR_CONSTANT("*CEE-based property*");
case PROP_LOCAL_VAR:
return UCHAR_CONSTANT("*LOCAL_VARIABLE*");
case PROP_GLOBAL_VAR:
return UCHAR_CONSTANT("*GLOBAL_VARIABLE*");
default:
return UCHAR_CONSTANT("*invalid property id*");
}
}
/* This is common code for all Constructors. It is defined in an
* inline'able function so that we can save a function call in the
* actual constructors (otherwise, the msgConstruct would need
* to call msgConstructWithTime(), which would require a
* function call). Now, both can use this inline function. This
* enables us to be optimal, but still have the code just once.
* the new object or NULL if no such object could be allocated.
* An object constructed via this function should only be destroyed
* via "msgDestruct()". This constructor does not query system time
* itself but rather uses a user-supplied value. This enables the caller
* to do some tricks to save processing time (done, for example, in the
* udp input).
* NOTE: this constructor does NOT call calloc(), as we have many bytes
* inside the structure which do not need to be cleared. bzero() will
* heavily thrash the cache, so we do the init manually (which also
* is the right thing to do with pointers, as they are not neccessarily
* a binary 0 on all machines [but today almost always...]).
* rgerhards, 2008-10-06
*/
static rsRetVal
msgBaseConstruct(smsg_t **ppThis)
{
DEFiRet;
smsg_t *pM;
assert(ppThis != NULL);
CHKmalloc(pM = malloc(sizeof(smsg_t)));
objConstructSetObjInfo(pM); /* intialize object helper entities */
/* initialize members in ORDER they appear in structure (think "cache line"!) */
pM->flowCtlType = 0;
pM->bParseSuccess = 0;
pM->iRefCount = 1;
pM->iSeverity = LOG_DEBUG;
pM->iFacility = LOG_INVLD;
pM->iLenPROGNAME = -1;
pM->offAfterPRI = 0;
pM->offMSG = -1;
pM->iProtocolVersion = 0;
pM->msgFlags = 0;
pM->iLenRawMsg = 0;
pM->iLenMSG = 0;
pM->iLenTAG = 0;
pM->iLenHOSTNAME = 0;
pM->pszRawMsg = NULL;
pM->pszHOSTNAME = NULL;
pM->pszRcvdAt3164 = NULL;
pM->pszRcvdAt3339 = NULL;
pM->pszRcvdAt_MySQL = NULL;
pM->pszRcvdAt_PgSQL = NULL;
pM->pszTIMESTAMP3164 = NULL;
pM->pszTIMESTAMP3339 = NULL;
pM->pszTIMESTAMP_MySQL = NULL;
pM->pszTIMESTAMP_PgSQL = NULL;
pM->pszStrucData = NULL;
pM->pCSAPPNAME = NULL;
pM->pCSPROCID = NULL;
pM->pCSMSGID = NULL;
pM->pInputName = NULL;
pM->pRcvFromIP = NULL;
pM->rcvFrom.pRcvFrom = NULL;
pM->pRuleset = NULL;
pM->json = NULL;
pM->localvars = NULL;
pM->dfltTZ[0] = '\0';
memset(&pM->tRcvdAt, 0, sizeof(pM->tRcvdAt));
memset(&pM->tTIMESTAMP, 0, sizeof(pM->tTIMESTAMP));
pM->TAG.pszTAG = NULL;
pM->pszTimestamp3164[0] = '\0';
pM->pszTimestamp3339[0] = '\0';
pM->pszTIMESTAMP_SecFrac[0] = '\0';
pM->pszRcvdAt_SecFrac[0] = '\0';
pM->pszTIMESTAMP_Unix[0] = '\0';
pM->pszRcvdAt_Unix[0] = '\0';
pM->pszUUID = NULL;
pthread_mutex_init(&pM->mut, NULL);
/* DEV debugging only! dbgprintf("msgConstruct\t0x%x, ref 1\n", (int)pM);*/
*ppThis = pM;
finalize_it:
RETiRet;
}
/* "Constructor" for a msg "object". Returns a pointer to
* the new object or NULL if no such object could be allocated.
* An object constructed via this function should only be destroyed
* via "msgDestruct()". This constructor does not query system time
* itself but rather uses a user-supplied value. This enables the caller
* to do some tricks to save processing time (done, for example, in the
* udp input).
* rgerhards, 2008-10-06
*/
rsRetVal msgConstructWithTime(smsg_t **ppThis, const struct syslogTime *stTime, const time_t ttGenTime)
{
DEFiRet;
CHKiRet(msgBaseConstruct(ppThis));
(*ppThis)->ttGenTime = ttGenTime;
memcpy(&(*ppThis)->tRcvdAt, stTime, sizeof(struct syslogTime));
memcpy(&(*ppThis)->tTIMESTAMP, stTime, sizeof(struct syslogTime));
finalize_it:
RETiRet;
}
/* "Constructor" for a msg "object". Returns a pointer to
* the new object or NULL if no such object could be allocated.
* An object constructed via this function should only be destroyed
* via "msgDestruct()". This constructor, for historical reasons,
* also sets the two timestamps to the current time.
*/
rsRetVal msgConstruct(smsg_t **ppThis)
{
DEFiRet;
CHKiRet(msgBaseConstruct(ppThis));
/* we initialize both timestamps to contain the current time, so that they
* are consistent. Also, this saves us from doing any further time calls just
* to obtain a timestamp. The memcpy() should not really make a difference,
* especially as I think there is no codepath currently where it would not be
* required (after I have cleaned up the pathes ;)). -- rgerhards, 2008-10-02
*/
datetime.getCurrTime(&((*ppThis)->tRcvdAt), &((*ppThis)->ttGenTime), TIME_IN_LOCALTIME);
memcpy(&(*ppThis)->tTIMESTAMP, &(*ppThis)->tRcvdAt, sizeof(struct syslogTime));
finalize_it:
RETiRet;
}
/* Special msg constructor, to be used when an object is deserialized.
* we do only the base init as we know the properties will be set in
* any case by the deserializer. We still do the "inexpensive" inits
* just to be on the safe side. The whole process needs to be
* refactored together with the msg serialization subsystem.
*/
rsRetVal
msgConstructForDeserializer(smsg_t **ppThis)
{
return msgBaseConstruct(ppThis);
}
/* some free handlers for (slightly) complicated cases... All of them may be called
* with an empty element.
*/
static inline void freeTAG(smsg_t *pThis)
{
if(pThis->iLenTAG >= CONF_TAG_BUFSIZE)
free(pThis->TAG.pszTAG);
}
static inline void freeHOSTNAME(smsg_t *pThis)
{
if(pThis->iLenHOSTNAME >= CONF_HOSTNAME_BUFSIZE)
free(pThis->pszHOSTNAME);
}
rsRetVal msgDestruct(smsg_t **ppThis)
{
DEFiRet;
smsg_t *pThis;
int currRefCount;
# ifdef HAVE_MALLOC_TRIM
int currCnt;
# endif
CODESTARTobjDestruct(msg)
/* DEV Debugging only ! dbgprintf("msgDestruct\t0x%lx, "
"Ref now: %d\n", (unsigned long)pThis, pThis->iRefCount - 1); */
# ifdef HAVE_ATOMIC_BUILTINS
currRefCount = ATOMIC_DEC_AND_FETCH(&pThis->iRefCount, NULL);
# else
MsgLock(pThis);
currRefCount = --pThis->iRefCount;
# endif
if(currRefCount == 0)
{
/* DEV Debugging Only! dbgprintf("msgDestruct\t0x%lx, RefCount now 0,
doing DESTROY\n", (unsigned long)pThis); */
if(pThis->pszRawMsg != pThis->szRawMsg)
free(pThis->pszRawMsg);
freeTAG(pThis);
freeHOSTNAME(pThis);
if(pThis->pInputName != NULL)
prop.Destruct(&pThis->pInputName);
if((pThis->msgFlags & NEEDS_DNSRESOL) == 0) {
if(pThis->rcvFrom.pRcvFrom != NULL)
prop.Destruct(&pThis->rcvFrom.pRcvFrom);
} else {
free(pThis->rcvFrom.pfrominet);
}
if(pThis->pRcvFromIP != NULL)
prop.Destruct(&pThis->pRcvFromIP);
free(pThis->pszRcvdAt3164);
free(pThis->pszRcvdAt3339);
free(pThis->pszRcvdAt_MySQL);
free(pThis->pszRcvdAt_PgSQL);
free(pThis->pszTIMESTAMP_MySQL);
free(pThis->pszTIMESTAMP_PgSQL);
free(pThis->pszStrucData);