[Feature][S300][task-view-1920][locknet] Implementation of enhanced network locking scheme base

Change-Id: If294dc65523d640481f35cf2cc991286e3bc5f03
diff --git a/lynq/S300/ap/app/zte_comm/zte_locknet/Makefile b/lynq/S300/ap/app/zte_comm/zte_locknet/Makefile
new file mode 100755
index 0000000..b1aed72
--- /dev/null
+++ b/lynq/S300/ap/app/zte_comm/zte_locknet/Makefile
@@ -0,0 +1,43 @@
+#*******************************************************************************
+# include ZTE application makefile
+#*******************************************************************************	
+include $(COMMON_MK)
+
+##############USER COMIZE BEGIN################
+EXEC1 = zte_locknet 
+
+CPU_PUB_ROOT=$(TOPDIR_AP)/../pub
+
+OBJS1 = $(patsubst %.c,%.o,$(wildcard ./src/*.c ))
+                                   
+CFLAGS += -I.
+CFLAGS += -I./inc
+CFLAGS += -I$(zte_app_path)/include
+CFLAGS += -I$(zte_app_path)/zte_comm/at_ctl/inc
+CFLAGS += -I$(zte_lib_path)/libsqlite
+CFLAGS += -I$(LINUX_DIR)
+
+CFLAGS += -I$(CPU_PUB_ROOT)/project/zx297520v3/include/nv
+CFLAGS += -O -Dlinux=1 -DHIGH_SPEED=1
+CFLAGS += -g
+CFLAGS += -g -Werror=implicit-function-declaration
+ 
+LDLIBS  += -lnvram -L$(zte_lib_path)/libnvram
+LDLIBS  += -lsoftap -L$(zte_lib_path)/libsoftap
+LDLIBS  += -latutils -L$(zte_lib_path)/libatutils
+LDLIBS  += -lsqlite -L$(zte_lib_path)/libsqlite
+LDLIBS  += -lsoft_timer -L$(zte_lib_path)/libsoft_timer
+
+LDLIBS  += -lm
+LDLIBS  += -lpthread -L$(zte_lib_path)/libpthread
+LDLIBS  += -lcpnv -L$(zte_lib_path)/libcpnv
+##############USER COMIZE END##################
+
+#*******************************************************************************
+# targets
+#*******************************************************************************
+lib: $(OBJS1)
+	@echo Compiling zte_locknet libraries.
+	
+clean:
+	-rm -f $(OBJS1)
diff --git a/lynq/S300/ap/app/zte_comm/zte_locknet/src/zctrm_locknet_main.c b/lynq/S300/ap/app/zte_comm/zte_locknet/src/zctrm_locknet_main.c
new file mode 100755
index 0000000..ed4968f
--- /dev/null
+++ b/lynq/S300/ap/app/zte_comm/zte_locknet/src/zctrm_locknet_main.c
@@ -0,0 +1,90 @@
+#include <stdio.h>

+#include <unistd.h>

+#include "zctrm_locknet.h"

+

+int sendflag = 0;

+void locknet_msg_proc(MSG_BUF *msg_buf)

+{

+	switch (msg_buf->usMsgCmd) {

+	case MSG_CMD_LOCKLISTAUTH_REQ: 

+		zCtrm_LocknetAuthProc(msg_buf);

+		break;

+	

+	case MSG_CMD_LOCKNETLIST_SET_REQ: 

+		zCtrm_LocknetListSet(msg_buf);

+		break;

+		

+	case MSG_CMD_LOCKNETKEY_REQ: 

+		zCtrm_LocknetKeyProc(msg_buf);

+		break;

+

+	case MSG_CMD_LOCKNETAMTSTATUS_GET_REQ: 

+		zCtrm_LocknetAmtStatus(msg_buf);

+		break;

+

+	case MSG_CMD_LOCKNETDIGEST_GET_REQ:

+		zCtrm_LocknetDigestGet(msg_buf);

+		break;

+

+	case MSG_CMD_LOCKNETSIGN_SET_REQ:

+		zCtrm_LocknetSignSet(msg_buf);

+		break;

+

+	case MSG_CMD_LOCKNETLEVEL_GET_REQ:

+		zCtrm_LocknetLevel(msg_buf);

+		break;

+

+	case MSG_CMD_LOCKNETLIST_GET_REQ:

+		zCtrm_LocknetListGetProc(msg_buf);

+		break;

+		

+	case MSG_CMD_LOCKNETAUTH_REQ:

+		sendflag = 1;

+		zCtrm_makeLocknetAuth(msg_buf);

+		break;

+

+	case MSG_CMD_LOCKNETUNLOCKTIMES_GET_REQ:

+		zCtrm_LocknetUnlockTimes(msg_buf);

+		break;

+		

+	case MSG_CMD_LOCKNETSTATUS_GET_REQ: 

+		zCtrm_LocknetStatus(msg_buf);

+		break;

+	

+	case MSG_CMD_LOCKNETUNLOCK_REQ: 

+		zCtrm_LocknetUnlock(msg_buf);

+		break;

+	case MSG_CMD_ZURDY_LOCKAUTH_REQ:

+		zCtrm_makeLocknetAuth(msg_buf);

+		break;

+	default:

+		break;

+	}

+}

+

+int zte_locknet_main(int argc, char* argv[])

+{

+	int msg_handle = 0;

+	MSG_BUF msg;

+	LONG msg_size =  sizeof(MSG_BUF)-sizeof(LONG);

+	prctl(PR_SET_NAME, "locknet", 0, 0, 0);

+	/* ´´½¨ÏûÏ¢¶ÓÁÐ*/

+	msg_handle = msgget(MODULE_ID_LOCKNET, IPC_CREAT|0600);

+	while(1)

+	{

+		memset(&msg, 0x00, sizeof(MSG_BUF));

+

+		/* »ñÈ¡ÏûÏ¢¶ÓÁÐÏûÏ¢²¢´¦Àí*/

+		if (msgrcv(msg_handle, &msg, msg_size, 0, 0) >= 0)

+		{

+			locknet_msg_proc(&msg); 		   

+		}

+		else

+		{

+			if(errno != EINTR)

+				slog(AT_PRINT,SLOG_ERR,"locknet_main msgrcv errno = %d, errmsg = %s\n", errno,strerror(errno));

+		}

+	}

+

+	return 0;

+}