lib/Linux/Ethtool/Settings.xs

filter: Statementstmt 0.0% 0 / 38 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 52 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« lib/Linux/Ethtool.xs ↑ Summary lib/Linux/Ethtool/WOL.xs »
1 #include <stdlib.h>
2 #include <net/if.h>
3 #include <linux/ethtool.h>
4 #include <linux/sockios.h>
5 #include <string.h>
6  
7 #include "EXTERN.h"
8 #include "perl.h"
9 #include "XSUB.h"
10  
11 #include "ppport.h"
12 #include "ethtool.h"
13  
14 0 static int _do_sset(const char *dev, unsigned int advertising, unsigned int speed, unsigned int duplex, unsigned int port, unsigned int transceiver, unsigned int autoneg)
15 {
16 struct ethtool_cmd cmd;
17 0 cmd.cmd = ETHTOOL_GSET;
18
19 0 ▶ if(!_do_ioctl(dev, &cmd))
Branch: 1 branch
BranchTrueFalseTotal
if(!_do_ioctl(dev, &cmd)) 0 0 0
20 {
21 0 return 0;
22 }
23
24 0 cmd.advertising = advertising;
25 0 ethtool_cmd_speed_set(&cmd, speed);
26 0 cmd.duplex = duplex;
27 0 cmd.port = port;
28 0 cmd.transceiver = transceiver;
29 0 cmd.autoneg = autoneg;
30
31 0 cmd.cmd = ETHTOOL_SSET;
32
33 0 ▶ if(!_do_ioctl(dev, &cmd))
Branch: 1 branch
BranchTrueFalseTotal
if(!_do_ioctl(dev, &cmd)) 0 0 0
34 {
35 0 return 0;
36 }
37
38 0 return 1;
39 }
40  
41 0 static int _do_gset(HV *hash, const char *dev)
42 {
43 struct ethtool_cmd cmd;
44 0 cmd.cmd = ETHTOOL_GSET;
45
46 0 ▶ if(!_do_ioctl(dev, &cmd))
Branch: 1 branch
BranchTrueFalseTotal
if(!_do_ioctl(dev, &cmd)) 0 0 0
47 {
48 0 return 0;
49 }
50
51 0 unsigned int speed = ethtool_cmd_speed(&cmd);
52
53 0 hv_store(hash, "supported", 9, newSVuv(cmd.supported), 0);
54 0 hv_store(hash, "advertising", 11, newSVuv(cmd.advertising), 0);
55 0 hv_store(hash, "speed", 5, newSVuv(speed), 0);
56 0 hv_store(hash, "duplex", 6, newSVuv(cmd.duplex), 0);
57 0 hv_store(hash, "port", 4, newSVuv(cmd.port), 0);
58 0 hv_store(hash, "transceiver", 11, newSVuv(cmd.transceiver), 0);
59 0 hv_store(hash, "autoneg", 7, newSVuv(cmd.autoneg), 0);
60 0 hv_store(hash, "lp_advertising", 14, newSVuv(cmd.lp_advertising), 0);
61
62 0 return 1;
63 }
64  
65 MODULE = Linux::Ethtool::Settings PACKAGE = Linux::Ethtool::Settings
66  
67 int
68 _ethtool_gset(buf, dev)
69 SV *buf
70 const char *dev
71
72 CODE:
73 0 ▶ if(!(SvROK(buf) && SvTYPE(SvRV(buf)) == SVt_PVHV))
Branch: 2 branches
BranchTrueFalseTotal
if(!(SvROK(buf) && SvTYPE(SvRV(buf)) == SVt_PVHV)) 0 0 0
if(!(SvROK(buf) && SvTYPE(SvRV(buf)) == SVt_PVHV)) 0 0 0
74 {
75 0 croak("First argument must be a hashref");
76 }
77 0 ▶ else if(strlen(dev) >= IFNAMSIZ)
Branch: 1 branch
BranchTrueFalseTotal
else if(strlen(dev) >= IFNAMSIZ) 0 0 0
78 {
79 0 errno = ENAMETOOLONG;
80 0 RETVAL = 0;
81 }
82 else{
83 0 RETVAL = _do_gset((HV*)(SvRV(buf)), dev);
84 }
85 OUTPUT:
86 RETVAL
87  
88 int
89 _ethtool_sset(dev, advertising, speed, duplex, port, transceiver, autoneg)
90 const char *dev
91 unsigned int advertising
92 unsigned int speed
93 unsigned int duplex
94 unsigned int port
95 unsigned int transceiver
96 unsigned int autoneg
97
98 CODE:
99 0 ▶ if(strlen(dev) >= IFNAMSIZ)
Branch: 1 branch
BranchTrueFalseTotal
if(strlen(dev) >= IFNAMSIZ) 0 0 0
100 {
101 0 errno = ENAMETOOLONG;
102 0 RETVAL = 0;
103 }
104 else{
105 0 RETVAL = _do_sset(dev, advertising, speed, duplex, port, transceiver, autoneg);
106 }
107 OUTPUT:
108 RETVAL
« lib/Linux/Ethtool.xs ↑ Summary lib/Linux/Ethtool/WOL.xs »