Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
babeld
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
babeld
Commits
209707c6
Commit
209707c6
authored
May 05, 2010
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement kernel_interface_channel.
parent
33d41c95
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
0 deletions
+79
-0
kernel.h
kernel.h
+1
-0
kernel_netlink.c
kernel_netlink.c
+71
-0
kernel_socket.c
kernel_socket.c
+7
-0
No files found.
kernel.h
View file @
209707c6
...
@@ -52,6 +52,7 @@ int kernel_interface_ipv4(const char *ifname, int ifindex,
...
@@ -52,6 +52,7 @@ int kernel_interface_ipv4(const char *ifname, int ifindex,
unsigned
char
*
addr_r
);
unsigned
char
*
addr_r
);
int
kernel_interface_mtu
(
const
char
*
ifname
,
int
ifindex
);
int
kernel_interface_mtu
(
const
char
*
ifname
,
int
ifindex
);
int
kernel_interface_wireless
(
const
char
*
ifname
,
int
ifindex
);
int
kernel_interface_wireless
(
const
char
*
ifname
,
int
ifindex
);
int
kernel_interface_channel
(
const
char
*
ifname
,
int
ifindex
);
int
kernel_route
(
int
operation
,
const
unsigned
char
*
dest
,
unsigned
short
plen
,
int
kernel_route
(
int
operation
,
const
unsigned
char
*
dest
,
unsigned
short
plen
,
const
unsigned
char
*
gate
,
int
ifindex
,
unsigned
int
metric
,
const
unsigned
char
*
gate
,
int
ifindex
,
unsigned
int
metric
,
const
unsigned
char
*
newgate
,
int
newifindex
,
const
unsigned
char
*
newgate
,
int
newifindex
,
...
...
kernel_netlink.c
View file @
209707c6
...
@@ -733,6 +733,77 @@ kernel_interface_wireless(const char *ifname, int ifindex)
...
@@ -733,6 +733,77 @@ kernel_interface_wireless(const char *ifname, int ifindex)
return
rc
;
return
rc
;
}
}
/* Sorry for that, but I haven't managed to get <linux/wireless.h>
to include cleanly. */
#define SIOCGIWFREQ 0x8B05
struct
iw_freq
{
int
m
;
short
e
;
unsigned
char
i
;
unsigned
char
flags
;
};
struct
iwreq_subset
{
union
{
char
ifrn_name
[
IFNAMSIZ
];
}
ifr_ifrn
;
union
{
struct
iw_freq
freq
;
}
u
;
};
static
int
freq_to_chan
(
struct
iw_freq
*
freq
)
{
int
m
=
freq
->
m
,
e
=
freq
->
e
;
/* Go figure. */
if
(
e
==
0
&&
m
>
0
&&
m
<
1000
)
return
m
;
if
(
e
==
1
)
{
/* m is in units of 10 Hz, so this encodes 1 MHz */
int
mega
=
100000
;
/* Channels 1 through 13 are 5 MHz apart, with channel 1 at 2412. */
int
step
=
5
*
mega
;
int
c
=
1
+
(
m
-
2412
*
mega
+
step
/
2
)
/
step
;
if
(
c
>=
1
&&
c
<=
13
)
return
c
;
/* Channel 14 is at 2484 MHz */
if
(
c
>=
14
&&
m
<
2484
*
mega
+
step
/
2
)
return
14
;
/* 802.11a channel 36 is at 5180 MHz */
c
=
36
+
(
m
-
5180
*
mega
+
step
/
2
)
/
step
;
if
(
c
>=
34
&&
c
<=
165
)
return
c
;
}
errno
=
ENOENT
;
return
-
1
;
}
int
kernel_interface_channel
(
const
char
*
ifname
,
int
ifindex
)
{
struct
iwreq_subset
iwreq
;
int
rc
;
memset
(
&
iwreq
,
0
,
sizeof
(
iwreq
));
strncpy
(
iwreq
.
ifr_ifrn
.
ifrn_name
,
ifname
,
IFNAMSIZ
);
rc
=
ioctl
(
dgram_socket
,
SIOCGIWFREQ
,
&
iwreq
);
if
(
rc
>=
0
)
return
freq_to_chan
(
&
iwreq
.
u
.
freq
);
else
return
-
1
;
}
int
int
kernel_route
(
int
operation
,
const
unsigned
char
*
dest
,
unsigned
short
plen
,
kernel_route
(
int
operation
,
const
unsigned
char
*
dest
,
unsigned
short
plen
,
const
unsigned
char
*
gate
,
int
ifindex
,
unsigned
int
metric
,
const
unsigned
char
*
gate
,
int
ifindex
,
unsigned
int
metric
,
...
...
kernel_socket.c
View file @
209707c6
...
@@ -306,6 +306,13 @@ kernel_interface_wireless(const char *ifname, int ifindex)
...
@@ -306,6 +306,13 @@ kernel_interface_wireless(const char *ifname, int ifindex)
return
-
1
;
return
-
1
;
}
}
int
kernel_interface_channel
(
const
char
*
ifname
,
int
ifindex
)
{
errno
=
ENOSYS
;
return
-
1
;
}
int
int
kernel_route
(
int
operation
,
const
unsigned
char
*
dest
,
unsigned
short
plen
,
kernel_route
(
int
operation
,
const
unsigned
char
*
dest
,
unsigned
short
plen
,
const
unsigned
char
*
gate
,
int
ifindex
,
unsigned
int
metric
,
const
unsigned
char
*
gate
,
int
ifindex
,
unsigned
int
metric
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment