Sfoglia il codice sorgente

[Improve][Modularization][Module_PowerSharing]

2022.07.27 / Folus Wen

Actions:
1. Print client IP to log file.

Files:
1. As follow commit history

Image version: D0.00.XX.XXXX.XX
Image checksum: XXXXXXXX

Hardware PWB P/N : XXXXXXX
Hardware Version : XXXXXXX
FolusWen 2 anni fa
parent
commit
f698298ebb
1 ha cambiato i file con 13 aggiunte e 0 eliminazioni
  1. 13 0
      EVSE/Modularization/Module_PowerSharing.c

+ 13 - 0
EVSE/Modularization/Module_PowerSharing.c

@@ -319,6 +319,18 @@ uint16_t checkChargingProfileLimit()
 	return targetMaxCurrent;
 }
 
+void getClientp(int socketFd)
+{
+	char clientip[20];
+	struct sockaddr_in addr;
+	socklen_t addr_size = sizeof(struct sockaddr_in);
+
+	getpeername(socketFd, (struct sockaddr *)&addr, &addr_size);
+	strcpy(clientip, inet_ntoa(addr.sin_addr));
+
+	DEBUG_INFO("Client IP address: %s\n", clientip);
+}
+
 //==========================================
 // Init all share memory
 //==========================================
@@ -822,6 +834,7 @@ int tcpSocketServer(void)
 		fcntl(clientSockFd, F_SETFD, FD_CLOEXEC);
 		DEBUG_INFO("Client connect in.\n");
 		DEBUG_INFO("clientSockFd : %d\n", clientSockFd);
+		getClientp(clientSockFd);
 
 		if(clientSockFd > 0)
 		{