Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
senf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wiback
senf
Commits
063b81e6
Commit
063b81e6
authored
16 years ago
by
dw6
Browse files
Options
Downloads
Patches
Plain Diff
completing implementation, adding missing interfaceName(std::string)
parent
1a7bcb65
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Socket/NetdeviceController.cc
+23
-1
23 additions, 1 deletion
Socket/NetdeviceController.cc
Socket/NetdeviceController.hh
+7
-3
7 additions, 3 deletions
Socket/NetdeviceController.hh
with
30 additions
and
4 deletions
Socket/NetdeviceController.cc
+
23
−
1
View file @
063b81e6
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
// Custom includes
// Custom includes
#include
<sys/socket.h>
#include
<sys/socket.h>
#include
<sys/ioctl.h>
#include
<sys/ioctl.h>
#include
<net/if.h>
#include
"../Utils/Exception.hh"
#include
"../Utils/Exception.hh"
#define prefix_
#define prefix_
...
@@ -59,6 +60,22 @@ prefix_ std::string senf::NetdeviceController::interfaceName()
...
@@ -59,6 +60,22 @@ prefix_ std::string senf::NetdeviceController::interfaceName()
return
std
::
string
(
ifr
.
ifr_name
);
return
std
::
string
(
ifr
.
ifr_name
);
}
}
prefix_
void
senf
::
NetdeviceController
::
interfaceName
(
const
std
::
string
&
newname
)
{
if
(
sizeof
(
newname
)
<=
IFNAMSIZ
)
{
struct
ifreq
ifr
;
ifrName
(
ifr
);
strncpy
(
ifr
.
ifr_newname
,
newname
.
c_str
(),
IFNAMSIZ
);
try
{
doIoctl
(
ifr
,
SIOCSIFNAME
);
}
catch
(
senf
::
SystemException
e
)
{
e
<<
"Could not change the interface name. Is the interface really down?"
;
throw
;
}
}
return
;
}
prefix_
senf
::
MACAddress
senf
::
NetdeviceController
::
hardwareAddress
()
prefix_
senf
::
MACAddress
senf
::
NetdeviceController
::
hardwareAddress
()
const
const
{
{
...
@@ -73,7 +90,12 @@ prefix_ void senf::NetdeviceController::hardwareAddress(const MACAddress &newAdd
...
@@ -73,7 +90,12 @@ prefix_ void senf::NetdeviceController::hardwareAddress(const MACAddress &newAdd
ifrName
(
ifr
);
ifrName
(
ifr
);
ifr
.
ifr_hwaddr
.
sa_family
=
1
;
// TODO: lookup named constant; PF_LOCAL ???
ifr
.
ifr_hwaddr
.
sa_family
=
1
;
// TODO: lookup named constant; PF_LOCAL ???
std
::
copy
(
newAddress
.
begin
(),
newAddress
.
end
(),
ifr
.
ifr_hwaddr
.
sa_data
);
std
::
copy
(
newAddress
.
begin
(),
newAddress
.
end
(),
ifr
.
ifr_hwaddr
.
sa_data
);
doIoctl
(
ifr
,
SIOCSIFHWADDR
);
try
{
doIoctl
(
ifr
,
SIOCSIFHWADDR
);
}
catch
(
senf
::
SystemException
e
)
{
e
<<
"Could not change the interface MAC address. Is the interface really down?"
;
throw
;
}
}
}
prefix_
int
senf
::
NetdeviceController
::
mtu
()
prefix_
int
senf
::
NetdeviceController
::
mtu
()
...
...
This diff is collapsed.
Click to expand it.
Socket/NetdeviceController.hh
+
7
−
3
View file @
063b81e6
...
@@ -61,13 +61,17 @@ namespace senf {
...
@@ -61,13 +61,17 @@ namespace senf {
///< return hardware address
///< return hardware address
void
hardwareAddress
(
const
MACAddress
&
newAddress
);
void
hardwareAddress
(
const
MACAddress
&
newAddress
);
///< set hardware address
///< set hardware address
/**< Note, that setting the hardware address is a privileged operation. */
/**< Changes the hardware address of the interface.
Note, that setting the hardware address is a privileged operation. It is only allowed when the interface
is not up. If the interface is up, this call will cause an SystemException to be thrown.*/
std
::
string
interfaceName
()
const
;
std
::
string
interfaceName
()
const
;
///< return interface name
///< return interface name
void
interfaceName
(
const
std
::
string
&
newName
);
void
interfaceName
(
const
std
::
string
&
newName
);
///< set interface name
///< set interface name
/**< Changes the name of the interface. Note, that this is a
/**< Changes the name of the interface.
privileged operation. It is only allowed when the interface is not up. */
Note, that setting the name is a privileged operation. It is only allowed when the interface
is not up. If the interface is up, this call will cause an SystemException to be thrown.*/
int
mtu
()
const
;
///< return the Maximum Transmission Unit
int
mtu
()
const
;
///< return the Maximum Transmission Unit
void
mtu
(
int
new_mtu
);
///< set the Maximum Transmission Unit
void
mtu
(
int
new_mtu
);
///< set the Maximum Transmission Unit
/**< Set the MTU (Maximum Transfer Unit) of the device.
/**< Set the MTU (Maximum Transfer Unit) of the device.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment