From 271136e2446445276a0188807ab67aa09c40ae0a Mon Sep 17 00:00:00 2001 From: hadaq Date: Sat, 25 Feb 2012 21:33:13 +0000 Subject: [PATCH] update --- pexor/Makefile | 2 +- trbnetd/Makefile | 2 +- trbnetd/server/Makefile | 2 +- trbnetd/server/trbnetd.c | 33 ++++++++++++++++++++++++++++++++- trbnetd/trbnetrpc.c | 33 ++++++++++++++++++++++++++++++++- trbnetd/trbrpc.x | 4 ++++ trbrich/Makefile | 2 +- 7 files changed, 72 insertions(+), 6 deletions(-) diff --git a/pexor/Makefile b/pexor/Makefile index 527b78a..b6991a5 100644 --- a/pexor/Makefile +++ b/pexor/Makefile @@ -19,7 +19,7 @@ LD = $(CC) LDFLAGS = LIBDIR = -L../libtrbnet -LOADLIBES = -ltrbnet +LOADLIBES = -ltrbnet -lm # ------------ TARGETS ------------------------------------------------- diff --git a/trbnetd/Makefile b/trbnetd/Makefile index 945804f..e1eec52 100644 --- a/trbnetd/Makefile +++ b/trbnetd/Makefile @@ -20,7 +20,7 @@ LD = $(CC) LDFLAGS = LIBDIR = -LOADLIBES = +LOADLIBES = -lm # ------------ TARGETS ------------------------------------------------- diff --git a/trbnetd/server/Makefile b/trbnetd/server/Makefile index 3818888..d346b20 100644 --- a/trbnetd/server/Makefile +++ b/trbnetd/server/Makefile @@ -24,7 +24,7 @@ LD = $(CC) LDFLAGS = LIBDIR = -L../../libtrbnet -LOADLIBES = -ltrbnet +LOADLIBES = -ltrbnet -lm # ------------ TARGETS ------------------------------------------------- diff --git a/trbnetd/server/trbnetd.c b/trbnetd/server/trbnetd.c index 3c8df76..b51def0 100644 --- a/trbnetd/server/trbnetd.c +++ b/trbnetd/server/trbnetd.c @@ -14,7 +14,7 @@ #include "trbrpc.h" -static const char trbnetd_version[] = "$Revision: 1.12 $"; +static const char trbnetd_version[] = "$Revision: 1.13 $"; static int daemon_lock = 0; @@ -437,6 +437,37 @@ bool_t register_modify_1_svc(uint16_t trb_address, return TRUE; } +bool_t nettrace_1_svc(uint16_t trb_address, + u_int dsize, + RetVal * retVal, + struct svc_req * rqstp) +{ + int status; + + /* allocate buffer memory */ + retVal->data.Buffer_len = 0; + retVal->data.Buffer_val = (uint32_t *) malloc(sizeof(uint32_t) * dsize); + if (retVal->data.Buffer_val == NULL) { + fprintf(stderr, "nettrace: malloc failed\n"); + retVal->status.trb_errno = TRB_RPC_ERROR; + retVal->status.retVal = -1; + return TRUE; + } + + if (daemon_lock == 1) { + retVal->status.retVal = -128; + return TRUE; + } + + status = trb_nettrace(trb_address, + (uint32_t *) retVal->data.Buffer_val, dsize); + retVal->data.Buffer_len = status == -1 ? 0 : status; + retVal->status.retVal = status; + copyStatus(&retVal->status); + + return TRUE; +} + extern void trbnetrpcprog_1(struct svc_req *rqstp, register SVCXPRT * transp); /* ------ MAIN ---------------------------------------------------------- */ diff --git a/trbnetd/trbnetrpc.c b/trbnetd/trbnetrpc.c index 8ce1236..18a8276 100644 --- a/trbnetd/trbnetrpc.c +++ b/trbnetd/trbnetrpc.c @@ -6,7 +6,7 @@ #include "trbnet.h" -const char trbnet_version[] = "$Revision: 1.11 $ RPC"; +const char trbnet_version[] = "$Revision: 1.12 $ RPC"; unsigned int trb_debug = 0; unsigned int trb_dma = 0; static CLIENT *trb_client = NULL; @@ -542,3 +542,34 @@ int trb_register_modify(uint16_t trb_address, copyStatus(&retVal); return retVal.retVal; } + +int trb_nettrace(uint16_t trb_address, + uint32_t * data, unsigned int dsize) +{ + enum clnt_stat status; + RetVal retVal; + + if (trb_client == NULL) return -1; + do { + retVal.data.Buffer_val = data; + retVal.data.Buffer_len = dsize; + status = + nettrace_1(trb_address, dsize, + &retVal, trb_client); + + if (status != RPC_SUCCESS) { + /* + * An error occurred while calling the server. + * Print error message and stop. + */ + trb_errno = status + 256; + return -1; + } + if (retVal.status.retVal != -128) break; + sleep(SLEEP_TIME); + } while (1); + + copyStatus(&retVal.status); + return retVal.status.retVal; +} + diff --git a/trbnetd/trbrpc.x b/trbnetd/trbrpc.x index 2a40678..a4583f9 100644 --- a/trbnetd/trbrpc.x +++ b/trbnetd/trbrpc.x @@ -89,6 +89,10 @@ program TRBNETRPCPROG { int, uint32_t, uint32_t) = 17; + + RetVal NETTRACE(uint16_t, + unsigned int) = 18; + } = 1; } = 0x20000099; diff --git a/trbrich/Makefile b/trbrich/Makefile index 79be570..2065325 100644 --- a/trbrich/Makefile +++ b/trbrich/Makefile @@ -18,7 +18,7 @@ CFLAGS = -pipe -g -Wall -Winline -O3 -fPIC -finline-functions -finline-limit=60 LD = $(CC) LDFLAGS = LIBDIR = -L../libtrbnet -LOADLIBES = -ltrbnet +LOADLIBES = -ltrbnet -lm # ------------ TARGETS ------------------------------------------------- -- 2.43.0