Commit a433089e authored by Alessandro Rubini's avatar Alessandro Rubini

arch-bare-* and lib-bare: network functions now dump if level is 2

Like what I did in two commits ago, now if debug level for "frames" is
2 or more, net_ops->send and net_ops->recv now dump the data to
stdout. The format is the same of tools/ptpdump, but the time is
not showing the local time, as we miss localtime() and I don't want
to waste time recoding it.

This is an example of a bare-i386 slave requesting its master:

  send: TIME: (1363278286 - 0x5141f9ce) 1363278286.52969000
  send: ETH: 88f7 (00:25:11:86:1f:d2 -> 01:1b:19:00:00:00)
  send: VERSION: 2 (type 1, len 44, domain 0)
  send: FLAGS: 0x0002 (correction 0x00000000)
  send: PORT: 00-25-11-ff-fe-86-1f-d2-00-01
  send: REST: seq 2, ctrl 1, log-interval 127
  send: MESSAGE: (E) DELAY_REQ
  send: MSG-DELAY_REQ: 1363278286.052689000
  send: DUMP: payload (size 44)
  send: DUMP: 81 02 00 2c  00 00 02 00  00 00 00 00  00 00 00 00
  send: DUMP: 00 00 00 00  00 25 11 ff  fe 86 1f d2  00 01 00 02
  send: DUMP: 01 7f 00 00  51 41 f9 ce  03 23 f8 68
  diag-frames-1-eth0: SENT 44 bytes at 1363278286.052969000 (delay_req)

This is a bare-i386 master receiving the same frame:

  recv: TIME: (1363278286 - 0x5141f9ce) 1363278286.92899000
  recv: ETH: 88f7 (00:25:11:86:1f:d2 -> 01:1b:19:00:00:00)
  recv: VERSION: 2 (type 1, len 44, domain 0)
  recv: FLAGS: 0x0002 (correction 0x00000000)
  recv: PORT: 00-25-11-ff-fe-86-1f-d2-00-01
  recv: REST: seq 2, ctrl 1, log-interval 127
  recv: MESSAGE: (E) DELAY_REQ
  recv: MSG-DELAY_REQ: 1363278286.052689000
  recv: TLV: too short (46 - 44 = 2)
  recv: DUMP: payload (size 46)
  recv: DUMP: 81 02 00 2c  00 00 02 00  00 00 00 00  00 00 00 00
  recv: DUMP: 00 00 00 00  00 25 11 ff  fe 86 1f d2  00 01 00 02
  recv: DUMP: 01 7f 00 00  51 41 f9 ce  03 23 f8 68  00 00
  diag-frames-1-eth0: RECV 46 bytes at 1363278286.092899000 (type 1)

And this is tools/ptprump running on the master, for the same frame:

  TIME: (1363278286 - 0x5141f9ce) 17:24:46.092814
  ETH: 88f7 (00:25:11:86:1f:d2 -> 01:1b:19:00:00:00)
  VERSION: 2 (type 1, len 44, domain 0)
  FLAGS: 0x0002 (correction 0x00000000)
  PORT: 00-25-11-ff-fe-86-1f-d2-00-01
  REST: seq 2, ctrl 1, log-interval 127
  MESSAGE: (E) DELAY_REQ
  MSG-DELAY_REQ: 1363278286.052689000
  TLV: too short (46 - 44 = 2)
  DUMP: payload (size 46)
  DUMP: 81 02 00 2c  00 00 02 00  00 00 00 00  00 00 00 00
  DUMP: 00 00 00 00  00 25 11 ff  fe 86 1f d2  00 01 00 02
  DUMP: 01 7f 00 00  51 41 f9 ce  03 23 f8 68  00 00
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 1e8c65c6
# Alessandro Rubini for CERN, 2011 -- public domain
CFLAGS += -ffreestanding -Os -fno-stack-protector
CFLAGS += -ffreestanding -Os -fno-stack-protector -Itools
ARCH_LDFLAGS = -nostdlib -static -T $(ARCH).lds
# All files are under A (short for ARCH) or L (short for lib): I'm lazy
......@@ -18,6 +18,7 @@ OBJ-libarch := $L/bare-startup.o \
$L/bare-time.o \
$A/syscalls.o \
lib/libc-functions.o \
lib/dump-funcs.o \
lib/cmdline.o \
lib/div64.o
......
# Alessandro Rubini for CERN, 2011 -- public domain
CFLAGS += -ffreestanding -Os -fno-stack-protector
CFLAGS += -ffreestanding -Os -fno-stack-protector -Itools
ARCH_LDFLAGS = -nostdlib -static -T $(ARCH).lds
# All files are under A (short for ARCH) or L (short for lib): I'm lazy
......@@ -19,6 +19,7 @@ OBJ-libarch := $L/bare-startup.o \
$A/syscall.o \
$A/syscalls.o \
lib/libc-functions.o \
lib/dump-funcs.o \
lib/cmdline.o \
lib/div64.o
......
......@@ -3,6 +3,7 @@
CFLAGS += -ffreestanding -Os \
-ffunction-sections -fdata-sections \
-mmultiply-enabled -mbarrel-shift-enabled \
-Itools
ARCH_LDFLAGS = -nostdlib -static -T $(ARCH).lds
......@@ -31,6 +32,7 @@ OBJ-libarch := $A/wrpc-socket.o \
$A/wrpc-io.o \
$A/wrpc-spll.o \
$A/wrpc-calibration.o \
lib/dump-funcs.o \
lib/div64.o
$(LIBARCH): $(OBJ-libarch)
......
......@@ -4,22 +4,28 @@
/* Socket interface for bare Linux */
#include <ppsi/ppsi.h>
#include "ptpdump.h"
#include "bare-linux.h"
/* FIXME: which socket we receive and send with? */
static int bare_net_recv(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t)
{
int ret;
if (t)
ppi->t_ops->get(ppi, t);
return sys_recv(NP(ppi)->ch[PP_NP_GEN].fd, pkt, len, 0);
ret = sys_recv(NP(ppi)->ch[PP_NP_GEN].fd, pkt, len, 0);
if (ret > 0 && pp_diag_allow(ppi, frames, 2))
dump_1588pkt("recv: ", pkt, ret, t);
return ret;
}
static int bare_net_send(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t, int chtype, int use_pdelay_addr)
{
struct bare_ethhdr *hdr = pkt;
int ret;
hdr->h_proto = htons(ETH_P_1588);
......@@ -31,7 +37,10 @@ static int bare_net_send(struct pp_instance *ppi, void *pkt, int len,
if (t)
ppi->t_ops->get(ppi, t);
return sys_send(NP(ppi)->ch[chtype].fd, pkt, len, 0);
ret = sys_send(NP(ppi)->ch[chtype].fd, pkt, len, 0);
if (ret > 0 && pp_diag_allow(ppi, frames, 2))
dump_1588pkt("send: ", pkt, len, t);
return ret;
}
#define SHUT_RD 0
......
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