Re: [RTnet-developers] Monitoring Link Beat
Brought to you by:
bet-frogger,
kiszka
|
From: Jan K. <jan...@we...> - 2006-11-23 16:48:26
|
Jorge Almeida wrote: > Em Quinta, 23 de Novembro de 2006 16:02, escreveu: >> Jorge Almeida wrote: >>> Hello Jan, >>> >>> I'm trying to implement an easy way of monitoring the link beat of on= e=20 > board. >>> What i want is to pass the index of the board, and internaly call the= =20 >>> "do_ioctl" function that should be initialialized in the rtnet_device= =20 > struct=20 >>> for each device. >>> >>> My question is, How do i call the do_ioctl function using the file=20 > descriptor=20 >>> of one socket that is open passing the number of the if_index (or the= =20 >>> interface name)? And how rtnet knows wath device to call? >> IOCTLs on RTDM sockets come in over the related protocol handler, see >> e.g. this one for packet sockets: >> >> > http://www.rts.uni-hannover.de/rtnet/lxr/source/stack/packet/af_packet.= c#L240 >> From there on you can easily go down the chain. >> >> As the IOCTLs are per-socket and not per-device, you have to provide t= he >> information about the address device within the request packet. Do you= >> have some Linux data structure you can reuse for it? Something like fo= r >> SIOCGIFINDEX? >=20 > Yes, i have the struct ifreq used for the SIOCGIFINDEX ioctl. >=20 > I was checking the code and the path is something like this: >=20 > 1 Start at "rt_packet_ioctl" (af_packet.c) checking for a new type of = ioctl=20 > "RTIOC_TYPE_MONITORING" So you are about to define a new IOCTL? Is there no comparable interface existing in Linux? Will this interface be about polling for the current link status? I'm not aware of an official Linux API for this, but this doesn't mean there isn't any. Anyway, do this multiplexing here: http://www.rts.uni-hannover.de/rtnet/lxr/source/stack/socket.c#L225 i.e. in rt_socket_if_ioctl(). That way it will automatically work for all kind of RTnet sockets. >=20 > 2 send it to a new function in socket.c "rt_socket_monitoring_ioctl" >=20 > 3 check the device that we are trying to check the link beat >=20 > 4 send it to the driver (rt_8139too.c) with the do_ioctl pointer. >=20 > In this i only have one doubt: > Where do i return the result? In the same data structure you used for the request? What does it look like so far? >=20 > Maybe the solution: > Build a new struct in RTnet has support of the monitoring IOCTLS > (just for now ) something like >=20 > struct SDeviceMonit > { > int nDeviceIndex; > int nLinkBeat; > } >=20 > This way i can identify the device (nDeviceIndex;) and get the result=20 > (nLinkBeat;). >=20 > Any sugestion??!! In any case, try to do it within struct ifreq. There is e.g. ifru_ivalue used by multiple requests to pass an integer up and down. Jan |