]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Add trace_snoop_time.
authorTed Lemon <source@isc.org>
Thu, 15 Feb 2001 14:12:36 +0000 (14:12 +0000)
committerTed Lemon <source@isc.org>
Thu, 15 Feb 2001 14:12:36 +0000 (14:12 +0000)
omapip/trace.c

index 19bbb635488c666daf896ac641428eebcf7ee150..849f7e72aaea40121838f6a3579497b2c6ea866c 100644 (file)
@@ -1,6 +1,8 @@
 /* trace.c
 
-   Subroutines that support dhcp tracing... */
+   Subroutines that support tracing of OMAPI wire transactions and
+   provide a mechanism for programs using OMAPI to trace their own
+   transactions... */
 
 /*
  * Copyright (c) 2001 Internet Software Consortium.
@@ -53,6 +55,7 @@ static trace_type_t *new_trace_types;
 static FILE *traceinfile;
 static tracefile_header_t tracefile_header;
 static int trace_playback_flag;
+trace_type_t trace_time_marker;
 
 int trace_playback ()
 {
@@ -499,6 +502,8 @@ isc_result_t trace_get_next_packet (trace_type_t **ttp,
                }
                return ISC_R_UNEXPECTEDTOKEN;
        }
+       if (ttp && *ttp == &trace_time_marker)
+               return ISC_R_EXISTS;
 
        paylen = tpkt -> length;
        if (paylen % 8)
@@ -558,6 +563,32 @@ isc_result_t trace_get_packet (trace_type_t **ttp,
        return status;
 }
 
+time_t trace_snoop_time ()
+{
+       tracepacket_t *tpkt;
+       unsigned bufmax = 0;
+       unsigned buflen = 0;
+       char *buf = (char *)0;
+       isc_result_t status;
+       time_t result;
+       trace_type_t *ttp = &trace_time_marker;
+       
+       if (!buf || *buf)
+               return ISC_R_INVALIDARG;
+
+       tpkt = dmalloc ((unsigned)tracefile_header.phlen, MDL);
+       if (!tpkt) {
+               log_error ("can't allocate trace packet header.");
+               return ISC_R_NOMEMORY;
+       }
+
+       trace_get_next_packet (&ttp, tpkt, &buf, &buflen, &bufmax);
+       result = tpkt -> when;
+
+       dfree (tpkt, MDL);
+       return result;
+}
+
 /* Get a packet from the trace input file that contains a file with the
    specified name.   We don't hunt for the packet - it should be the next
    packet in the tracefile.   If it's not, or something else bad happens,