Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GNS3_unikernel_testbed
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
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
NGUYEN Do Duc Anh
GNS3_unikernel_testbed
Commits
51ba2345
Commit
51ba2345
authored
8 months ago
by
NGUYEN Do Duc Anh
Browse files
Options
Downloads
Patches
Plain Diff
update listen to public
parent
98ddd4f5
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
simple-IDS/unikernel.ml
+181
-0
181 additions, 0 deletions
simple-IDS/unikernel.ml
with
181 additions
and
0 deletions
simple-IDS/unikernel.ml
+
181
−
0
View file @
51ba2345
...
...
@@ -162,6 +162,87 @@ module Main
()
in
let
output_private5
packet
=
let
len
=
Cstruct
.
length
packet
in
Private_net5
.
write
private_netif5
~
size
:
len
(
fun
b
->
Cstruct
.
blit
packet
0
b
0
len
;
len
)
>|=
function
|
Ok
()
->
()
|
Error
e
->
Log
.
warn
(
fun
f
->
f
"netif write errored %a"
Private_net5
.
pp_error
e
)
;
()
in
let
output_private6
packet
=
let
len
=
Cstruct
.
length
packet
in
Private_net6
.
write
private_netif6
~
size
:
len
(
fun
b
->
Cstruct
.
blit
packet
0
b
0
len
;
len
)
>|=
function
|
Ok
()
->
()
|
Error
e
->
Log
.
warn
(
fun
f
->
f
"netif write errored %a"
Private_net6
.
pp_error
e
)
;
()
in
let
output_private7
packet
=
let
len
=
Cstruct
.
length
packet
in
Private_net7
.
write
private_netif7
~
size
:
len
(
fun
b
->
Cstruct
.
blit
packet
0
b
0
len
;
len
)
>|=
function
|
Ok
()
->
()
|
Error
e
->
Log
.
warn
(
fun
f
->
f
"netif write errored %a"
Private_net7
.
pp_error
e
)
;
()
in
let
output_private8
packet
=
let
len
=
Cstruct
.
length
packet
in
Private_net8
.
write
private_netif8
~
size
:
len
(
fun
b
->
Cstruct
.
blit
packet
0
b
0
len
;
len
)
>|=
function
|
Ok
()
->
()
|
Error
e
->
Log
.
warn
(
fun
f
->
f
"netif write errored %a"
Private_net8
.
pp_error
e
)
;
()
in
let
output_private9
packet
=
let
len
=
Cstruct
.
length
packet
in
Private_net9
.
write
private_netif9
~
size
:
len
(
fun
b
->
Cstruct
.
blit
packet
0
b
0
len
;
len
)
>|=
function
|
Ok
()
->
()
|
Error
e
->
Log
.
warn
(
fun
f
->
f
"netif write errored %a"
Private_net9
.
pp_error
e
)
;
()
in
let
output_private10
packet
=
let
len
=
Cstruct
.
length
packet
in
Private_net10
.
write
private_netif10
~
size
:
len
(
fun
b
->
Cstruct
.
blit
packet
0
b
0
len
;
len
)
>|=
function
|
Ok
()
->
()
|
Error
e
->
Log
.
warn
(
fun
f
->
f
"netif write errored %a"
Private_net10
.
pp_error
e
)
;
()
in
let
output_private11
packet
=
let
len
=
Cstruct
.
length
packet
in
Private_net11
.
write
private_netif11
~
size
:
len
(
fun
b
->
Cstruct
.
blit
packet
0
b
0
len
;
len
)
>|=
function
|
Ok
()
->
()
|
Error
e
->
Log
.
warn
(
fun
f
->
f
"netif write errored %a"
Private_net11
.
pp_error
e
)
;
()
in
let
output_private12
packet
=
let
len
=
Cstruct
.
length
packet
in
Private_net12
.
write
private_netif12
~
size
:
len
(
fun
b
->
Cstruct
.
blit
packet
0
b
0
len
;
len
)
>|=
function
|
Ok
()
->
()
|
Error
e
->
Log
.
warn
(
fun
f
->
f
"netif write errored %a"
Private_net12
.
pp_error
e
)
;
()
in
let
output_private13
packet
=
let
len
=
Cstruct
.
length
packet
in
Private_net13
.
write
private_netif13
~
size
:
len
(
fun
b
->
Cstruct
.
blit
packet
0
b
0
len
;
len
)
>|=
function
|
Ok
()
->
()
|
Error
e
->
Log
.
warn
(
fun
f
->
f
"netif write errored %a"
Private_net13
.
pp_error
e
)
;
()
in
let
output_ether_private4
mac_src
mac_dst
packet
=
Private_ethernet4
.
write
private_ethernet4
~
src
:
mac_src
mac_dst
`IPv4
(
fun
b
->
let
len
=
Cstruct
.
length
packet
in
...
...
@@ -227,6 +308,96 @@ module Main
Lwt
.
return_unit
in
let
listen_public5
=
let
header_size
=
Ethernet
.
Packet
.
sizeof_ethernet
and
input
frame
=
output_private5
frame
in
Public_net5
.
listen
~
header_size
public_netif5
input
>>=
function
|
Error
e
->
Log
.
debug
(
fun
f
->
f
"public5 interface stopped: %a"
Public_net5
.
pp_error
e
);
Lwt
.
return_unit
|
Ok
()
->
Log
.
debug
(
fun
f
->
f
"public5 interface terminated normally"
);
Lwt
.
return_unit
in
let
listen_public6
=
let
header_size
=
Ethernet
.
Packet
.
sizeof_ethernet
and
input
frame
=
output_private6
frame
in
Public_net6
.
listen
~
header_size
public_netif6
input
>>=
function
|
Error
e
->
Log
.
debug
(
fun
f
->
f
"public6 interface stopped: %a"
Public_net6
.
pp_error
e
);
Lwt
.
return_unit
|
Ok
()
->
Log
.
debug
(
fun
f
->
f
"public6 interface terminated normally"
);
Lwt
.
return_unit
in
let
listen_public7
=
let
header_size
=
Ethernet
.
Packet
.
sizeof_ethernet
and
input
frame
=
output_private7
frame
in
Public_net7
.
listen
~
header_size
public_netif7
input
>>=
function
|
Error
e
->
Log
.
debug
(
fun
f
->
f
"public7 interface stopped: %a"
Public_net7
.
pp_error
e
);
Lwt
.
return_unit
|
Ok
()
->
Log
.
debug
(
fun
f
->
f
"public7 interface terminated normally"
);
Lwt
.
return_unit
in
let
listen_public8
=
let
header_size
=
Ethernet
.
Packet
.
sizeof_ethernet
and
input
frame
=
output_private8
frame
in
Public_net8
.
listen
~
header_size
public_netif8
input
>>=
function
|
Error
e
->
Log
.
debug
(
fun
f
->
f
"public8 interface stopped: %a"
Public_net8
.
pp_error
e
);
Lwt
.
return_unit
|
Ok
()
->
Log
.
debug
(
fun
f
->
f
"public8 interface terminated normally"
);
Lwt
.
return_unit
in
let
listen_public9
=
let
header_size
=
Ethernet
.
Packet
.
sizeof_ethernet
and
input
frame
=
output_private9
frame
in
Public_net9
.
listen
~
header_size
public_netif9
input
>>=
function
|
Error
e
->
Log
.
debug
(
fun
f
->
f
"public9 interface stopped: %a"
Public_net9
.
pp_error
e
);
Lwt
.
return_unit
|
Ok
()
->
Log
.
debug
(
fun
f
->
f
"public9 interface terminated normally"
);
Lwt
.
return_unit
in
let
listen_public10
=
let
header_size
=
Ethernet
.
Packet
.
sizeof_ethernet
and
input
frame
=
output_private10
frame
in
Public_net10
.
listen
~
header_size
public_netif10
input
>>=
function
|
Error
e
->
Log
.
debug
(
fun
f
->
f
"public10 interface stopped: %a"
Public_net10
.
pp_error
e
);
Lwt
.
return_unit
|
Ok
()
->
Log
.
debug
(
fun
f
->
f
"public10 interface terminated normally"
);
Lwt
.
return_unit
in
let
listen_public11
=
let
header_size
=
Ethernet
.
Packet
.
sizeof_ethernet
and
input
frame
=
output_private11
frame
in
Public_net11
.
listen
~
header_size
public_netif11
input
>>=
function
|
Error
e
->
Log
.
debug
(
fun
f
->
f
"public11 interface stopped: %a"
Public_net11
.
pp_error
e
);
Lwt
.
return_unit
|
Ok
()
->
Log
.
debug
(
fun
f
->
f
"public11 interface terminated normally"
);
Lwt
.
return_unit
in
let
listen_public12
=
let
header_size
=
Ethernet
.
Packet
.
sizeof_ethernet
and
input
frame
=
output_private12
frame
in
Public_net12
.
listen
~
header_size
public_netif12
input
>>=
function
|
Error
e
->
Log
.
debug
(
fun
f
->
f
"public12 interface stopped: %a"
Public_net12
.
pp_error
e
);
Lwt
.
return_unit
|
Ok
()
->
Log
.
debug
(
fun
f
->
f
"public12 interface terminated normally"
);
Lwt
.
return_unit
in
let
listen_public13
=
let
header_size
=
Ethernet
.
Packet
.
sizeof_ethernet
and
input
frame
=
output_private13
frame
in
Public_net13
.
listen
~
header_size
public_netif13
input
>>=
function
|
Error
e
->
Log
.
debug
(
fun
f
->
f
"public13 interface stopped: %a"
Public_net13
.
pp_error
e
);
Lwt
.
return_unit
|
Ok
()
->
Log
.
debug
(
fun
f
->
f
"public13 interface terminated normally"
);
Lwt
.
return_unit
in
let
listen_private4
=
let
header_size
=
Ethernet
.
Packet
.
sizeof_ethernet
and
input
frame
=
(* Takes an ethernet packet and send it to the relevant callback *)
...
...
@@ -332,6 +503,16 @@ module Main
(* start both listeners, and continue as long as both are working. *)
Lwt
.
pick
[
listen_public4
;
listen_public5
;
listen_public6
;
listen_public7
;
listen_public8
;
listen_public9
;
listen_public10
;
listen_public11
;
listen_public12
;
listen_public13
;
listen_private4
;
listen_private5
;
listen_private6
;
...
...
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