/*
 * TraceDaemon.h
 *
 * Copyright (C) 1999, 2000 Karim Yaghmour.
 *
 * This is distributed under GPL.
 *
 * Header for trace toolkit.
 *
 * History : 
 *    K.Y., 01/10/1999, Initial typing.
 *
 */

#ifndef __TRACE_DAEMON_MAIN_HEADER__
#define __TRACE_DAEMON_MAIN_HEADER__

#include <LTTTypes.h>

#include <sys/time.h>
#include <sys/types.h>

/* Number of traced events */
#if SUPP_RTAI
#define TRACE_MAX            44
#else
#define TRACE_MAX            20
#endif

/* The configurations possible */
#define TRACER_START                      0  /* Start tracing events using the current configuration */
#define TRACER_STOP                       1  /* Stop tracing */
#define TRACER_CONFIG_DEFAULT             2  /* Set the tracer to the default configuration */
#define TRACER_CONFIG_MEMORY_BUFFERS      3  /* Set the memory buffers the daemon wants us to use */
#define TRACER_CONFIG_EVENTS              4  /* Trace the given events */
#define TRACER_CONFIG_DETAILS             5  /* Record the details of the event, or not */
#define TRACER_CONFIG_CPUID               6  /* Record the CPUID associated with the event */
#define TRACER_CONFIG_PID                 7  /* Trace only one process */
#define TRACER_CONFIG_PGRP                8  /* Trace only the given process group */
#define TRACER_CONFIG_GID                 9  /* Trace the processes of a given group of users */
#define TRACER_CONFIG_UID                10  /* Trace the processes of a given user */
#define TRACER_CONFIG_SYSCALL_EIP_DEPTH  11  /* Set the call depth at which the EIP should be fetched on syscall */
#define TRACER_CONFIG_SYSCALL_EIP_LOWER  12  /* Set the lowerbound address from which EIP is recorded on syscall */
#define TRACER_CONFIG_SYSCALL_EIP_UPPER  13  /* Set the upperbound address from which EIP is recorded on syscall */
#define TRACER_DATA_COMITTED             14  /* The daemon has comitted the last trace */
#define TRACER_GET_EVENTS_LOST           15  /* Get the number of events lost */

/* The event mask functions and definitions */
typedef uint64_t tracer_event_mask;

/* Options structure */
typedef struct _options
{
  int                ConfigDefault;      /* Use the tracing device's default configuration */
  int                SpecifyEvents;      /* Does the user want to specify the events to trace */
  tracer_event_mask  EventMask;          /* The mask specifying the events to be traced */
  int                SpecifyDetails;     /* Does the user want to specify for which events he wants the details */
  tracer_event_mask  DetailsMask;        /* The mask specifying for which events the details are logged */
  int                ConfigCPUID;        /* Should the CPUID be logged */
  int                ConfigPID;          /* Does the user want to log only the events belonging to a certain PID */
  int                PID;                /* The designated PID */
  int                ConfigPGRP;         /* Does the user want to log only the events belonging to a certain process group */
  int                PGRP;               /* The designated process group */
  int                ConfigGID;          /* Does the user want to log only the events belonging to a certain GID */
  int                GID;                /* The designated GID */
  int                ConfigUID;          /* Does the user want to log only the events belonging to a certain UID */
  int                UID;                /* The designated UID */
  int                ConfigSyscallDepth; /* Fetch a certain syscall depth */
  int                SyscallDepth;       /* The designated depth */
  int                ConfigSyscallBound; /* Fetch the syscall eip that fits in a certain address bounds */
  uint32_t           UpperBound;         /* The upper bound eip */
  uint32_t           LowerBound;         /* The lower bound eip */
  int                ConfigTime;         /* Should the deamon only run for a given period of time */
  struct timeval     Time;               /* Time for which daemon should run */
  char*              DeviceFileName;     /* The name of the device from which to read events */
  char*              TraceFileName;      /* Name of file used to dump raw trace */
  char*              ProcFileName;       /* Name of file contaning /proc information as of daemon's startup */
} options;

#endif  /* __TRACE_DAEMON_MAIN_HEADER__ */
