Ver Fonte

temp submit

zhangbo há 5 anos atrás
pai
commit
3702877ddf

BIN
app/bmc/bmc_app


+ 2 - 1
app/goahead-5.1.0/src/goahead.c

@@ -150,7 +150,7 @@ MAIN(goahead, int argc, char **argv, char **envp)
     }
 #endif
     logHeader();
-	error("---> argind = %d, argc = %d\n", argind, argc);
+	printf("---> argind = %d, argc = %d\n", argind, argc);
     if (argind < argc) {
         while (argind < argc) {
             endpoint = argv[argind++];
@@ -166,6 +166,7 @@ MAIN(goahead, int argc, char **argv, char **envp)
             if (strstr(endpoint, "https")) continue;
 #endif
             if (websListen(endpoint) < 0) {
+                printf("websListen>>>>>>>>>>>>>>endpoint>>>>%s\n", endpoint);
                 wfree(endpoints);
                 return -1;
             }

+ 23 - 3
app/goahead-5.1.0/src/http.c

@@ -576,6 +576,8 @@ PUBLIC void websFree(Webs *wp)
  */
 PUBLIC void websDone(Webs *wp)
 {
+
+    printf("-------------writeDone------0-----------------s\n" );
     WebsSocket  *sp;
 
     assert(wp);
@@ -600,7 +602,9 @@ PUBLIC void websDone(Webs *wp)
         /*
             Initiate flush. If not all flushed, wait for output to drain via a socket event.
          */
+        printf("-------------writeDone  here------0-----------------s\n %d", wp->sid );
         if (websFlush(wp, 0) == 0) {
+             printf("-------------writeDone-- error----0-----------------s\n" );
             sp = socketPtr(wp->sid);
             socketCreateHandler(wp->sid, sp->handlerMask | SOCKET_WRITABLE, socketEvent, wp);
         }
@@ -645,6 +649,9 @@ PUBLIC int websListen(cchar *endpoint)
         error("Too many listen endpoints");
         return -1;
     }
+
+
+    printf("socket ++++++++++++++++++>%s\n", endpoint);
     socketParseAddress(endpoint, &ip, &port, &secure, 80);
 	error("---> ip: %s, port: %d, secure: %d\n", ip, port, secure);
     if ((sid = socketListen(ip, port, websAccept, 0)) < 0) {
@@ -739,7 +746,7 @@ PUBLIC int websAccept(int sid, cchar *ipaddr, int port, int listenSid)
         Arrange for socketEvent to be called when read data is available
      */
     lp = socketPtr(listenSid);
-    trace(4, "New connection from %s:%d to %s:%d", ipaddr, port, wp->ifaddr, lp->port);
+    printf("New connection from %s:%d to %s:%d", ipaddr, port, wp->ifaddr, lp->port);
 
 #if ME_COM_SSL
     if (lp->secure) {
@@ -839,6 +846,7 @@ static void readEvent(Webs *wp)
     if (nbytes > 0 || wp->state > WEBS_BEGIN) {
         websPump(wp);
     }
+    error("---> WEBS_CLOSED: %d", WEBS_CLOSED );
 	error("---> wp.flags: %d, nbytes: %d, wp.state: %d, wp.sid: %#x\n", wp->flags, nbytes, wp->state, wp->sid );
     if (wp->flags & WEBS_CLOSED) {
         return;
@@ -1633,13 +1641,13 @@ PUBLIC void websResponse(Webs *wp, int code, cchar *message)
         websWriteBlock(wp, message, len);
         websWriteBlock(wp, "\r\n", 2);
 
-        // websWrite(wp, message);
+        websWrite(wp, message);
        
     } else {
         logmsg(2,"-----------------------response 2-----------------------%s", message);
         websWriteHeaders(wp, 0, 0);
         websWriteEndHeaders(wp);
-        // websWriteBlock(wp, message, len);
+        websWriteBlock(wp, message, len);
     }
     websDone(wp);
 }
@@ -1867,8 +1875,11 @@ PUBLIC int websWriteHeader(Webs *wp, cchar *key, cchar *fmt, ...)
 
 PUBLIC void websSetStatus(Webs *wp, int code)
 {
+    printf("------------------code----------------%#x\n", wp->code);
+    // printf("------------------route----------------%s\n", wp->route);
     wp->code = (code & WEBS_CODE_MASK);
     if (code & WEBS_CLOSE) {
+        printf("------------------keep-alive----------------%s\n", wp->flags);
         wp->flags &= ~WEBS_KEEP_ALIVE;
     }
 }
@@ -1880,6 +1891,7 @@ PUBLIC void websSetStatus(Webs *wp, int code)
  */
 PUBLIC void websWriteHeaders(Webs *wp, ssize length, cchar *location)
 {
+
     WebsKey     *cookie, *key, *next;
     char        *date, *protoVersion;
 
@@ -2105,6 +2117,7 @@ static bool flushChunkData(Webs *wp)
  */
 PUBLIC int websFlush(Webs *wp, bool block)
 {
+
     WebsBuf     *op;
     ssize       nbytes, written;
     int         errCode, wasBlocking;
@@ -2247,6 +2260,7 @@ PUBLIC ssize websWriteBlock(Webs *wp, cchar *buf, ssize size)
         buf += thisWrite;
         written += thisWrite;
     }
+
     bufAddNull(op);
     if (wp->state >= WEBS_COMPLETE && written == 0) {
         return -1;
@@ -2367,7 +2381,11 @@ static void checkTimeout(void *arg, int id)
 
     wp = (Webs*) arg;
     assert(websValid(wp));
+    printf("<<<<<<<<<checkTimeout<<<<<<<<>>%d\n", id);
 
+    printf("<<<<<<<<<checkTimeout<<<<websDebug<<<<>>%s\n", wp->path);
+
+    printf("<<<<<<<<<checkTimeout<<<<websDebug<<<<>>%#x\n", websDebug);
     elapsed = getTimeSinceMark(wp) * 1000;
     if (websDebug) {
         websRestartEvent(id, (int) WEBS_TIMEOUT);
@@ -3428,6 +3446,8 @@ PUBLIC int websServer(cchar *endpoint, cchar *documents)
 {
     int     finished = 0;
 
+
+    printf("websServer>>>>>>>>>>>>>>>>>>%s\n", documents);
     if (websOpen(documents, "route.txt") < 0) {
         error("Cannot initialize server. Exiting.");
         return -1;

+ 0 - 3
app/goahead-5.1.0/src/route.c

@@ -94,7 +94,6 @@ PUBLIC void websRouteRequest(Webs *wp)
 {
 
     // logmsg(2,"——————————————————————0————————————");
-    logmsg(2, "-----------------------222----------------------");
     WebsRoute   *route;
     WebsHandler *handler;
     ssize       plen, len;
@@ -108,7 +107,6 @@ PUBLIC void websRouteRequest(Webs *wp)
 
     safeMethod = smatch(wp->method, "POST") || smatch(wp->method, "GET") || smatch(wp->method, "HEAD");
     plen = slen(wp->path);
-        logmsg(2, "-----------------------0.1----------------------");
     /*
         Resume routine from last matched route. This permits the legacy service() callbacks to return false
         and continue routing.
@@ -163,7 +161,6 @@ PUBLIC void websRouteRequest(Webs *wp)
         }
 
         wp->route = route;
-         logmsg(2,"-----------------------11-----------------------");
 #if ME_GOAHEAD_AUTH
         logmsg(2,"-----------------------22-----111-------%#X-----------", route->authType);
         if (route->authType) {

Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 0
app/goahead-5.1.0/src/web/static/css/dashbord.css


Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 0
app/goahead-5.1.0/src/web/static/css/sensor_history.css


Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 0
app/goahead-5.1.0/src/web/static/js/dashbord.js


Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 0
app/goahead-5.1.0/src/web/static/js/sensor_history.js


+ 124 - 52
app/goahead-5.1.0/src/web_interface/src/dashboard.c

@@ -30,7 +30,7 @@ void getDeviceInfo(Webs *wp){
     
 
     //Create session
-    LIBIPMI_CreateSession(&UDSSession, 10);
+    LIBIPMI_CreateSession(&UDSSession, 10000);
 
     //get build time
     sprintf(BuildTime, "%s %s", __DATE__, __TIME__);
@@ -40,6 +40,12 @@ void getDeviceInfo(Webs *wp){
     if (wRet == LIBIPMI_E_SUCCESS)
     {
         sprintf(FwVersion, "%d.%d", DeviceID.FirmwareRevision1, DeviceID.FirmwareRevision2);
+
+
+        printf("BuildTime: %s\n", BuildTime);
+        printf("FwVersion: %s\n", FwVersion);
+        printf("MacAddr: %s\n", MacAddr);
+        printf("IpAddr: %s\n", IpAddr);
     }
 
     //Close session
@@ -91,6 +97,7 @@ void getDeviceInfo(Webs *wp){
     // }
     // close(sock);
 
+
     char *pStr = malloc(500);
     char *dataStr = malloc(200);
     char msgStr[10] = "\"\"";
@@ -99,6 +106,7 @@ void getDeviceInfo(Webs *wp){
     sprintf(dataStr, "{\"buildTime\":\"%s\",\"fwVersion\":\"%s\",\"macAddr\":\"%s\",\"ipAddr\":\"%s\"}", \
         BuildTime, FwVersion, MacAddr, IpAddr);
 
+
     sprintf(pStr, "{\"data\": %s,\"msg\":%s,\"code\": %s}", \
          dataStr, msgStr, codeStr);
 
@@ -116,11 +124,13 @@ void getDeviceInfo(Webs *wp){
 
     //pStr = cJSON_Print(root);
 
-    printf("json str:\n%s\n", pStr);
+
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp); 
-    websWrite(wp, "%s", pStr);
+    //websWrite(wp, "[");
+    websWrite(wp, pStr);
+    //websWrite(wp, "]");
     websFlush(wp, 0);
     websDone(wp);
 
@@ -132,6 +142,9 @@ void getDeviceInfo(Webs *wp){
 
 /*获取系统信息*/
 void getSysInfo(Webs *wp){
+
+
+    printf("lisentid value is %d\n", wp->listenSid);
     int wRet;
     SysInfo_T sysInfo;
     uint8_t Req[5] = {0,0,0,0,0};
@@ -159,38 +172,49 @@ void getSysInfo(Webs *wp){
         memset(sysInfo.text, 0, MAX_TEXT_LEN);
 
     //Create session
-    wRet = LIBIPMI_CreateSession(&UDSSession, 10);
+    wRet = LIBIPMI_CreateSession(&UDSSession, 10000);
     
     LIBIPMI_HL_GetSysInfo(&UDSSession, &sysInfo, DEFAULT_TIMEOUT);
 
     //Close session
-    LIBIPMI_CloseSession(&UDSSession );
+    // LIBIPMI_CloseSession(&UDSSession );
 
     printf("Title: %s\n", sysInfo.title);
     printf("Text: %s\n", sysInfo.text);
 
 
-    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, "title", sysInfo.title);
-    cJSON_AddStringToObject(data, "text", sysInfo.text);
+    // 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, "title", sysInfo.title);
+    // cJSON_AddStringToObject(data, "text", sysInfo.text);
 
-    pStr = cJSON_Print(root);
+    // pStr = cJSON_Print(root);
 
+
+     char *pStr;
+
+    char *testStr;
+    testStr = malloc(500); 
+    //sprintf(testStr, "{data: {\"Version\": \"%s\", \"MAC\": \"%s\", \"IP\": \"%s\"}, \"msg\":\"\"}", FwVersion, MacAddr, IpAddr);
+
+    sprintf(testStr, "{\"data\": {\"buildTime\":\"%s\",\"fwVersion\":\"%s\",\"macAddr\":\"%s\",\"ipAddr\":\"%s\"},\"msg\":\"\",\"code\": %d}", \
+        "BuildTime", "FwVersion", "MacAddr", "IpAddr", 200);
+
+    pStr = testStr;
     printf("first json:\n%s\n", pStr);
     logmsg(2, "-----------------------sys----------------------%s", pStr);
-    websSetStatus(wp, WEBS_KEEP_ALIVE);
+    websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp); 
-    websWrite(wp, pStr);
+    websWrite(wp,"%s", pStr);
+    websFlush(wp, 0);
     websDone(wp);
-    sleep(1);
 sys_info_end: 
     if(sysInfo.title)
         free(sysInfo.title);
@@ -198,8 +222,8 @@ sys_info_end:
         free(sysInfo.text);
 
     free(pStr);
-    cJSON_Delete(root);
-    cJSON_Delete(data);
+    // cJSON_Delete(root);
+    // cJSON_Delete(data);
 
 }
 
@@ -237,7 +261,7 @@ void getSensorInfo(Webs *wp){
     IPMI20_UDS_SESSION_T    UDSSession;
 
     //Create session
-    wRet = LIBIPMI_CreateSession(&UDSSession, 10);
+    wRet = LIBIPMI_CreateSession(&UDSSession, 10000);
    
     /* Get number of SEL records in the system at this time */
     wRet = LIBIPMI_HL_GetSensorCount(&UDSSession,&nSensors,DEFAULT_TIMEOUT);
@@ -347,6 +371,14 @@ void getSensorInfo(Webs *wp){
 
             logmsg(2, "-----------------------sensor----------------------");
 
+            websSetStatus(wp, 200);
+            websWriteHeaders(wp, -1, 0);
+            websWriteEndHeaders(wp); 
+            //websWrite(wp, "[");
+            websWrite(wp, ">>>>>>>>>>>>>>>>>>>>>");
+            //websWrite(wp, "]");
+            //websFlush(wp, 0);
+            websDone(wp);
             // websSetStatus(wp, WEBS_KEEP_ALIVE);
             // websWriteHeaders(wp, -1, 0);
             // websWriteEndHeaders(wp); 
@@ -403,6 +435,49 @@ void buy(Webs *wp)
 // /*
 //     Implement /action/actionTest. Parse the form variables: name, address and echo back.
 //  */
+// void actionTest(Webs *wp)
+// {
+
+//     printf("sid value is >>>>>>>>>>>>>: %d<<<<<<<<<<<\n", wp->sid);
+//     IPMI20_UDS_SESSION_T    UDSSession;
+//     GetDevIDRes_T   DeviceID;
+
+//     //Create session
+//     printf("actionTest!\n");
+//     LIBIPMI_CreateSession(&UDSSession, 10);
+//     IPMICMD_GetDeviceID( &UDSSession, &DeviceID, DEFAULT_TIMEOUT);
+
+//     printf("sid value is >>>>>1>>>>>>>>: %d<<<<<<<\n", wp->sid);
+
+
+//     char *pStr;
+
+//     char *testStr;
+//     testStr = malloc(500); 
+//     //sprintf(testStr, "{data: {\"Version\": \"%s\", \"MAC\": \"%s\", \"IP\": \"%s\"}, \"msg\":\"\"}", FwVersion, MacAddr, IpAddr);
+
+//     sprintf(testStr, "{\"data\": {\"buildTime\":\"%s\",\"fwVersion\":\"%s\",\"macAddr\":\"%s\",\"ipAddr\":\"%s\"},\"msg\":\"\",\"code\": %d}", \
+//         BuildTime, FwVersion, MacAddr, IpAddr, 200);
+
+
+//     //sprintf(testStr, "jimbo and lusa are very confused, please git me some tips, my god!");
+
+//      pStr = testStr;
+
+
+//     char name[] = "jimbo";
+//     char address[] = "shanghai";
+//     printf("name: %s, address: %s\n", name, address);
+//     websSetStatus(wp, 200);
+//     websWriteHeaders(wp, -1, 0);
+//     websWriteEndHeaders(wp);
+//     websWrite(wp,  testStr);
+//     websFlush(wp, 0);
+//     websDone(wp);
+//     // LIBIPMI_CloseSession(&UDSSession );
+// }
+
+
 void actionTest(Webs *wp)
 {
     IPMI20_UDS_SESSION_T    UDSSession;
@@ -413,10 +488,11 @@ void actionTest(Webs *wp)
     char IpAddr[16] = "192.168.255.255";
 
     //Create session
-    printf("actionTest!\n");
-    LIBIPMI_CreateSession(&UDSSession, 10);
-    IPMICMD_GetDeviceID( &UDSSession, &DeviceID, DEFAULT_TIMEOUT);
-    LIBIPMI_CloseSession(&UDSSession );
+
+    // LIBIPMI_CreateSession(&UDSSession, 10);
+    // IPMICMD_GetDeviceID( &UDSSession, &DeviceID, DEFAULT_TIMEOUT);
+    // LIBIPMI_CloseSession(&UDSSession );
+
 
     char *pStr;
 
@@ -426,31 +502,29 @@ void actionTest(Webs *wp)
 
     sprintf(testStr, "{\n\t\"data\": {\n\t\t\"buildTime\":\"%s\",\n\t\t\"fwVersion\":\"%s\",\n\t\t\"macAddr\":\"%s\",\n\t\t\"ipAddr\":\"%s\"\n\t},\n\t\"msg\":\"\",\n\t\"code\": %d\n}", \
         BuildTime, FwVersion, MacAddr, IpAddr, 200);
+     pStr = testStr;
 
-
-    //sprintf(testStr, "jimbo and lusa are very confused, please git me some tips, my god!");
-
-    pStr = testStr;
-
-    cJSON * root =  cJSON_CreateObject();
-    cJSON * data =  cJSON_CreateObject();
+    // cJSON * root =  cJSON_CreateObject();
+    // cJSON * data =  cJSON_CreateObject();
     printf("log1\n");
-    //cJSON_AddItemToObject(root, "data", data);//根节点下添加
-    cJSON_AddStringToObject(root, "msg", NULL);
-    cJSON_AddNumberToObject(root, "code", 200);
-    cJSON_AddStringToObject(data, "buildTime", BuildTime);
-    cJSON_AddStringToObject(data, "fwVersion", FwVersion);
-    cJSON_AddStringToObject(data, "macAddr", MacAddr);
-    cJSON_AddStringToObject(data, "ipAddr", IpAddr);
- //   /*pStr = */cJSON_Print(root);     //include malloc
+    // 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);
+    // cJSON_AddStringToObject(data, "macAddr", MacAddr);
+    // cJSON_AddStringToObject(data, "ipAddr", IpAddr);
+    // pStr = cJSON_Print(root);     //include malloc
+ //    cJSON_AddItemToObject(root, "data", data);//根节点下添加
+ //    cJSON_AddStringToObject(root, "msg", NULL);
+ //    cJSON_AddNumberToObject(root, "code", 200);
+ // //   cJSON_AddStringToObject(data, "buildTime", BuildTime);
+ // //   cJSON_AddStringToObject(data, "fwVersion", FwVersion);
+ // //   cJSON_AddStringToObject(data, "macAddr", MacAddr);
+ // //   cJSON_AddStringToObject(data, "ipAddr", IpAddr);
+ //    pStr = cJSON_Print(root);     //include malloc
     
     printf("%s\n", pStr);
-    int i=0;
-    while(pStr[i])
-    {
-        printf("%#x ", pStr[i++]);
-    }
-    printf("\n");
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp);
@@ -461,10 +535,8 @@ void actionTest(Webs *wp)
     if(pStr)
         free(pStr);
 
-    cJSON_Delete(root);
-    cJSON_Delete(data);
+    // cJSON_Delete(root);
+    // cJSON_Delete(data);
 
     
-}
-
-
+}

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff