/* kcwmp.c cwmp service client in C -------------------------------------------------------------------------------- cwmp service client Copyright (C) 2011-2012, Inteno, Inc. All Rights Reserved. Any distribution, dissemination, modification, conversion, integral or partial reproduction, can not be made without the prior written permission of Inteno. -------------------------------------------------------------------------------- Author contact information: -------------------------------------------------------------------------------- */ #include #include #include #include #include #include #include #include #include "inc/cwmp_kernel.h" typedef struct kernel_cwmp_input { char **argv; int argc; int handler; struct mutex mutex; wait_queue_head_t thresholdq; } KERNEL_CWMP_INPUT; static struct sock *nl_sk = NULL; static struct kernel_cwmp_input kernel_cwmp_input; MODULE_LICENSE("INTENO"); static void kernel_api_cwmp_value_change_listener(struct sk_buff *skb) { struct nlmsghdr *nlh; int pid; struct sk_buff *skb_out; int msg_size; char *msg; char *recv; int i,res; nlh = (struct nlmsghdr*)skb->data; recv = (char*)nlmsg_data(nlh); if (strcmp(recv,NETLINK_CWMP_ID)!=0) { return; } pid = nlh->nlmsg_pid; /*pid of sending process */ while (kernel_cwmp_input.argc==0) { if ( wait_event_interruptible( kernel_cwmp_input.thresholdq, kernel_cwmp_input.handler)) { return ; } } kernel_cwmp_input.handler = 0; mutex_lock (&(kernel_cwmp_input.mutex)); for (i=0;i<=kernel_cwmp_input.argc;i++) { if (i0) { kernel_cwmp_input.handler = 1; wake_up_interruptible(&(kernel_cwmp_input.thresholdq)); return 1; } mutex_lock (&(kernel_cwmp_input.mutex)); kernel_cwmp_input.argv = kmalloc(count*sizeof(char *),GFP_KERNEL); if (kernel_cwmp_input.argv==NULL) { goto kernel_api_cwmp_error; } va_start(args, count); for (i=0;i