|
@@ -17,7 +17,8 @@
|
|
#include "goahead.h"
|
|
#include "goahead.h"
|
|
#include "libipmi_IPM.h"
|
|
#include "libipmi_IPM.h"
|
|
#include "com_IPMIDefs.h"
|
|
#include "com_IPMIDefs.h"
|
|
-
|
|
|
|
|
|
+#include "ResultUtils.h"
|
|
|
|
+#include "cJSON.h"
|
|
/*********************************** Locals ***********************************/
|
|
/*********************************** Locals ***********************************/
|
|
|
|
|
|
static WebsRoute **routes = 0;
|
|
static WebsRoute **routes = 0;
|
|
@@ -92,27 +93,86 @@ void getDeviceInfo(Webs *wp){
|
|
GetDevIDRes_T DeviceID;
|
|
GetDevIDRes_T DeviceID;
|
|
char BuildTime[30] = {0};
|
|
char BuildTime[30] = {0};
|
|
char FwVersion[10] = {0};
|
|
char FwVersion[10] = {0};
|
|
-
|
|
|
|
//Create session
|
|
//Create session
|
|
LIBIPMI_CreateSession(&wp->ipmi_session, 10);
|
|
LIBIPMI_CreateSession(&wp->ipmi_session, 10);
|
|
-
|
|
|
|
sprintf(BuildTime, "%s %s", __DATE__, __TIME__);
|
|
sprintf(BuildTime, "%s %s", __DATE__, __TIME__);
|
|
wRet = IPMICMD_GetDeviceID( &wp->ipmi_session, &DeviceID, DEFAULT_TIMEOUT);
|
|
wRet = IPMICMD_GetDeviceID( &wp->ipmi_session, &DeviceID, DEFAULT_TIMEOUT);
|
|
if (wRet == LIBIPMI_E_SUCCESS)
|
|
if (wRet == LIBIPMI_E_SUCCESS)
|
|
{
|
|
{
|
|
sprintf(FwVersion, "%d.%d", DeviceID.FirmwareRevision1, DeviceID.FirmwareRevision2);
|
|
sprintf(FwVersion, "%d.%d", DeviceID.FirmwareRevision1, DeviceID.FirmwareRevision2);
|
|
}
|
|
}
|
|
-
|
|
|
|
printf("BuildTime: %s\n", BuildTime);
|
|
printf("BuildTime: %s\n", BuildTime);
|
|
printf("FwVersion: %s\n", FwVersion);
|
|
printf("FwVersion: %s\n", FwVersion);
|
|
|
|
+ //Close session
|
|
|
|
+ LIBIPMI_CloseSession(&wp->ipmi_session );
|
|
|
|
+ char *pStr;
|
|
|
|
+ int code = 200;
|
|
|
|
+ cJSON * root = cJSON_CreateObject();
|
|
|
|
+ cJSON * data = cJSON_CreateObject();
|
|
|
|
+ // cJSON * next = cJSON_CreateObject();
|
|
|
|
+ cJSON_AddItemToObject(root, "data", data);//根节点下添加
|
|
|
|
+ cJSON_AddItemToObject(root, "msg", cJSON_CreateString(""));
|
|
|
|
+ cJSON_AddItemToObject(root, "code", cJSON_CreateString("200"));
|
|
|
|
+ cJSON_AddStringToObject(data, "BuildTime", BuildTime);
|
|
|
|
+ cJSON_AddStringToObject(data, "FwVersion", FwVersion);
|
|
|
|
+
|
|
|
|
+ pStr = cJSON_Print(root);
|
|
|
|
+
|
|
|
|
+ printf("first json:\n%s\n", pStr);
|
|
|
|
+ logmsg(2, "-----------------------jso1n----------------------%s", pStr);
|
|
|
|
+ websSetStatus(wp, 200);
|
|
|
|
+ websWriteHeaders(wp, -1, 0);
|
|
|
|
+ websWriteEndHeaders(wp);
|
|
|
|
+ websWrite(wp, "[ {\"name\":\"kangkang\",\"age\":\"12\",\"gender\":\"male\"}, {\"name\":\"Jane\",\"age\":\"14\",\"gender\":\"female\"}]");
|
|
|
|
+ websDone(wp);
|
|
|
|
+ // retrun 1;
|
|
|
|
+}
|
|
|
|
+/*获取设备信息*/
|
|
|
|
+void getDeviceInfoBak(Webs *wp){
|
|
|
|
+ logmsg(2, "--------------------ggggggggg----------------");
|
|
|
|
|
|
|
|
+ uint16_t wRet = LIBIPMI_E_SUCCESS;
|
|
|
|
+ GetDevIDRes_T DeviceID;
|
|
|
|
+ char BuildTime[30] = {0};
|
|
|
|
+ char FwVersion[10] = {0};
|
|
|
|
+ //Create session
|
|
|
|
+ LIBIPMI_CreateSession(&wp->ipmi_session, 10);
|
|
|
|
+ sprintf(BuildTime, "%s %s", __DATE__, __TIME__);
|
|
|
|
+ wRet = IPMICMD_GetDeviceID( &wp->ipmi_session, &DeviceID, DEFAULT_TIMEOUT);
|
|
|
|
+ if (wRet == LIBIPMI_E_SUCCESS)
|
|
|
|
+ {
|
|
|
|
+ sprintf(FwVersion, "%d.%d", DeviceID.FirmwareRevision1, DeviceID.FirmwareRevision2);
|
|
|
|
+ }
|
|
|
|
+ printf("BuildTime: %s\n", BuildTime);
|
|
|
|
+ printf("FwVersion: %s\n", FwVersion);
|
|
//Close session
|
|
//Close session
|
|
LIBIPMI_CloseSession(&wp->ipmi_session );
|
|
LIBIPMI_CloseSession(&wp->ipmi_session );
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ cchar *pStr;
|
|
|
|
+ int code = 200;
|
|
|
|
+ cJSON * root = cJSON_CreateObject();
|
|
|
|
+ cJSON * data = cJSON_CreateObject();
|
|
|
|
+ // cJSON * next = cJSON_CreateObject();
|
|
|
|
+ cJSON_AddItemToObject(root, "data", data);//根节点下添加
|
|
|
|
+ cJSON_AddItemToObject(root, "msg", cJSON_CreateString(""));
|
|
|
|
+ cJSON_AddItemToObject(root, "code", cJSON_CreateString("200"));
|
|
|
|
+ cJSON_AddStringToObject(data, "BuildTime", BuildTime);
|
|
|
|
+ cJSON_AddStringToObject(data, "FwVersion", FwVersion);
|
|
|
|
+
|
|
|
|
+ pStr = cJSON_Print(root);
|
|
|
|
+
|
|
|
|
+ printf("first json:\n%s\n", pStr);
|
|
|
|
+ logmsg(2, "-----------------------jso1n----------------------%s", pStr);
|
|
|
|
+
|
|
|
|
+ websSetStatus(wp, 200);
|
|
|
|
+ websWriteHeaders(wp, -1, 0);
|
|
|
|
+ websWriteEndHeaders(wp);
|
|
|
|
+ websWrite(wp, "[ {\"name\":\"kangkang\",\"age\":\"12\",\"gender\":\"male\"}, {\"name\":\"Jane\",\"age\":\"14\",\"gender\":\"female\"}]");
|
|
|
|
+ websFlush(wp, 0);
|
|
|
|
+ websDone(wp);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
/************************************ Code ************************************/
|
|
/************************************ Code ************************************/
|
|
/*
|
|
/*
|
|
Route the request. If wp->route is already set, test routes after that route
|
|
Route the request. If wp->route is already set, test routes after that route
|
|
@@ -159,7 +219,7 @@ PUBLIC void websRouteRequest(Webs *wp)
|
|
|
|
|
|
for (; i < routeCount; i++) {
|
|
for (; i < routeCount; i++) {
|
|
route = routes[i];
|
|
route = routes[i];
|
|
- logmsg(2, "-----------------------0.2----------------------%s", route->prefix);
|
|
|
|
|
|
+ // logmsg(2, "-----------------------0.2----------------------%s", route->prefix);
|
|
assert(route->prefix && route->prefixLen > 0);
|
|
assert(route->prefix && route->prefixLen > 0);
|
|
|
|
|
|
if (plen < route->prefixLen) continue;
|
|
if (plen < route->prefixLen) continue;
|
|
@@ -193,11 +253,15 @@ PUBLIC void websRouteRequest(Webs *wp)
|
|
wp->route = route;
|
|
wp->route = route;
|
|
logmsg(2,"-----------------------11-----------------------");
|
|
logmsg(2,"-----------------------11-----------------------");
|
|
#if ME_GOAHEAD_AUTH
|
|
#if ME_GOAHEAD_AUTH
|
|
- logmsg(2,"-----------------------22-----------------------%s", route->authType);
|
|
|
|
- if (route->authType && !websAuthenticate(wp)) {
|
|
|
|
|
|
+ logmsg(2,"-----------------------22------------%#X-----------", route->authType);
|
|
|
|
+ if (route->authType) {
|
|
// personInfoAction(wp);//
|
|
// personInfoAction(wp);//
|
|
- logmsg(2,"-----------------------33-----------------------");
|
|
|
|
- return;
|
|
|
|
|
|
+ logmsg(2,"-----------------------33--444---------------------");
|
|
|
|
+ if(!websAuthenticate(wp)){
|
|
|
|
+ logmsg(2,"-----------------------33--111---------------------");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
if (route->abilities >= 0 && !websCan(wp, route->abilities)) {
|
|
if (route->abilities >= 0 && !websCan(wp, route->abilities)) {
|
|
logmsg(2,"-----------------------44-----------------------");
|
|
logmsg(2,"-----------------------44-----------------------");
|