1
- // Copyright 2017 Intel Corporation.
1
+ // Copyright 2017-2019 Intel Corporation.
2
2
// Use of this source code is governed by a BSD-style
3
3
// license that can be found in the LICENSE file.
4
4
5
5
package main
6
6
7
7
import (
8
+ "flag"
9
+ "net"
10
+
8
11
"github.com/intel-go/nff-go/flow"
9
12
"github.com/intel-go/nff-go/packet"
10
13
)
@@ -13,10 +16,23 @@ var l3Rules *packet.L3Rules
13
16
14
17
// Main function for constructing packet processing graph.
15
18
func main () {
19
+ inport := flag .Uint ("inport" , 0 , "Port for receiving packets." )
20
+ numflows := flag .Uint ("numflows" , 5 , "Number of output flows to use. First flow with number zero is used for dropped packets." )
21
+ nostats := flag .Bool ("nostats" , false , "Disable statics HTTP server." )
22
+ flag .Parse ()
23
+
16
24
var err error
25
+ var statsServerAddres * net.TCPAddr = nil
26
+ if ! * nostats {
27
+ // Set up address for stats web server
28
+ statsServerAddres = & net.TCPAddr {
29
+ Port : 8080 ,
30
+ }
31
+ }
32
+
17
33
// Initialize NFF-GO library at 16 cores by default
18
34
config := flow.Config {
19
- CPUList : "0-15" ,
35
+ StatsHTTPAddress : statsServerAddres ,
20
36
}
21
37
flow .CheckFatal (flow .SystemInit (& config ))
22
38
@@ -25,11 +41,11 @@ func main() {
25
41
flow .CheckFatal (err )
26
42
27
43
// Receive packets from zero port. Receive queue will be added automatically.
28
- inputFlow , err := flow .SetReceiver (0 )
44
+ inputFlow , err := flow .SetReceiver (uint16 ( * inport ) )
29
45
flow .CheckFatal (err )
30
46
31
47
// Split packet flow based on ACL.
32
- flowsNumber := uint16 (5 )
48
+ flowsNumber := uint16 (* numflows )
33
49
outputFlows , err := flow .SetSplitter (inputFlow , l3Splitter , uint (flowsNumber ), nil )
34
50
flow .CheckFatal (err )
35
51
0 commit comments