diff --git a/CMakeLists.txt.user b/CMakeLists.txt.user new file mode 100644 index 00000000..f9b5c939 --- /dev/null +++ b/CMakeLists.txt.user @@ -0,0 +1,273 @@ + + + + + + EnvironmentId + {7cd13185-8f0a-4828-a39b-a90c87177fdb} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + false + true + false + 0 + true + true + 0 + 8 + true + false + 2 + true + true + true + *.md, *.MD, Makefile + false + true + + + + ProjectExplorer.Project.PluginSettings + + + true + false + true + true + true + true + + + 0 + true + + true + true + Builtin.DefaultTidyAndClazy + 2 + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + MinGW 32bit + MinGW 32bit + {322e3fa8-c77b-446b-a0db-2847debf3b82} + 0 + 0 + 0 + + MinSizeRel + -DCMAKE_GENERATOR:STRING=MinGW Makefiles +-DCMAKE_BUILD_TYPE:STRING=MinSizeRel +-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake +-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} +-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} +-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} +-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} + D:/Coding/C/iec61850/libiec61850_angwangiot/libiec61850-build-MinGW_32bit-MinSizeRel + + + + iec61850 + iec61850-shared + + true + Build + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + clean + + true + Build + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Minimum Size Release + CMakeProjectManager.CMakeBuildConfiguration + + 1 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + true + + 2 + + ProjectExplorer.CustomExecutableRunConfiguration + + false + true + false + true + + 1 + + + + ProjectExplorer.Project.Target.1 + + Desktop + MinGW 64bit + MinGW 64bit + {fcdd76d2-4a09-4fb7-ae7a-85dbdec0159b} + 0 + 0 + 0 + + MinSizeRel + -DCMAKE_GENERATOR:STRING=MinGW Makefiles +-DCMAKE_BUILD_TYPE:STRING=MinSizeRel +-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake +-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable} +-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX} +-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C} +-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx} + D:/Coding/C/iec61850/libiec61850_angwangiot/libiec61850-build-MinGW_64bit-MinSizeRel + + + + iec61850 + iec61850-shared + + true + Build + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + clean + + true + Build + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Minimum Size Release + CMakeProjectManager.CMakeBuildConfiguration + + 1 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + true + + 2 + + ProjectExplorer.CustomExecutableRunConfiguration + + false + true + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 2 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + diff --git a/config/stack_config.h b/config/stack_config.h index 2e363644..6375bc4c 100644 --- a/config/stack_config.h +++ b/config/stack_config.h @@ -51,16 +51,25 @@ #define CONFIG_MMS_THREADLESS_STACK 0 /* number of concurrent MMS client connections the server accepts, -1 for no limit */ -#define CONFIG_MAXIMUM_TCP_CLIENT_CONNECTIONS 100 +#define CONFIG_MAXIMUM_TCP_CLIENT_CONNECTIONS -1 + +/* set socket buffer size. 1 -> enable */ +#define CONFIG_SET_SOCKET_BUFSIZE 1 + +/* size (in KB) SOCKET RCVBUF */ +#define CONFIG_SOCKET_RCVBUFSIZE 128 + +/* size (in KB) SOCKET SNDBUF */ +#define CONFIG_SOCKET_SNDBUFSIZE 128 /* activate TCP keep alive mechanism. 1 -> activate */ #define CONFIG_ACTIVATE_TCP_KEEPALIVE 1 /* time (in s) between last message and first keepalive message */ -#define CONFIG_TCP_KEEPALIVE_IDLE 5 +#define CONFIG_TCP_KEEPALIVE_IDLE 20 /* time between subsequent keepalive messages if no ack received */ -#define CONFIG_TCP_KEEPALIVE_INTERVAL 2 +#define CONFIG_TCP_KEEPALIVE_INTERVAL 5 /* number of not missing keepalive responses until socket is considered dead */ #define CONFIG_TCP_KEEPALIVE_CNT 2 diff --git a/config/stack_config.h.cmake b/config/stack_config.h.cmake index eaca7448..cb3ede52 100644 --- a/config/stack_config.h.cmake +++ b/config/stack_config.h.cmake @@ -48,14 +48,23 @@ /* number of concurrent MMS client connections the server accepts, -1 for no limit */ #cmakedefine CONFIG_MAXIMUM_TCP_CLIENT_CONNECTIONS @CONFIG_MAXIMUM_TCP_CLIENT_CONNECTIONS@ +/* set socket buffer size. 1 -> enable */ +#define CONFIG_SET_SOCKET_BUFSIZE 1 + +/* size (in KB) SOCKET RCVBUF */ +#define CONFIG_SOCKET_RCVBUFSIZE 128 + +/* size (in KB) SOCKET SNDBUF */ +#define CONFIG_SOCKET_SNDBUFSIZE 128 + /* activate TCP keep alive mechanism. 1 -> activate */ #cmakedefine01 CONFIG_ACTIVATE_TCP_KEEPALIVE /* time (in s) between last message and first keepalive message */ -#define CONFIG_TCP_KEEPALIVE_IDLE 5 +#define CONFIG_TCP_KEEPALIVE_IDLE 20 /* time between subsequent keepalive messages if no ack received */ -#define CONFIG_TCP_KEEPALIVE_INTERVAL 2 +#define CONFIG_TCP_KEEPALIVE_INTERVAL 5 /* number of not missing keepalive responses until socket is considered dead */ #define CONFIG_TCP_KEEPALIVE_CNT 2 diff --git a/hal/socket/win32/socket_win32.c b/hal/socket/win32/socket_win32.c index 46a40d49..5824ee50 100644 --- a/hal/socket/win32/socket_win32.c +++ b/hal/socket/win32/socket_win32.c @@ -160,6 +160,33 @@ setSocketNonBlocking(Socket self) setsockopt(self->fd, IPPROTO_TCP, TCP_NODELAY, (const char*)&tcpNoDelay, sizeof(int)); } +static void +setSocketBufferSize(Socket self, int rcvBufSize, int sndBufSize) +{ + setsockopt(self->fd, SOL_SOCKET, SO_RCVBUF, (const char*)&rcvBufSize, sizeof(int)); + setsockopt(self->fd, SOL_SOCKET, SO_SNDBUF, (const char*)&sndBufSize, sizeof(int)); +} + + +#ifdef __i386__ +const char* +inet_ntop(int af, const void* src, char* dst, int cnt){ + + struct sockaddr_in srcaddr; + + memset(&srcaddr, 0, sizeof(struct sockaddr_in)); + memcpy(&(srcaddr.sin_addr), src, sizeof(srcaddr.sin_addr)); + + srcaddr.sin_family = af; + if (WSAAddressToString((struct sockaddr*) &srcaddr, sizeof(struct sockaddr_in), 0, dst, (LPDWORD) &cnt) != 0) { + DWORD rv = WSAGetLastError(); + printf("WSAAddressToString() : %d\n",rv); + return NULL; + } + return dst; +} +#endif + static bool prepareAddress(const char *address, int port, struct sockaddr_in *sockaddr) { @@ -266,6 +293,9 @@ TcpServerSocket_create(const char* address, int port) setSocketNonBlocking((Socket)serverSocket); + if(CONFIG_SET_SOCKET_BUFSIZE == 1) + setSocketBufferSize((Socket)serverSocket, CONFIG_SOCKET_RCVBUFSIZE*1024, CONFIG_SOCKET_SNDBUFSIZE*1024); + socketCount++; } else { @@ -297,6 +327,9 @@ ServerSocket_accept(ServerSocket self) setSocketNonBlocking(conSocket); + if(CONFIG_SET_SOCKET_BUFSIZE == 1) + setSocketBufferSize(conSocket, CONFIG_SOCKET_RCVBUFSIZE*1024, CONFIG_SOCKET_SNDBUFSIZE*1024); + if (DEBUG_SOCKET) printf("WIN32_SOCKET: connection accepted\n"); } @@ -414,6 +447,9 @@ Socket_connectAsync(Socket self, const char* address, int port) setSocketNonBlocking(self); + if(CONFIG_SET_SOCKET_BUFSIZE == 1) + setSocketBufferSize(self, CONFIG_SOCKET_RCVBUFSIZE*1024, CONFIG_SOCKET_SNDBUFSIZE*1024); + if (connect(self->fd, (struct sockaddr *) &serverAddress, sizeof(serverAddress)) == SOCKET_ERROR) { if (WSAGetLastError() != WSAEWOULDBLOCK) { closesocket(self->fd); diff --git a/src/mms/iso_mms/client/mms_client_connection.c b/src/mms/iso_mms/client/mms_client_connection.c index e1d5811c..763db960 100644 --- a/src/mms/iso_mms/client/mms_client_connection.c +++ b/src/mms/iso_mms/client/mms_client_connection.c @@ -2106,6 +2106,8 @@ mmsClient_getNameList(MmsConnection self, MmsError *mmsError, err = parameter.err; list = parameter.nameList; moreFollows = parameter.moreFollows; + } else { + moreFollows = false; } Semaphore_destroy(parameter.sem);