206 lines
8.0 KiB
Diff
206 lines
8.0 KiB
Diff
Index: wide-dhcpv6-20080615/common.c
|
|
===================================================================
|
|
--- wide-dhcpv6-20080615.orig/common.c 2015-07-01 09:39:01.518095085 +0800
|
|
+++ wide-dhcpv6-20080615/common.c 2015-07-01 09:43:28.583588954 +0800
|
|
@@ -94,7 +94,8 @@
|
|
#include "zcfg_fe_rdm_access.h"
|
|
#include "zcfg_msg.h"
|
|
|
|
-struct json_object *dhcp6cMsg = NULL;
|
|
+struct dhcp6c_Msg dhcp6cMsg = {0};
|
|
+//struct json_object *dhcp6cMsg = NULL;
|
|
|
|
#ifdef __linux__
|
|
/* from /usr/include/linux/ipv6.h */
|
|
@@ -3332,12 +3333,20 @@
|
|
dprintf(LOG_ERR, FNAME, "%s : address of the PD interface\n", __FUNCTION__);
|
|
}
|
|
else { /* address of the WAN interface */
|
|
- json_object_object_add(dhcp6cMsg, "addrAssigned", json_object_new_boolean(true));
|
|
+ dhcp6cMsg.editAddr = true;
|
|
+
|
|
+ dhcp6cMsg.addrAssigned = true;
|
|
+ dhcp6cMsg.addrCmd = cmd;
|
|
+ strcpy(dhcp6cMsg.ifname, ifname);
|
|
+ strcpy(dhcp6cMsg.addr, addr);
|
|
+ dhcp6cMsg.addrPltime = pltime;
|
|
+ dhcp6cMsg.addrVltime = vltime;
|
|
+ /*json_object_object_add(dhcp6cMsg, "addrAssigned", json_object_new_boolean(true));
|
|
json_object_object_add(dhcp6cMsg, "addrCmd", json_object_new_int(cmd));
|
|
json_object_object_add(dhcp6cMsg, "ifname", json_object_new_string(ifname));
|
|
json_object_object_add(dhcp6cMsg, "addr", json_object_new_string(addr));
|
|
json_object_object_add(dhcp6cMsg, "addrPltime", json_object_new_int(pltime));
|
|
- json_object_object_add(dhcp6cMsg, "addrVltime", json_object_new_int(vltime));
|
|
+ json_object_object_add(dhcp6cMsg, "addrVltime", json_object_new_int(vltime));*/
|
|
#if 0
|
|
dhcp6cMsgBody.addrAssigned = TRUE;
|
|
dhcp6cMsgBody.addrCmd = cmd;
|
|
Index: wide-dhcpv6-20080615/common.h
|
|
===================================================================
|
|
--- wide-dhcpv6-20080615.orig/common.h 2015-07-01 09:39:01.518095085 +0800
|
|
+++ wide-dhcpv6-20080615/common.h 2015-07-01 09:41:00.793942892 +0800
|
|
@@ -117,6 +117,28 @@
|
|
#endif
|
|
}
|
|
|
|
+struct dhcp6c_Msg {
|
|
+ int addrAssigned;
|
|
+ int addrCmd;
|
|
+ char ifname[32];
|
|
+ char addr[128];
|
|
+ int addrPltime;
|
|
+ int addrVltime;
|
|
+ int editAddr;/*check send addr msg or not */
|
|
+ char pidfile[64];
|
|
+ int eidtPid;/*check send Pid msg or not*/
|
|
+ int prefixAssigned;
|
|
+ int prefixCmd;
|
|
+ char prefix[128];
|
|
+ int prefixPltime;
|
|
+ int prefixVltime;
|
|
+ int eidtPrefix;/*check send prefix msg or not*/
|
|
+ char nameserver[128];
|
|
+ int eidtNameServer;/*check send name server msg or not*/
|
|
+ char domainName[128];
|
|
+ int eidtDomain;/*check send domain msg or not*/
|
|
+};
|
|
+
|
|
extern int foreground;
|
|
extern int debug_thresh;
|
|
extern char *device;
|
|
Index: wide-dhcpv6-20080615/dhcp6c.c
|
|
===================================================================
|
|
--- wide-dhcpv6-20080615.orig/dhcp6c.c 2015-07-01 09:39:01.522095085 +0800
|
|
+++ wide-dhcpv6-20080615/dhcp6c.c 2015-07-01 09:46:07.887200251 +0800
|
|
@@ -85,7 +85,8 @@
|
|
|
|
#include <json/json.h>
|
|
|
|
-extern struct json_object *dhcp6cMsg;
|
|
+extern struct dhcp6c_Msg dhcp6cMsg;
|
|
+//extern struct json_object *dhcp6cMsg;
|
|
extern zcfgRet_t dhcp6MsgSend(int, int, const char *);
|
|
/*end*/
|
|
|
|
@@ -264,6 +265,30 @@
|
|
|
|
/*------------------------------------------------------------*/
|
|
|
|
+void dhcpMsgToJsonFormat(struct json_object *dhcp6cMsgBody){
|
|
+ if(dhcp6cMsg.eidtPid)
|
|
+ json_object_object_add(dhcp6cMsgBody, "pidfile", json_object_new_string(dhcp6cMsg.pidfile)); //add pid_file information
|
|
+ if(dhcp6cMsg.editAddr){
|
|
+ json_object_object_add(dhcp6cMsgBody, "addrAssigned", json_object_new_boolean(dhcp6cMsg.addrAssigned));
|
|
+ json_object_object_add(dhcp6cMsgBody, "addrCmd", json_object_new_int(dhcp6cMsg.addrCmd));
|
|
+ json_object_object_add(dhcp6cMsgBody, "ifname", json_object_new_string(dhcp6cMsg.ifname));
|
|
+ json_object_object_add(dhcp6cMsgBody, "addr", json_object_new_string(dhcp6cMsg.addr));
|
|
+ json_object_object_add(dhcp6cMsgBody, "addrPltime", json_object_new_int(dhcp6cMsg.addrPltime));
|
|
+ json_object_object_add(dhcp6cMsgBody, "addrVltime", json_object_new_int(dhcp6cMsg.addrVltime));
|
|
+ }
|
|
+ if(dhcp6cMsg.eidtPrefix){
|
|
+ json_object_object_add(dhcp6cMsgBody, "prefixAssigned", json_object_new_boolean(dhcp6cMsg.prefixAssigned));
|
|
+ json_object_object_add(dhcp6cMsgBody, "prefixCmd", json_object_new_int(dhcp6cMsg.prefixCmd));
|
|
+ json_object_object_add(dhcp6cMsgBody, "prefix", json_object_new_string(dhcp6cMsg.prefix));
|
|
+ json_object_object_add(dhcp6cMsgBody, "prefixPltime", json_object_new_int(dhcp6cMsg.prefixPltime));
|
|
+ json_object_object_add(dhcp6cMsgBody, "prefixVltime", json_object_new_int(dhcp6cMsg.prefixVltime));
|
|
+ }
|
|
+ if(dhcp6cMsg.eidtNameServer)
|
|
+ json_object_object_add(dhcp6cMsgBody, "nameserver", json_object_new_string(dhcp6cMsg.nameserver));
|
|
+ if(dhcp6cMsg.eidtDomain)
|
|
+ json_object_object_add(dhcp6cMsgBody, "domainName", json_object_new_string(dhcp6cMsg.domainName));
|
|
+}
|
|
+
|
|
void
|
|
client6_init()
|
|
{
|
|
@@ -1790,7 +1815,7 @@
|
|
}
|
|
|
|
/*zyxel*/
|
|
- dhcp6cMsg = json_object_new_object();
|
|
+ //dhcp6cMsg = json_object_new_object();
|
|
|
|
/*
|
|
* The client MAY choose to report any status code or message from the
|
|
@@ -1922,13 +1947,19 @@
|
|
&optinfo->serverID, ev->authparam);
|
|
}
|
|
|
|
+ struct json_object *dhcp6cJsonMsg = NULL;
|
|
+ dhcp6cJsonMsg = json_object_new_object();
|
|
//dprintf(LOG_ERR, FNAME, "json : %s\n", json_object_to_json_string(dhcp6cMsg));
|
|
- json_object_object_add(dhcp6cMsg, "pidfile", json_object_new_string(pid_file)); //add pid_file information
|
|
- msg = json_object_to_json_string(dhcp6cMsg);
|
|
+ dhcp6cMsg.eidtPid = true;
|
|
+ strcpy(dhcp6cMsg.pidfile, pid_file);
|
|
+ //json_object_object_add(dhcp6cMsg, "pidfile", json_object_new_string(pid_file)); //add pid_file information
|
|
+ dhcpMsgToJsonFormat(dhcp6cJsonMsg);
|
|
+ msg = json_object_to_json_string(dhcp6cJsonMsg);
|
|
msgLen = strlen(msg) + 1;
|
|
|
|
dhcp6MsgSend(ZCFG_MSG_DHCP6C_STATE_CHANGED, msgLen, msg);
|
|
- json_object_put(dhcp6cMsg);
|
|
+ memset(&dhcp6cMsg, 0, sizeof(dhcp6cMsg));
|
|
+ json_object_put(dhcp6cJsonMsg);
|
|
|
|
dhcp6_remove_event(ev);
|
|
|
|
@@ -2232,7 +2263,9 @@
|
|
dhcp6cMsgBody.dnsAssigned = TRUE;
|
|
strcpy(dhcp6cMsgBody.nameserver, nameserver);
|
|
#endif
|
|
- json_object_object_add(dhcp6cMsg, "nameserver", json_object_new_string(nameserver));
|
|
+ dhcp6cMsg.eidtNameServer = true;
|
|
+ strcpy(dhcp6cMsg.nameserver, nameserver);
|
|
+ //json_object_object_add(dhcp6cMsg, "nameserver", json_object_new_string(nameserver));
|
|
}
|
|
|
|
if(domainName && domainName[0] != '\0') {
|
|
@@ -2240,7 +2273,9 @@
|
|
dhcp6cMsgBody.domainNameAssigned = TRUE;
|
|
strcpy(dhcp6cMsgBody.domainName, domainName);
|
|
#endif
|
|
- json_object_object_add(dhcp6cMsg, "domainName", json_object_new_string(domainName));
|
|
+ dhcp6cMsg.eidtDomain = true;
|
|
+ strcpy(dhcp6cMsg.domainName, domainName);
|
|
+ //json_object_object_add(dhcp6cMsg, "domainName", json_object_new_string(domainName));
|
|
}
|
|
|
|
return;
|
|
Index: wide-dhcpv6-20080615/prefixconf.c
|
|
===================================================================
|
|
--- wide-dhcpv6-20080615.orig/prefixconf.c 2015-07-01 09:39:01.570095085 +0800
|
|
+++ wide-dhcpv6-20080615/prefixconf.c 2015-07-01 09:40:55.887059146 +0800
|
|
@@ -64,7 +64,8 @@
|
|
#include <stdbool.h>
|
|
#include <json/json.h>
|
|
|
|
-extern struct json_object *dhcp6cMsg;
|
|
+extern struct dhcp6c_Msg dhcp6cMsg;
|
|
+//extern struct json_object *dhcp6cMsg;
|
|
/*zyxel end*/
|
|
|
|
TAILQ_HEAD(siteprefix_list, siteprefix);
|
|
@@ -534,11 +535,19 @@
|
|
|
|
sprintf(prefix, "%s/%d", in6addr2str(&sp->prefix.addr, 0), sp->prefix.plen);
|
|
|
|
- json_object_object_add(dhcp6cMsg, "prefixAssigned", json_object_new_boolean(true));
|
|
+ dhcp6cMsg.eidtPrefix = true;
|
|
+ dhcp6cMsg.prefixAssigned = true;
|
|
+ dhcp6cMsg.prefixCmd = cmd;
|
|
+ strcpy(dhcp6cMsg.prefix, prefix);
|
|
+
|
|
+ dhcp6cMsg.prefixPltime = sp->prefix.pltime;
|
|
+ dhcp6cMsg.prefixVltime = sp->prefix.vltime;
|
|
+
|
|
+ /*json_object_object_add(dhcp6cMsg, "prefixAssigned", json_object_new_boolean(true));
|
|
json_object_object_add(dhcp6cMsg, "prefixCmd", json_object_new_int(cmd));
|
|
json_object_object_add(dhcp6cMsg, "prefix", json_object_new_string(prefix));
|
|
json_object_object_add(dhcp6cMsg, "prefixPltime", json_object_new_int(sp->prefix.pltime));
|
|
- json_object_object_add(dhcp6cMsg, "prefixVltime", json_object_new_int(sp->prefix.vltime));
|
|
+ json_object_object_add(dhcp6cMsg, "prefixVltime", json_object_new_int(sp->prefix.vltime));*/
|
|
|
|
return;
|
|
}
|