attached code is working properly on i386 machine running 2.6.32. but
not working on uml (2.6.32 ).
am i missing something ? or is it a known bug ?
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
# include <linux/sched.h>
# include <linux/netlink.h>
# include <net/sock.h>
# include <net/net_namespace.h>
# define NETLINK_NITRO 17
MODULE_LICENSE("GPL");
static struct sock *nl_sk = NULL;
static void nl_data_ready (struct sk_buff *skb)
{
struct nlmsghdr *nlh = NULL;
if(skb == NULL) {
printk("skb is NULL \n");
return ;
}
nlh = (struct nlmsghdr *)skb->data;
printk(KERN_INFO "%s: received netlink message payload: %s\n", __FUNCTION__,
(char *) NLMSG_DATA(nlh));
}
static void netlink_test()
{
nl_sk = netlink_kernel_create(&init_net,NETLINK_NITRO,0, nl_data_ready,NULL, THIS_MODULE);
}
static int __init my_module_init(void)
{
printk(KERN_INFO "Initializing Netlink Socket");
netlink_test();
return 0;
}
static void __exit my_module_exit(void)
{
printk(KERN_INFO "Goodbye");
sock_release(nl_sk->sk_socket);
}
module_init(my_module_init);
module_exit(my_module_exit);
# include <sys/types.h>
# include <sys/socket.h>
# include <linux/netlink.h>
# include <stdlib.h>
# include <string.h>
# define NETLINK_NITRO 17
# define MAX_PAYLOAD 2048
int main()
{
struct sockaddr_nl s_nladdr, d_nladdr;
struct msghdr msg ;
struct nlmsghdr *nlh=NULL ;
struct iovec iov;
int fd=socket(AF_NETLINK ,SOCK_RAW , NETLINK_NITRO );
/* source address */
memset(&s_nladdr, 0 ,sizeof(s_nladdr));
s_nladdr.nl_family= AF_NETLINK ;
s_nladdr.nl_pad=0;
s_nladdr.nl_pid = getpid();
bind(fd, (struct sockaddr*)&s_nladdr, sizeof(s_nladdr));
/* destination address */
memset(&d_nladdr, 0 ,sizeof(d_nladdr));
d_nladdr.nl_family= AF_NETLINK ;
d_nladdr.nl_pad=0;
d_nladdr.nl_pid = 0; /* destined to kernel */
/* Fill the netlink message header */
nlh = (struct nlmsghdr *)malloc(100);
memset(nlh , 0 , 100);
strcpy(NLMSG_DATA(nlh), " Mr. Kernel, Are you ready ?" );
nlh->nlmsg_len =100;
nlh->nlmsg_pid = getpid();
nlh->nlmsg_flags = 1;
nlh->nlmsg_type = 0;
/*iov structure */
iov.iov_base = (void *)nlh;
iov.iov_len = nlh->nlmsg_len;
/* msg */
memset(&msg,0,sizeof(msg));
msg.msg_name = (void *) &d_nladdr ;
msg.msg_namelen=sizeof(d_nladdr);
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
printf("nlh=%p iov=%p msg=%p \n" , nlh , &iov , &msg);
sendmsg(fd, &msg, 0 );
close(fd);
return (EXIT_SUCCESS);
}
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://p.sf.net/sfu/dev2dev-palm
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel