/* * Copyright (C) 2019 iopsys Software Solutions AB. All rights reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * */ #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("IOPSYS"); 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