User Tools

Site Tools


ifreq_ethtool

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
ifreq_ethtool [2018/09/02 06:52]
rpjday
ifreq_ethtool [2018/09/02 06:56]
rpjday [Userspace and struct ifreq]
Line 16: Line 16:
         * [[https://​github.com/​torvalds/​linux/​blob/​master/​include/​uapi/​linux/​ethtool.h|ethtool.h]]         * [[https://​github.com/​torvalds/​linux/​blob/​master/​include/​uapi/​linux/​ethtool.h|ethtool.h]]
  
-===== struct ifreq =====+===== Userspace and struct ifreq ===== 
 + 
 +From ethtool'​s ''​internal.h'':​ 
 + 
 +<​code>​ 
 +/* Context for sub-commands */ 
 +struct cmd_context { 
 +        const char *devname; ​   /* net device name */ 
 +        int fd;                 /* socket suitable for ethtool ioctl */ 
 +        struct ifreq ifr;       /* ifreq suitable for ethtool ioctl */ 
 +        int argc;               /* number of arguments to the sub-command */ 
 +        char **argp; ​           /* arguments to the sub-command */ 
 +}; 
 +</​code>​ 
 + 
 +and from ''​ethtool.c'',​ the wrapper for ioctl calls: 
 + 
 +<​code>​ 
 +#ifndef TEST_ETHTOOL 
 +int send_ioctl(struct cmd_context *ctx, void *cmd) 
 +
 +        ctx->​ifr.ifr_data = cmd; 
 +        return ioctl(ctx->​fd,​ SIOCETHTOOL,​ &​ctx->​ifr);​ 
 +
 +#endif 
 +</​code>​
  
 From ''​if.h'':​ From ''​if.h'':​
ifreq_ethtool.txt · Last modified: 2018/09/02 06:56 by rpjday