def get_ifindex(sock, ifname):
    """
    IFNAMSIZ = 16

    struct ifreq {
        union {
            char ifrn_name[IFNAMSIZ];   /* Interface name, e.g. "eth0".  */
        } ifr_ifrn;

        union {
            struct sockaddr ifru_addr;
            struct sockaddr ifru_dstaddr;
            struct sockaddr ifru_broadaddr;
            struct sockaddr ifru_netmask;
            struct sockaddr ifru_hwaddr;
            short int ifru_flags;
            int ifru_ivalue;
            int ifru_mtu;
            struct ifmap ifru_map;
            char ifru_slave[IFNAMSIZ];  /* Just fits the size */
            char ifru_newname[IFNAMSIZ];
            __caddr_t ifru_data;
        } ifr_ifru;
    };
    """
    SIOCGIFINDEX = 0x8933
    ifname, ifindex = unpack('16sI',
            ioctl(sock, SIOCGIFINDEX, pack('16sI', ifname, 0)))
    return ifindex

    IFNAMSIZ = 16

    struct ifreq {
        union {
            char ifrn_name[IFNAMSIZ];   /* Interface name, e.g. "eth0".  */
        } ifr_ifrn;

        union {
            struct sockaddr ifru_addr;
            struct sockaddr ifru_dstaddr;
            struct sockaddr ifru_broadaddr;
            struct sockaddr ifru_netmask;
            struct sockaddr ifru_hwaddr;
            short int ifru_flags;
            int ifru_ivalue;
            int ifru_mtu;
            struct ifmap ifru_map;
            char ifru_slave[IFNAMSIZ];  /* Just fits the size */
            char ifru_newname[IFNAMSIZ];
            __caddr_t ifru_data;
        } ifr_ifru;
    };
    
recipes/Python/577523_EAPMD5_8021X_Supplicant/recipe-577523.py