nps: poci/nws_poci.c - fixed parameters passing to iproute in set_...

baggins baggins at pld-linux.org
Tue Sep 13 13:32:56 CEST 2005


Author: baggins                      Date: Tue Sep 13 11:32:56 2005 GMT
Module: nps                           Tag: HEAD
---- Log message:
- fixed parameters passing to iproute in set_ip function

---- Files affected:
nps/poci:
   nws_poci.c (1.9 -> 1.10) 

---- Diffs:

================================================================
Index: nps/poci/nws_poci.c
diff -u nps/poci/nws_poci.c:1.9 nps/poci/nws_poci.c:1.10
--- nps/poci/nws_poci.c:1.9	Mon Sep 12 20:30:04 2005
+++ nps/poci/nws_poci.c	Tue Sep 13 13:32:47 2005
@@ -400,6 +400,10 @@
 
 int call_iproute2(int command, char *iface, char *pl_ip, char *sp_ip, int prefix, char *logfile)
 {
+	char *const *argv;
+	pid_t pid;
+	int status;
+
 	switch (command) {
 		case IP_A_SHOW:
 		// /sbin/ip address show %s 2>%s
@@ -417,6 +421,16 @@
 		default:
 			return -1;
 	}
+
+	pid = fork();
+	if (pid < 0)
+		return -1;
+
+	if (pid == 0) {
+//		execl("/sbin/ip", "ip", ...);
+	} else {
+		waitpid(pid, &status, 0);
+	}
 	return 0;
 }
 
@@ -699,7 +713,7 @@
 **********************************************/
 void getCpuid(int s, int desired) {
     FILE *inFile;
-    int i, proc;
+    int i, proc = 0;
     size_t bytesRx;
     VPD_FIELDS field = Unknown;
     char buf[LG_STR], ecLevel[LG_STR];
@@ -932,7 +946,6 @@
 {
     int fd;
     int rc;
-    int pref;
     struct in_addr pl_ip, sp_ip;
     char pl_addr[16], sp_addr[16];
     unsigned long platIp, spIp;
@@ -965,7 +978,6 @@
 
     pl_ip.s_addr = ntohl(platIp);
     sp_ip.s_addr = ntohl(spIp);
-fprintf(stderr, "%0x, %0x, %d\n", spIp, platIp, sizeof(spIp));
     strncpy(pl_addr, inet_ntoa(pl_ip), 16);
     strncpy(sp_addr, inet_ntoa(sp_ip), 16);
     snprintf(command,BUFSIZE,"/sbin/ip address flush jnet0 ; /sbin/ip address add %s peer %s dev jnet0", pl_addr, sp_addr);
@@ -1366,21 +1378,21 @@
     case 2:
 	snprintf(command,BUFSIZE,
 			"/sbin/ip address add %s dev %s 2>%s",
-			param[1],param[2], logFileName);
+			param[2],param[1], logFileName);
 fprintf(stderr, "2: %s\n", command);
         break;
     case 3:
 	pref = netmask_to_prefix(param[3]);
 	snprintf(command,BUFSIZE,
 			"/sbin/ip address add %s/%d dev %s 2>%s",
-			param[1],param[2],pref, logFileName);
+			param[2],pref,param[1], logFileName);
 fprintf(stderr, "3: %s\n", command);
         break;
     case 4:
 	pref = netmask_to_prefix(param[3]);
 	snprintf(command,BUFSIZE,
 			"/sbin/ip address add %s/%d dev %s 2>%s",
-			param[1],param[2],pref, logFileName);
+			param[2],pref,param[1], logFileName);
 fprintf(stderr, "4: %s\n", command);
         break;
     default:
@@ -1693,7 +1705,6 @@
     int fd, fd1;
     uint32_t pip;
     struct in_addr inp;
-    int pref;
 
     printStart(outBuf);
 
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/nps/poci/nws_poci.c?r1=1.9&r2=1.10&f=u




More information about the pld-cvs-commit mailing list