Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hn70ap
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
f4grx
hn70ap
Commits
cb339590
Commit
cb339590
authored
6 years ago
by
f4grx
Browse files
Options
Downloads
Patches
Plain Diff
fix tun initialization
parent
bd9ebb86
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
apps/export/tun.h
+3
-1
3 additions, 1 deletion
apps/export/tun.h
apps/libhn70ap/Makefile
+1
-1
1 addition, 1 deletion
apps/libhn70ap/Makefile
apps/libhn70ap/system.c
+4
-1
4 additions, 1 deletion
apps/libhn70ap/system.c
apps/libhn70ap/tun.c
+29
-4
29 additions, 4 deletions
apps/libhn70ap/tun.c
with
37 additions
and
7 deletions
apps/export/tun.h
+
3
−
1
View file @
cb339590
...
...
@@ -39,7 +39,9 @@
#include
<stdint.h>
#include
<stdbool.h>
int
hn70ap_tun_init
(
void
);
#include
<net/if.h>
int
hn70ap_tun_init
(
char
ifname
[
IFNAMSIZ
]);
#endif
/* HN70AP_SYSTEM_H */
This diff is collapsed.
Click to expand it.
apps/libhn70ap/Makefile
+
1
−
1
View file @
cb339590
...
...
@@ -36,7 +36,7 @@
-include
$(TOPDIR)/Make.defs
ASRCS
=
CSRCS
=
eeprom.c leds.c lcd.c timer.c system.c radio.c
CSRCS
=
eeprom.c leds.c lcd.c timer.c system.c radio.c
tun.c
CSRCS
+=
tlv.c crc.c sha256.c hdlc.c
CSRCS
+=
update.c
...
...
This diff is collapsed.
Click to expand it.
apps/libhn70ap/system.c
+
4
−
1
View file @
cb339590
...
...
@@ -43,6 +43,7 @@
#include
<hn70ap/eeprom.h>
#include
<hn70ap/timer.h>
#include
<hn70ap/leds.h>
#include
<hn70ap/lcd.h>
#include
<hn70ap/radio.h>
#include
<hn70ap/tun.h>
...
...
@@ -52,6 +53,7 @@ int hn70ap_system_init(void)
{
int
ret
;
bool
defaults
;
char
tunname
[
IFNAMSIZ
];
if
(
hn70ap_system_initialized
)
{
...
...
@@ -103,7 +105,8 @@ int hn70ap_system_init(void)
syslog
(
LOG_ERR
,
"WARNING: Failed to initialize Radios
\n
"
);
}
ret
=
hn70ap_tun_init
();
strcpy
(
tunname
,
"uhf%d"
);
ret
=
hn70ap_tun_init
(
tunname
);
if
(
ret
!=
0
)
{
syslog
(
LOG_ERR
,
"WARNING: Failed to initialize TUN interface
\n
"
);
...
...
This diff is collapsed.
Click to expand it.
apps/libhn70ap/tun.c
+
29
−
4
View file @
cb339590
...
...
@@ -35,16 +35,41 @@
#include
<nuttx/config.h>
#include
<string.h>
#include
<fcntl.h>
#include
<unistd.h>
int
hn70ap_tun_init
(
void
)
#include
<sys/ioctl.h>
#include
<nuttx/net/tun.h>
#include
<hn70ap/tun.h>
int
hn70ap_tun_init
(
char
ifname
[
IFNAMSIZ
])
{
struct
ifreq
ifr
;
int
errcode
;
int
fd
;
fd
=
open
(
"/dev/tun"
,
O_RDWR
);
if
((
fd
=
open
(
"/dev/tun"
,
O_RDWR
))
<
0
)
{
return
fd
;
}
memset
(
&
ifr
,
0
,
sizeof
(
ifr
));
ifr
.
ifr_flags
=
IFF_TUN
;
if
(
ifname
[
0
])
{
strncpy
(
ifr
.
ifr_name
,
ifname
,
IFNAMSIZ
);
}
if
((
errcode
=
ioctl
(
fd
,
TUNSETIFF
,
(
unsigned
long
)
&
ifr
))
<
0
)
{
close
(
fd
);
return
errcode
;
}
close
(
fd
);
return
0
;
return
fd
;
}
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