blob: b76f7a4b32285cee11eadd91bc372ced78416216 [file] [log] [blame]
Dave Barach52642c32016-02-11 19:28:19 -05001/*
2 *------------------------------------------------------------------
3 * Copyright (c) 2006-2016 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef __cpel_util_h__
18#define __cpel_util_h__
19
20/*
21 * Our idea of an event, as opposed to a CPEL event
22 */
23typedef struct evt_ {
24 u64 timestamp;
25 u32 track_id;
26 u32 event_id;
27 u32 datum;
28} evt_t;
29
30evt_t *the_events;
31
32/*
33 * Track object, so we can sort the tracks alphabetically and
34 * fix the events later
35 */
36typedef struct track_ {
37 u32 original_index;
38 u32 strtab_offset;
39} track_t;
40
41track_t *the_tracks;
42u32 *track_alpha_map;
43
44event_definition_t *the_event_definitions;
45i64 min_timestamp;
46
47/* Hash tables, used to find previous instances of the same items */
48uword *the_track_hash;
49uword *the_msg_event_hash;
50uword *the_strtab_hash;
51uword *the_pidtid_hash;
52uword *the_pid_to_name_hash;
53u8 *the_strtab;
54
55u32 find_or_add_strtab(void *s_arg);
56u32 find_or_add_track(void *s_arg);
57u32 find_or_add_event(void *s_arg, char *datum_format);
58int write_string_table(FILE *ofp);
59int write_cpel_header(FILE *ofp, u32 nsections);
60int write_event_defs(FILE *ofp);
61u64 ntohll (u64 x);
62int write_events(FILE *ofp, u64 clock_ticks_per_second);
63int write_track_defs(FILE *ofp);
64void cpel_util_init (void);
65void alpha_sort_tracks(void);
66void fixup_event_tracks(void);
67
68#endif /* __cpel_util_h__ */