zhangbo před 5 roky
rodič
revize
7c72a979bd

+ 30 - 1
app/bmc/Api.c

@@ -466,6 +466,35 @@ char* getip(char *ip_buf)
     if(ret < 0)
     if(ret < 0)
         return NULL;
         return NULL;
     myaddr = (struct sockaddr_in *)&(temp.ifr_addr);
     myaddr = (struct sockaddr_in *)&(temp.ifr_addr);
-    strcpy(ip_buf, inet_ntoa(myaddr->sin_addr));
+    strcpy(ip_buf, (char*)inet_ntoa(myaddr->sin_addr));
     return ip_buf;
     return ip_buf;
+}
+
+char* getmac(char *mac_buf)
+{
+    struct ifreq temp;
+    struct sockaddr_in *myaddr;
+    int fd = 0;
+    int ret = -1;
+    strcpy(temp.ifr_name, "eth0");
+    if((fd=socket(AF_INET, SOCK_STREAM, 0))<0)
+    {
+        return NULL;
+    }
+    if(ioctl(fd,SIOCGIFHWADDR,&temp)<0)
+    {
+        printf("Get mac address ioctl fail!\n");
+    }
+    else
+    {
+        sprintf(mac_buf, "%02x:%02x:%02x:%02x:%02x:%02x\n",
+                (unsigned char)temp.ifr_hwaddr.sa_data[0],
+                (unsigned char)temp.ifr_hwaddr.sa_data[1],
+                (unsigned char)temp.ifr_hwaddr.sa_data[2],
+                (unsigned char)temp.ifr_hwaddr.sa_data[3],
+                (unsigned char)temp.ifr_hwaddr.sa_data[4],
+                (unsigned char)temp.ifr_hwaddr.sa_data[5]);
+    }
+    close(fd);
+    return mac_buf;
 }
 }

+ 1 - 0
app/bmc/Api.h

@@ -28,5 +28,6 @@ extern int PDK_FanControl(void);
 
 
 char* getip(char *ip_buf);
 char* getip(char *ip_buf);
 int setip(char *ip);
 int setip(char *ip);
+char* getmac(char *mac_buf);
 
 
 #endif /* __API_H__ */
 #endif /* __API_H__ */

binární
app/bmc/bmc_app


binární
app/bmc/bmc_app.gdb


+ 10 - 5
app/bmc/msghndlr/OemSMMCmds/OemSMMCmds.c

@@ -879,17 +879,22 @@ int SMMExample_7fh( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)
 }
 }
 
 
 /********************** storlead oem command ********************************/
 /********************** storlead oem command ********************************/
-//
+//get MAC
 int SMMExample_80h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
 int SMMExample_80h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
 {
 {
-	return 1;
+	pRes[0] = CC_NORMAL;
+	getip(&pRes[1]);
+	printf("ip: %s\n", &pRes[1]);
+	return 16;
 } 
 } 
 
 
-//
+//get IP
 int SMMExample_81h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
 int SMMExample_81h( uint8_t* pReq, uint8_t ReqLen,  uint8_t* pRes)	
 {
 {
-
-	return 1;
+	pRes[0] = CC_NORMAL;
+	getmac(&pRes[1]);
+	printf("mac: %s\n", &pRes[1]);
+	return 18;
 } 
 } 
 
 
 //GetIPMCCapability
 //GetIPMCCapability

binární
app/goahead-5.1.0/build/linux-arm-static/bin/goahead


binární
app/goahead-5.1.0/build/linux-arm-static/bin/goahead-test


binární
app/goahead-5.1.0/build/linux-arm-static/bin/goahead.gdb


binární
app/goahead-5.1.0/build/linux-arm-static/bin/gopass


binární
app/goahead-5.1.0/build/linux-arm-static/bin/libgo.a


binární
gd32450i-eval.uImage