Mod aaa-12 描述:添加配置接收模块的头文件

RCA:
SOL:
修改人:xusaiqun
检视人:xusaiqun

Signed-off-by: xusaiqun <xusaiqun@cmhi.chinamobile.com>
This commit is contained in:
xusaiqun 2019-06-24 02:33:16 -07:00
parent effe617f56
commit 44420ea09e
7 changed files with 77 additions and 20 deletions

View File

@ -0,0 +1,14 @@
#ifndef CFGRCV_KINIT_H
#define CFGRCV_KINIT_H
#include "libnetlink_k.h"
extern int cfgnl_unicast(struct sk_buff *skb, u32 portid);
extern int cfg_msgtype_register( int msgtype,commnl_doit_func doit,
commnl_dumpit_func dumpit,commnl_calcit_func calcit);
extern int cfg_msgtype_unregister(int msgtype);
#endif

View File

@ -187,6 +187,7 @@ int debugfs_pkt_num_stati_witisend(struct netlinkk_cfg *g_nlcfg,
struct nlattr *rta; struct nlattr *rta;
char* load; char* load;
unsigned long fk_type; unsigned long fk_type;
struct netlink_debugfs * tmp_dfs = NULL;
pload = nlmsg_data(nlh); pload = nlmsg_data(nlh);
rta = (struct nlattr *)pload; rta = (struct nlattr *)pload;
@ -204,16 +205,29 @@ int debugfs_pkt_num_stati_witisend(struct netlinkk_cfg *g_nlcfg,
out_nlh = nlmsg_put(out_skb,nlh->nlmsg_pid, nlh->nlmsg_seq, 0x11, length, 0); out_nlh = nlmsg_put(out_skb,nlh->nlmsg_pid, nlh->nlmsg_seq, 0x11, length, 0);
if (!out_nlh) goto failure; if (!out_nlh) goto failure;
nla_put_nohdr(out_skb, length, &(g_nlcfg->dfs)); tmp_dfs = &((msg_process+fk_type)->dfs);
nla_put_nohdr(out_skb, length, &((msg_process+fk_type)->dfs));
#if 0 nla_put_nohdr(out_skb, length, &(g_nlcfg->dfs));
printk("******************************cfg_rev_succ=%d****************\n",g_nlcfg->netlink_dfs.cfg_rev_succ); nla_put_nohdr(out_skb, length, tmp_dfs);
printk("******************************cfg_rev_fail=%d****************\n",g_nlcfg->netlink_dfs.cfg_rev_fail);
printk("******************************pde_rev_succ=%d****************\n",g_nlcfg->netlink_dfs.pde_rev_succ); #if 1
printk("******************************pde_rev_fail=%d****************\n",g_nlcfg->netlink_dfs.pde_rev_fail); printk("netlink total msg stats:\r\n");
printk("******************************pde_pkt_succ=%d****************\n",g_nlcfg->netlink_dfs.pde_pkt_succ); printk(" rev_total = %d\n",g_nlcfg->dfs.rev_total);
printk("******************************pde_pkt_fail=%d****************\n",g_nlcfg->netlink_dfs.pde_pkt_fail); printk(" rev_cb_sucess = %d\n",g_nlcfg->dfs.rev_cb_sucess);
printk(" rev_cb_fail = %d\n",g_nlcfg->dfs.rev_cb_fail);
printk(" rev_drop_total = %d\n",g_nlcfg->dfs.rev_drop_total);
printk(" rev_drop_nodoit = %d\n",g_nlcfg->dfs.rev_drop_nodoit);
printk(" send_succ = %d\n",g_nlcfg->dfs.send_succ);
printk(" send_fail = %d\n",g_nlcfg->dfs.send_fail);
printk("netlink msg stats:\r\n");
printk(" rev_total = %d\n",tmp_dfs->rev_total);
printk(" rev_cb_sucess = %d\n",tmp_dfs->rev_cb_sucess);
printk(" rev_cb_fail = %d\n",tmp_dfs->rev_cb_fail);
printk(" rev_drop_total = %d\n",tmp_dfs->rev_drop_total);
printk(" rev_drop_nodoit = %d\n",tmp_dfs->rev_drop_nodoit);
printk(" send_succ = %d\n",tmp_dfs->send_succ);
printk(" send_fail = %d\n",tmp_dfs->send_fail);
#endif #endif

View File

@ -1,3 +1,6 @@
#ifndef LIBNETLINKK_K_H
#define LIBNETLINKK_K_H
#include <linux/module.h> #include <linux/module.h>
#include <linux/netlink.h> #include <linux/netlink.h>
#include <linux/netfilter.h> #include <linux/netfilter.h>
@ -78,5 +81,5 @@ extern int debugfs_pkt_num_stati_witisend(struct netlinkk_cfg *g_nlcfg,
extern int nf_nlmsg_multicast(struct netlinkk_cfg *g_nlcfg, struct sk_buff *skb); extern int nf_nlmsg_multicast(struct netlinkk_cfg *g_nlcfg, struct sk_buff *skb);
#endif

View File

@ -257,8 +257,15 @@ failure:
} }
int pdeliv_unicast(struct sk_buff *skb, u32 portid)
{
return(commnl_unicast(g_nlcfg.sk, skb, portid));
}
EXPORT_SYMBOL_GPL(pdeliv_msgtype_register); EXPORT_SYMBOL_GPL(pdeliv_msgtype_register);
EXPORT_SYMBOL_GPL(pdeliv_msgtype_unregister); EXPORT_SYMBOL_GPL(pdeliv_msgtype_unregister);
EXPORT_SYMBOL_GPL(pdeliv_unicast);
module_init(pdelivery_init); module_init(pdelivery_init);

View File

@ -0,0 +1,16 @@
#ifndef CFGRCV_KINIT_H
#define CFGRCV_KINIT_H
#include "libnetlink_k.h"
extern int pdeliv_unicast(struct sk_buff *skb, u32 portid);
extern int pdeliv_msgtype_register( int msgtype,commnl_doit_func doit,
commnl_dumpit_func dumpit,commnl_calcit_func calcit);
extern int pdeliv_msgtype_unregister(int msgtype);
#endif

View File

@ -515,7 +515,7 @@ next:
/* check messages from kernel */ /* check messages from kernel */
//nl_dump_ext_ack(h, errfn); //nl_dump_ext_ack(h, errfn);
} else { } else {
errno = -error; //errno = -error;
//if (rtnl->proto != NETLINK_SOCK_DIAG && show_rtnl_err) //if (rtnl->proto != NETLINK_SOCK_DIAG && show_rtnl_err)
//rtnl_talk_error(h, err, errfn); //rtnl_talk_error(h, err, errfn);
@ -533,7 +533,7 @@ next:
if (answer) { if (answer) {
*answer = (struct nlmsghdr *)buf; *answer = (struct nlmsghdr *)buf;
return 0; return 0;/*find the first onegive it to user.*/
} }
fprintf(stderr, "Unexpected reply!!!\n"); fprintf(stderr, "Unexpected reply!!!\n");
@ -587,6 +587,7 @@ int pdeliv_talk(int group,struct nlmsghdr *n, struct nlmsghdr **answer)
return -1; return -1;
} }
printf("pdeliv_talk send msg type=%d,len=%d.\r\n",n->nlmsg_type,n->nlmsg_len);
return(commnl_talk(nl,n,answer)); return(commnl_talk(nl,n,answer));
} }
@ -601,6 +602,7 @@ int commcfg_talk(struct nlmsghdr *n, struct nlmsghdr **answer)
return -1; return -1;
} }
printf("commcfg_talk send msg type=%d,len=%d.\r\n",n->nlmsg_type,n->nlmsg_len);
return(commnl_talk(nl,n,answer)); return(commnl_talk(nl,n,answer));
} }
@ -640,7 +642,7 @@ int conmnl_listen(struct upmnl_handle *nl,
char buf[16384]; char buf[16384];
char cmsgbuf[BUFSIZ]; char cmsgbuf[BUFSIZ];
printf("conmnl_listen begin.\r\n"); //printf("conmnl_listen begin.\r\n");
#if 0 #if 0
if (nl->flags & RTNL_HANDLE_F_LISTEN_ALL_NSID) { if (nl->flags & RTNL_HANDLE_F_LISTEN_ALL_NSID) {
@ -654,7 +656,7 @@ int conmnl_listen(struct upmnl_handle *nl,
struct pdelivnl_ctrl_data ctrl; struct pdelivnl_ctrl_data ctrl;
struct cmsghdr *cmsg; struct cmsghdr *cmsg;
printf("pdelivnl_listen recvmsg....\r\n"); //printf("pdelivnl_listen recvmsg....\r\n");
iov.iov_len = sizeof(buf); iov.iov_len = sizeof(buf);
//status = recvmsg(nl->fd, &msg, MSG_WAITALL); //status = recvmsg(nl->fd, &msg, MSG_WAITALL);
status = recvmsg(nl->fd, &msg, MSG_WAITFORONE); status = recvmsg(nl->fd, &msg, MSG_WAITFORONE);
@ -697,7 +699,7 @@ int conmnl_listen(struct upmnl_handle *nl,
#if 1 #if 1
printf("pdelivnl_listen prase msg:\r\n"); //printf("pdelivnl_listen prase msg:\r\n");
for (h = (struct nlmsghdr *)buf; status >= sizeof(*h); ) { for (h = (struct nlmsghdr *)buf; status >= sizeof(*h); ) {
int err; int err;
int len = h->nlmsg_len; int len = h->nlmsg_len;

View File

@ -1,3 +1,5 @@
#if 1
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
@ -8,7 +10,6 @@
#include "libnetlinku.h" #include "libnetlinku.h"
#include "commuapinl.h" #include "commuapinl.h"
#if 0
static int process_pkt(struct pdelivnl_ctrl_data *ctrl, static int process_pkt(struct pdelivnl_ctrl_data *ctrl,