Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
osv
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
Verlässliche Systemsoftware
projects
osv
Commits
cf0ce6ec
Commit
cf0ce6ec
authored
12 years ago
by
Guy Zana
Browse files
Options
Downloads
Patches
Plain Diff
A simple if_alloc, if_free test and backbone for further testing network interface management
parent
b35279a9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bootfs.manifest
+2
-1
2 additions, 1 deletion
bootfs.manifest
build.mak
+3
-1
3 additions, 1 deletion
build.mak
tests/tst-bsd-netdriver.c
+113
-0
113 additions, 0 deletions
tests/tst-bsd-netdriver.c
with
118 additions
and
2 deletions
bootfs.manifest
+
2
−
1
View file @
cf0ce6ec
...
...
@@ -20,8 +20,9 @@
#/tests/tst-ramdisk.so: ./tests/tst-ramdisk.so
#/tests/tst-vblk.so: ./tests/tst-vblk.so
#/tests/tst-bsd-evh.so: ./tests/tst-bsd-evh.so
/tests/tst-bsd-callout.so: ./tests/tst-bsd-callout.so
#
/tests/tst-bsd-callout.so: ./tests/tst-bsd-callout.so
#/tests/tst-bsd-netisr.so: ./tests/tst-bsd-netisr.so
/tests/tst-bsd-netdriver.so: ./tests/tst-bsd-netdriver.so
/testrunner.so: ./tests/testrunner.so
/java/Hello.class: ./tests/hello/Hello.class
/java.so: java/java.so
...
...
This diff is collapsed.
Click to expand it.
build.mak
+
3
−
1
View file @
cf0ce6ec
...
...
@@ -71,7 +71,8 @@ do-sys-includes = $(foreach inc, $(sys-includes), -isystem $(inc))
tests
:=
tests/tst-pthread.so tests/tst-ramdisk.so tests/hello/Hello.class
tests
+=
tests/tst-vblk.so tests/bench/bench.jar
tests
+=
tests/tst-bsd-evh.so tests/tst-bsd-callout.so tests/tst-bsd-netisr.so
tests
+=
tests/tst-bsd-evh.so tests/tst-bsd-callout.so tests/tst-bsd-netisr.so
\
tests/tst-bsd-netdriver.so
tests/hello/Hello.class
:
javabase=tests/hello
...
...
@@ -83,6 +84,7 @@ tests/tst-vblk.so: tests/tst-vblk.o
tests/tst-bsd-evh.so
:
tests/tst-bsd-evh.o
tests/tst-bsd-callout.so
:
tests/tst-bsd-callout.o
tests/tst-bsd-netisr.so
:
tests/tst-bsd-netisr.o
tests/tst-bsd-netdriver.so
:
tests/tst-bsd-netdriver.o
all
:
loader.img loader.bin
...
...
This diff is collapsed.
Click to expand it.
tests/tst-bsd-netdriver.c
0 → 100644
+
113
−
0
View file @
cf0ce6ec
#include
<stdio.h>
#include
<bsd/sys/net/if_var.h>
#include
<bsd/sys/net/if.h>
#include
<bsd/sys/net/if_arp.h>
#include
<bsd/sys/net/ethernet.h>
#include
<bsd/sys/net/if_dl.h>
#include
<bsd/sys/net/if_types.h>
#include
<bsd/sys/netinet/in.h>
#include
<bsd/sys/netinet/in_var.h>
#include
<bsd/sys/sys/sockio.h>
#include
<bsd/sys/sys/socket.h>
/* Test log */
#define TLOG(...) printf(__VA_ARGS__)
/* Global ifnet */
struct
ifnet
*
pifp
;
static
int
lge_ioctl
(
struct
ifnet
*
ifp
,
u_long
command
,
caddr_t
data
)
{
TLOG
(
"lge_ioctl
\n
"
);
return
(
0
);
}
static
void
lge_start
(
struct
ifnet
*
ifp
)
{
TLOG
(
"lge_start
\n
"
);
}
static
void
lge_init
(
void
*
xsc
)
{
TLOG
(
"lge_init
\n
"
);
}
int
create_if
(
void
)
{
u_char
eaddr
[
ETHER_ADDR_LEN
]
=
{
0x11
,
0x22
,
0x33
,
0x44
,
0x55
,
0x66
};
printf
(
"[~] Creating interface!
\n
"
);
pifp
=
if_alloc
(
IFT_ETHER
);
if
(
pifp
==
NULL
)
{
printf
(
"[-] if_alloc() failed!
\n
"
);
return
(
-
1
);
}
if_initname
(
pifp
,
"test-net"
,
0
);
pifp
->
if_mtu
=
ETHERMTU
;
pifp
->
if_softc
=
(
void
*
)
"Driver private softc"
;
pifp
->
if_flags
=
0
/* IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST */
;
pifp
->
if_ioctl
=
lge_ioctl
;
pifp
->
if_start
=
lge_start
;
pifp
->
if_init
=
lge_init
;
pifp
->
if_snd
.
ifq_maxlen
=
2
;
pifp
->
if_capabilities
=
0
/* IFCAP_RXCSUM */
;
pifp
->
if_capenable
=
pifp
->
if_capabilities
;
ether_ifattach
(
pifp
,
eaddr
);
return
(
0
);
}
void
destroy_id
(
void
)
{
/* ether_ifdetach(pifp); */
if_free
(
pifp
);
}
void
set_address
(
void
)
{
struct
sockaddr_in
ia_addr
;
struct
ifaddr
ifa
;
bzero
(
&
ifa
,
sizeof
(
ifa
));
bzero
(
&
ia_addr
,
sizeof
(
ia_addr
));
ifa
.
ifa_addr
=
(
struct
sockaddr
*
)
&
ia_addr
;
ia_addr
.
sin_family
=
AF_INET
;
ia_addr
.
sin_len
=
sizeof
(
struct
sockaddr_in
);
/* FIXME: use inet_addr when we have one */
ia_addr
.
sin_addr
.
s_addr
=
0xAABBCCDD
;
/* This causes the arp module issue a broadcast an arp tell packet
* (Happen only if the interface was already up! */
ether_ioctl
(
pifp
,
SIOCSIFADDR
,
(
caddr_t
)
&
ifa
);
}
int
main
(
void
)
{
TLOG
(
"BSD Net Driver Test
\n
"
);
create_if
();
/*
* Let all domains know about this interface...
* (There are non configured at this moment)
*/
if_attachdomain
(
NULL
);
// set_address();
destroy_id
();
TLOG
(
"BSD Net Driver Test
\n
"
);
return
(
0
);
}
#undef TLOG
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