[lldp-devel] [PATCH 3/3] vdptest use function clif_getpid

Thomas Richter tmricht at linux.vnet.ibm.com
Thu Feb 21 15:38:44 UTC 2013


Use new function clif_getpid() to get the pid of lldpad.

Signed-off-by: Thomas Richter <tmricht at linux.vnet.ibm.com>
---
 test/vdptest.c |   34 +++-------------------------------
 1 files changed, 3 insertions(+), 31 deletions(-)

diff --git a/test/vdptest.c b/test/vdptest.c
index 1b80879..8447c6c 100644
--- a/test/vdptest.c
+++ b/test/vdptest.c
@@ -669,43 +669,15 @@ static int open_socket(int protocol)
  */
 static void lldpad_pid(void)
 {
-	struct clif *clif_conn;
-	char buf[MAX_CLIF_MSGBUF];
-	size_t len;
-	int ret;
-	char *ppong;
-
-	clif_conn = clif_open();
-	if (!clif_conn) {
-		fprintf(stderr, "%s: couldn't connect to lldpad\n", progname);
-		exit(1);
-	}
-	if (clif_attach(clif_conn, NULL)) {
-		fprintf(stderr, "%s: failed to attach to lldpad\n", progname);
-		exit(2);
-	}
-	ret = clif_request(clif_conn, "P", 1, buf, &len, NULL);
-	if (ret == -2) {
-		fprintf(stderr, "%s: connection to lldpad timed out\n",
-			progname);
-		exit(3);
-	}
-	if (ret < 0) {
-		fprintf(stderr, "%s: ping command failed\n", progname);
-		exit(4);
-	}
-	buf[len] = '\0';
-	ppong = strstr(buf, "PPONG");		/* Ignore leading chars */
-	if (!ppong || sscanf(ppong, "PPONG%d", &lldpad) != 1) {
-		fprintf(stderr, "%s error parsing pid of lldpad\n",
+	lldpad = clif_getpid();
+	if (!lldpad) {
+		fprintf(stderr, "%s error getting pid of lldpad\n",
 			progname);
 		exit(5);
 	}
 	if (verbose >= 2)
 		printf("%s my pid %d lldpad pid %d\n", progname, getpid(),
 		    lldpad);
-	clif_detach(clif_conn);
-	clif_close(clif_conn);
 }
 
 /*
-- 
1.7.1



More information about the lldp-devel mailing list