Commit 58f064cc authored by Aurelio Colosimo's avatar Aurelio Colosimo

pp_get_tstamp and new pp_set_tstamp implemented

parent 0426fd59
...@@ -21,5 +21,5 @@ all: $(TARGET) ...@@ -21,5 +21,5 @@ all: $(TARGET)
# were not selected yet (e.g., pp_open_instance() ). # were not selected yet (e.g., pp_open_instance() ).
$(TARGET): $(TARGET).o $(LIBARCH) $(TARGET): $(TARGET).o $(LIBARCH)
$(CC) -Wl,-Map,$(TARGET).map2 -o $@ $(TARGET).o \ $(CC) -Wl,-Map,$(TARGET).map2 -o $@ $(TARGET).o \
-L$A -larch -L$D -lstd -L$A -larch -L$D -lstd -lrt
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
*/ */
#define _GNU_SOURCE /* for strnlen */ #define _GNU_SOURCE /* for strnlen */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <pptp/pptp.h> #include <pptp/pptp.h>
...@@ -34,5 +35,23 @@ void *pp_memset(void *s, int c, int count) ...@@ -34,5 +35,23 @@ void *pp_memset(void *s, int c, int count)
void pp_get_tstamp(TimeInternal *t) void pp_get_tstamp(TimeInternal *t)
{ {
/*FIXME tstamp *sptr = htonl(time(NULL)); */ struct timespec tp;
if (clock_gettime(CLOCK_REALTIME, &tp) < 0) {
/* FIXME diag PERROR("clock_gettime() failed, exiting."); */
exit(0);
}
t->seconds = tp.tv_sec;
t->nanoseconds = tp.tv_nsec;
}
void pp_set_tstamp(TimeInternal *t)
{
/* FIXME: what happens with timers? */
struct timespec tp;
tp.tv_sec = t->seconds;
tp.tv_nsec = t->nanoseconds;
if (clock_settime(CLOCK_REALTIME, &tp) < 0) {
/* FIXME diag PERROR("clock_settime() failed, exiting."); */
exit(0);
}
} }
...@@ -266,8 +266,9 @@ extern int to_TimeInternal(TimeInternal *internal, Timestamp *external); ...@@ -266,8 +266,9 @@ extern int to_TimeInternal(TimeInternal *internal, Timestamp *external);
extern void add_TimeInternal(TimeInternal *r, TimeInternal *x, TimeInternal *y); extern void add_TimeInternal(TimeInternal *r, TimeInternal *x, TimeInternal *y);
extern void sub_TimeInternal(TimeInternal *r, TimeInternal *x, TimeInternal *y); extern void sub_TimeInternal(TimeInternal *r, TimeInternal *x, TimeInternal *y);
/* Get a timestamp */ /* Get and Set system timestamp */
extern void pp_get_tstamp(TimeInternal *t); extern void pp_get_tstamp(TimeInternal *t);
extern void pp_set_tstamp(TimeInternal *t);
/* /*
* The state machine itself is an array of these structures. * The state machine itself is an array of these structures.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment