Re: Adding new protocol to linux.
Hi Daniel, Some of the Network application use two connections. One connection for control channel to send commands and status update. Other connection is used for real data transfer. For example: FTP. However this needs two socket. TCP talks about out-of-band data transfer using Urgent Pointer flag and Urgent pointer offset in the tcp header. However the data transfer uses the same connection. Regards Manoj Nayak ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Adding new protocol to linux.
Hey everybody, I see that sockets, protocols and network device drivers are pieces of a same puzzle. So after some digging and thinking I'm considering write the driver in such way that it only deals with data link layer, no socket bits. It should sit at 2nd OSI layer and let routing and segmenting for the other layers. This way everything that works with TCP/UDP/IP should work with our little radio transciver. The one million dollars question remains, how do this with only 32bytes MTU and as a bonus, how to spread the communications of several nodes throughout all available channels so that I have less collisions as possible. The first idea that I have was using some connection based protocol where, when someone wants to transfers some N bytes of data, the source makes a request to destination which choses one avaible channel to be used for the transfers. The data is transferred through the selected channel and the connection is closed. The comunication used to open some "connection" would be done on a "control channel" which should be used as few as possible, while the realdata is transmitted on *some of* "data channels". What you guys think? I'll keep working (as much as my sparse time allows me) to get this up and running then I think at details, if someone has interest here is the (not yet finished) code: https://github.com/gkos/nrf24l01p Cheers 2016-03-28 17:08 GMT-03:00 Rami Rosen : > Hi, > Header files under include/net are for kernel internal use. > Header files under include/uapi are for exposure to userspace: > http://lxr.free-electrons.com/source/include/uapi/ > > Regards, > Rami Rosen > http://ramirose.wix.com/ramirosen > > בתאריך 28 במרץ 2016 18:04, "Manoj Nayak" כתב: >> >> > 1) Is it possible to write a new protocol for linux with an out of >> > tree module without modifing socket.h file? >> >> I think this has been already tried in the following code. >> >> http://lxr.free-electrons.com/source/include/net/bluetooth/bluetooth.h#L36 >> >> http://lxr.free-electrons.com/source/include/linux/socket.h#L239 >> >> The challenge is to expose this development specific header file to >> userspace. >> The following document talks about that. >> >> http://kernelnewbies.org/KernelHeaders >> >> Regards >> Manoj Nayak >> >> >> ___ >> Kernelnewbies mailing list >> Kernelnewbies@kernelnewbies.org >> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies >> > > ___ > Kernelnewbies mailing list > Kernelnewbies@kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > -- "Do or do not. There is no try" Yoda Master ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Adding new protocol to linux.
Hi, Header files under include/net are for kernel internal use. Header files under include/uapi are for exposure to userspace: http://lxr.free-electrons.com/source/include/uapi/ Regards, Rami Rosen http://ramirose.wix.com/ramirosen בתאריך 28 במרץ 2016 18:04, "Manoj Nayak" כתב: > > 1) Is it possible to write a new protocol for linux with an out of > > tree module without modifing socket.h file? > > I think this has been already tried in the following code. > > http://lxr.free-electrons.com/source/include/net/bluetooth/bluetooth.h#L36 > > http://lxr.free-electrons.com/source/include/linux/socket.h#L239 > > The challenge is to expose this development specific header file to > userspace. > The following document talks about that. > > http://kernelnewbies.org/KernelHeaders > > Regards > Manoj Nayak > > > ___ > Kernelnewbies mailing list > Kernelnewbies@kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > > ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Adding new protocol to linux.
> 1) Is it possible to write a new protocol for linux with an out of > tree module without modifing socket.h file? I think this has been already tried in the following code. http://lxr.free-electrons.com/source/include/net/bluetooth/bluetooth.h#L36 http://lxr.free-electrons.com/source/include/linux/socket.h#L239 The challenge is to expose this development specific header file to userspace. The following document talks about that. http://kernelnewbies.org/KernelHeaders Regards Manoj Nayak ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Adding new protocol to linux
> 2) Could netlink socket be used to solve this? .. and Netlink is used to transfer information between kernel and user-space processes. It consists of a standard sockets-based interface for user space processes and an internal kernel API for kernel modules. netlink socket does not call dev_queue_xmit(). But here the requirement is to transfer the packet using Nordic's nRF24L01+. AF_PACKET is used to output a raw packet from userspace to a device layer. Even AF_PACKET does that using proto_ops and net_proto_family. Regards Manoj Nayak ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Res: Adding new protocol to linux.
Enviado do meu smartphone BlackBerry 10. Mensagem original De: valdis.kletni...@vt.edu Enviada: sábado, 26 de março de 2016 16:59 Para: Daniel. Cc: kernelnewbies Assunto: Re: Adding new protocol to linux. On Fri, 25 Mar 2016 23:00:48 -0300, "Daniel." said: > Hi everybody, > > I'm planing to write a socket API for Nordic's nRF24L01+ and I was > digging on socket code and find all supported protocols at > include/linux/socket.h with all that #define AF_x y. So my questions > are: > > 1) Is it possible to write a new protocol for linux with an out of > tree module without modifing socket.h file? Rami Rosen gave a good outline of what's needed. But the *first* question you should ask is why a hardware device needs its own socket API rather than re-using an existing one. Basically, if it's an intelligent enough device or SOC, you should be able to get it to talk at least UDP or something. And if it's not that smart, maybe you shouldn't be trying to use sockets to talk to it. So what are the reasons you're doing a new socket API instead of using the existing stuff? Hi Valdis, thanks for the answer. The big problem here is that this piece of hardware has really tiny payloads, only 32 bytes long and is not of standard type. Also I want to add some routing bits, the final goal is to have something like xbee but GPL and cheaper. I thought to use IP at first but the hw payloads are too small, so I think in writing a new protocol module and then I found the socket.h file. Thanks for your reply Cheers ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Adding new protocol to linux.
Thanks Rami, it helps a lot. I'm using SocketCAN as reference for doing this, and I see AF_CAN at socket.h. I saw that protocol family create is called by __sock_create(). Also found that proto_ops bind is used (in the example of the CAN) to find the interface where the communication realy happens.. I am wondering if is possible to achieve my goal with and only with out of tree module. I'm planing to get this merged at main tree anyway, but first I would like to keep it out ou tree until is ready... Cheers, 2016-03-26 8:04 GMT-03:00 Rami Rosen : > Hi Daniel, > > Following are answers for several of your questions: > Adding a protocol in Linux is done first by defining a protocol, and > then registering it with the proto_register() method: > http://lxr.free-electrons.com/source/net/core/sock.c#L2815 > For that you need to define a proto object; for TCPv4 it is done thus, > for example: > http://lxr.free-electrons.com/source/net/ipv4/tcp_ipv4.c#L2315 > > Defining a protocol is not enough, you should also register a protocol > handler for this protocol. > Defining a protocol handler is done first by > defining a packet_type object > of this protocol and then defining a callback for this packet_type. > So for example, for IPv4, a packet_type object called ip_packet_type is > defined in http://lxr.free-electrons.com/source/net/ipv4/af_inet.c#L1677 > > The protocol handler for this packet type is ip_rcv(): > http://lxr.free-electrons.com/source/net/ipv4/ip_input.c#L378 > > This protocol is registered with dev_add_pack(): > http://lxr.free-electrons.com/source/net/core/dev.c#L397 > > So, for example, for IPv4 it is done in inet_init(): > http://lxr.free-electrons.com/source/net/ipv4/af_inet.c#L1791 > > Apart from the protocol handler, a unique Ethernet type should be > defined for this protocol; for IPv4 we have 0x0800 (ETH_P_IP) > http://lxr.free-electrons.com/source/include/uapi/linux/if_ether.h#L46 > and for the ARP protocol we have 0x0806 (ETH_P_ARP), and so on. > > The Ethernet type in the Ethernet header represents the protocol > assigned to this packet. > > The net_device_ops structure is not related, it merely represents the > interface of the of the kernel representation of network device (a > net_device object) to userspace, for userspace operations like > setting the MTU, setting the MAC address, bringing the device up and > down, putting the device in promiscuous mode, and more. > > Hope this helps! > > Regards, > Rami Rosen > http://ramirose.wix.com/ramirosen > > > On 26 March 2016 at 05:00, Daniel. wrote: >> Hi everybody, >> >> I'm planing to write a socket API for Nordic's nRF24L01+ and I was >> digging on socket code and find all supported protocols at >> include/linux/socket.h with all that #define AF_x y. So my questions >> are: >> >> 1) Is it possible to write a new protocol for linux with an out of >> tree module without modifing socket.h file? >> 2) Could netlink socket be used to solve this? .. and >> 3) I saw that there is net_device_ops and proto_ops. How they are tied >> together? >> >> Thanks in advance and >> Best regards, >> >> -- >> "Do or do not. There is no try" >> Yoda Master >> >> ___ >> Kernelnewbies mailing list >> Kernelnewbies@kernelnewbies.org >> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies -- "Do or do not. There is no try" Yoda Master ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Adding new protocol to linux.
On Fri, 25 Mar 2016 23:00:48 -0300, "Daniel." said: > Hi everybody, > > I'm planing to write a socket API for Nordic's nRF24L01+ and I was > digging on socket code and find all supported protocols at > include/linux/socket.h with all that #define AF_x y. So my questions > are: > > 1) Is it possible to write a new protocol for linux with an out of > tree module without modifing socket.h file? Rami Rosen gave a good outline of what's needed. But the *first* question you should ask is why a hardware device needs its own socket API rather than re-using an existing one. Basically, if it's an intelligent enough device or SOC, you should be able to get it to talk at least UDP or something. And if it's not that smart, maybe you shouldn't be trying to use sockets to talk to it. So what are the reasons you're doing a new socket API instead of using the existing stuff? pgp6jFfSlkET0.pgp Description: PGP signature ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Adding new protocol to linux.
Hi Daniel, Following are answers for several of your questions: Adding a protocol in Linux is done first by defining a protocol, and then registering it with the proto_register() method: http://lxr.free-electrons.com/source/net/core/sock.c#L2815 For that you need to define a proto object; for TCPv4 it is done thus, for example: http://lxr.free-electrons.com/source/net/ipv4/tcp_ipv4.c#L2315 Defining a protocol is not enough, you should also register a protocol handler for this protocol. Defining a protocol handler is done first by defining a packet_type object of this protocol and then defining a callback for this packet_type. So for example, for IPv4, a packet_type object called ip_packet_type is defined in http://lxr.free-electrons.com/source/net/ipv4/af_inet.c#L1677 The protocol handler for this packet type is ip_rcv(): http://lxr.free-electrons.com/source/net/ipv4/ip_input.c#L378 This protocol is registered with dev_add_pack(): http://lxr.free-electrons.com/source/net/core/dev.c#L397 So, for example, for IPv4 it is done in inet_init(): http://lxr.free-electrons.com/source/net/ipv4/af_inet.c#L1791 Apart from the protocol handler, a unique Ethernet type should be defined for this protocol; for IPv4 we have 0x0800 (ETH_P_IP) http://lxr.free-electrons.com/source/include/uapi/linux/if_ether.h#L46 and for the ARP protocol we have 0x0806 (ETH_P_ARP), and so on. The Ethernet type in the Ethernet header represents the protocol assigned to this packet. The net_device_ops structure is not related, it merely represents the interface of the of the kernel representation of network device (a net_device object) to userspace, for userspace operations like setting the MTU, setting the MAC address, bringing the device up and down, putting the device in promiscuous mode, and more. Hope this helps! Regards, Rami Rosen http://ramirose.wix.com/ramirosen On 26 March 2016 at 05:00, Daniel. wrote: > Hi everybody, > > I'm planing to write a socket API for Nordic's nRF24L01+ and I was > digging on socket code and find all supported protocols at > include/linux/socket.h with all that #define AF_x y. So my questions > are: > > 1) Is it possible to write a new protocol for linux with an out of > tree module without modifing socket.h file? > 2) Could netlink socket be used to solve this? .. and > 3) I saw that there is net_device_ops and proto_ops. How they are tied > together? > > Thanks in advance and > Best regards, > > -- > "Do or do not. There is no try" > Yoda Master > > ___ > Kernelnewbies mailing list > Kernelnewbies@kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Adding new protocol to linux.
Hi everybody, I'm planing to write a socket API for Nordic's nRF24L01+ and I was digging on socket code and find all supported protocols at include/linux/socket.h with all that #define AF_x y. So my questions are: 1) Is it possible to write a new protocol for linux with an out of tree module without modifing socket.h file? 2) Could netlink socket be used to solve this? .. and 3) I saw that there is net_device_ops and proto_ops. How they are tied together? Thanks in advance and Best regards, -- "Do or do not. There is no try" Yoda Master ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies