Re: [bind] How to send UDP packet from kernel?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi (again),


Quoting Daniele Bellucci <bellucda@tiscali.it>:

> 
> |you do it that way:
> |
> |retval = sock->ops->bind(sock, (struct sockaddr *) knetlog->addr_in,
> |sizeof(struct sockaddr)); 
> |
> |
> |whereas I use IPv6 and therefore do so:
> |
> |   
> |struct sockaddr_in6 sin;
> |...
> |error = sock->ops->bind(sock,(struct sockaddr*)&sin,sizeof(sin));	
> 
> i'm sorry but i never played with IPv6 ;(

nm, it doesnt very much difference here. just that the address is a bit bigger ;)

> 
> |my socket works very fine, but I'm wondering if passing sizeof(sin) instead
> |of sizeof(struct sockaddr) is wise. 

My question was more porting the size expected by bind. Is it mandatory
sizeof(struct sockaddr) or sizeof(struct_we_use) ?
I just do like kHTTPd (+ IPv6)

> 
> Why should it be wise?
> 
> |Could it cause some troubles at some point?
> 
> i don't think so.

what does bind() use this size for? if the given size is wrong, wouldnt it fool
some pointers?



> |khttpd might also be used as example of threads and sockets...
> |(from 2.4 if i recall correctly, but has been given up in 2.6)
> 
> Be aware, my kernel module doesn't compile with 2.6.
> 

I'm with 2.4.20
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux