> sysfs is architecture independent.
> 
> Signed-off-by: FUJITA Tomonori <[email protected]>
> ---
>  ryu/services/protocols/vrrp/monitor_linux.py | 40 
> +++-------------------------
>  1 file changed, 4 insertions(+), 36 deletions(-)
> 
> diff --git a/ryu/services/protocols/vrrp/monitor_linux.py 
> b/ryu/services/protocols/vrrp/monitor_linux.py
> index f1b5efb..2c3569e 100644
> --- a/ryu/services/protocols/vrrp/monitor_linux.py
> +++ b/ryu/services/protocols/vrrp/monitor_linux.py
> @@ -14,12 +14,7 @@
>  # See the License for the specific language governing permissions and
>  # limitations under the License.
>  
> -# tested on 64bit linux.
> -# On other platform like 32bit Linux, the structure can be different
> -# due to alignment difference.

have you taken a look at _join_vrrp_group?

YAMAMOTO Takashi

> -
>  import contextlib
> -import fcntl
>  import socket
>  import struct
>  
> @@ -36,9 +31,7 @@ from ryu.services.protocols.vrrp import utils
>  
>  
>  # Those are not defined in socket module
> -IFNAMSIZ = 16
>  SS_MAXSIZE = 128
> -SIOCGIFINDEX = 0x8933   # This is for Linux x64. May differ on other Linux
>  MCAST_JOIN_GROUP = 42
>  MCAST_LEAVE_GROUP = 45
>  PACKET_ADD_MEMBERSHIP = 1
> @@ -48,35 +41,10 @@ SOL_PACKET = 263
>  
>  
>  def if_nametoindex(ifname):
> -    # can the one defined in libc.so be used?
> -    #
> -    # IFNAMSIZE = 16
> -    # struct ifreq {
> -    #     char ifr_name[IFNAMSIZ]; /* Interface name */
> -    #     union {
> -    #         struct sockaddr ifr_addr;
> -    #         struct sockaddr ifr_dstaddr;
> -    #         struct sockaddr ifr_broadaddr;
> -    #         struct sockaddr ifr_netmask;
> -    #         struct sockaddr ifr_hwaddr;
> -    #         short           ifr_flags;
> -    #         int             ifr_ifindex;
> -    #         int             ifr_metric;
> -    #         int             ifr_mtu;
> -    #         struct ifmap    ifr_map;
> -    #         char            ifr_slave[IFNAMSIZ];
> -    #         char            ifr_newname[IFNAMSIZ];
> -    #         char           *ifr_data;
> -    #     };
> -    # };
> -    PACK_STR = '16sI12x'
> -
> -    # get ip address of the given interface
> -    with contextlib.closing(socket.socket(socket.AF_INET,
> -                                          socket.SOCK_DGRAM, 0)) as 
> udp_socket:
> -        ifreq = struct.pack(PACK_STR, ifname, 0)
> -        res = fcntl.ioctl(udp_socket, SIOCGIFINDEX, ifreq)
> -        return struct.unpack(PACK_STR, res)[1]
> +    filename = '/sys/class/net/' + ifname + '/ifindex'
> +    with contextlib.closing(open(filename)) as f:
> +        for line in f:
> +            return int(line)
>  
>  
>  @monitor.VRRPInterfaceMonitor.register(vrrp_event.VRRPInterfaceNetworkDevice)
> -- 
> 1.8.3.4 (Apple Git-47)
> 
> 
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT 
> organizations don't have a clear picture of how application performance 
> affects their revenue. With AppDynamics, you get 100% visibility into your 
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
> _______________________________________________
> Ryu-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ryu-devel

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to