[Oisf-devel] [PATCH 1/2] Add interface setting discovery via ioctl

Victor Julien victor at inliniac.net
Mon Nov 29 14:06:18 UTC 2010


Eric Leblond wrote:

> +int GetIfaceMaxHWHeaderLength(char *pcap_dev)
> +{
> +    if ((!strcmp("eth", pcap_dev))
> +            ||
> +            (!strcmp("br", pcap_dev))
> +            ||
> +            (!strcmp("bond", pcap_dev))
> +            ||
> +            (!strcmp("wlan", pcap_dev))
> +            ||
> +            (!strcmp("tun", pcap_dev))
> +            ||
> +            (!strcmp("tap", pcap_dev))
> +            ||
> +            (!strcmp("lo", pcap_dev))
> +       )

Shouldn't strncmp be used here? The pcap_dev is unlikely to be just
"eth", right?

> +int GetIfaceMTU(char *pcap_dev)
> +{
> +#ifdef SIOCGIFMTU
> +    struct ifreq ifr;
> +    int fd;
> +
> +    (void)strncpy(ifr.ifr_name, pcap_dev, sizeof(ifr.ifr_name));

Please use strlcpy (from util-strlcpy.h).

> +int GetIfaceMTU(char *pcap_dev);
> +int GetIfaceMaxPayloadSize(char *pcap_dev);

I'd like a naming like IfaceGetMTU better.

Thanks Eric.

Cheers,
Victor


-- 
---------------------------------------------
Victor Julien
http://www.inliniac.net/
PGP: http://www.inliniac.net/victorjulien.asc
---------------------------------------------




More information about the Oisf-devel mailing list