On Thu, Dec 11, 2003 at 04:41:15PM +0100, Tomislav Sajdl wrote: |I would like to send UDP packets directly from kernel. | |What is the regular way for doing this? Should I manually fill an sk_buff You can create a socket in kernel space by calling: retval = sock_create(PF_INET, SOCK_DGRAM, 0, &sock); the bind operations looks like : addr_in->sin_family=PF_INET; addr_in->sin_port = htons(source_port); addr_in->sin_addr.s_addr = source_address; memset(&(addr_in->sin_zero), '\0', 8); knetlog->addr_in = addr_in; retval = sock->ops->bind(sock, (struct sockaddr *) knetlog->addr_in, sizeof(struct sockaddr)); if you want to enable broadcast: lock_sock(sock->sk); sock->sk->broadcast = 1; release_sock(sock->sk); now, your UDP packet could be sent by: oldfs = get_fs(); set_fs(KERNEL_DS); /* Required to change addr_limit */ retval = sock_sendmsg(&sock, &msg, len); set_fs(oldfs); where msg is an array of char and len is the total number of bytes. I developed a simple module for 2.4.x where a kernel_thread is created to send UDP packets containing the memory usage. Anyone interested can ask me to send the source code of the kernel module. (I apologize for my bad english) -- Daniele. "I could have made money this way, and perhaps amused myself writing code. But I knew that at the end of my career, I would look back on years of building walls to divide people, and feel I had spent my life making the world a worse place." Richard Stallman -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/