blob: af51fed7fbcbdc393a7e41a96c06d9bb60c1be79 [file] [log] [blame]
Matteo Scandolo40e067f2019-10-16 16:59:41 -07001/*
2 * Copyright 2018-present Open Networking Foundation
3
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7
8 * http://www.apache.org/licenses/LICENSE-2.0
9
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package common
18
19import "flag"
20
21type BBSimCliOptions struct {
22 OltID int
23 NumNniPerOlt int
24 NumPonPerOlt int
25 NumOnuPerPon int
26 STag int
27 CTagInit int
Matteo Scandoloc1147092019-10-29 09:38:33 -070028 Auth bool
29 Dhcp bool
Matteo Scandolo40e067f2019-10-16 16:59:41 -070030 ProfileCpu *string
31 LogLevel string
32 LogCaller bool
Matteo Scandoloe33447a2019-10-31 12:38:23 -070033 Delay int
Matteo Scandolo40e067f2019-10-16 16:59:41 -070034}
35
36type BBRCliOptions struct {
37 *BBSimCliOptions
38 BBSimIp string
39 BBSimPort string
40 BBSimApiPort string
Matteo Scandolof5c537e2019-10-28 16:45:57 -070041 LogFile string
Matteo Scandolo40e067f2019-10-16 16:59:41 -070042}
43
44func GetBBSimOpts() *BBSimCliOptions {
45
46 olt_id := flag.Int("olt_id", 0, "Number of OLT devices to be emulated")
47 nni := flag.Int("nni", 1, "Number of NNI ports per OLT device to be emulated")
48 pon := flag.Int("pon", 1, "Number of PON ports per OLT device to be emulated")
49 onu := flag.Int("onu", 1, "Number of ONU devices per PON port to be emulated")
50
Matteo Scandoloc1147092019-10-29 09:38:33 -070051 auth := flag.Bool("auth", false, "Set this flag if you want authentication to start automatically")
52 dhcp := flag.Bool("dhcp", false, "Set this flag if you want DHCP to start automatically")
53
Matteo Scandolo40e067f2019-10-16 16:59:41 -070054 s_tag := flag.Int("s_tag", 900, "S-Tag value")
55 c_tag_init := flag.Int("c_tag", 900, "C-Tag starting value, each ONU will get a sequential one (targeting 1024 ONUs per BBSim instance the range is big enough)")
56
57 profileCpu := flag.String("cpuprofile", "", "write cpu profile to file")
58
59 logLevel := flag.String("logLevel", "debug", "Set the log level (trace, debug, info, warn, error)")
60 logCaller := flag.Bool("logCaller", false, "Whether to print the caller filename or not")
61
Matteo Scandoloe33447a2019-10-31 12:38:23 -070062 dhcpDelay := flag.Int("dhcp_delay", 200, "The delay between ONU DISCOVERY batches in milliseconds (1 ONU per each PON PORT at a time")
63
Matteo Scandolo40e067f2019-10-16 16:59:41 -070064 flag.Parse()
65
66 o := new(BBSimCliOptions)
67
68 o.OltID = int(*olt_id)
69 o.NumNniPerOlt = int(*nni)
70 o.NumPonPerOlt = int(*pon)
71 o.NumOnuPerPon = int(*onu)
72 o.STag = int(*s_tag)
73 o.CTagInit = int(*c_tag_init)
74 o.ProfileCpu = profileCpu
75 o.LogLevel = *logLevel
76 o.LogCaller = *logCaller
Matteo Scandoloc1147092019-10-29 09:38:33 -070077 o.Auth = *auth
78 o.Dhcp = *dhcp
Matteo Scandoloe33447a2019-10-31 12:38:23 -070079 o.Delay = *dhcpDelay
Matteo Scandolo40e067f2019-10-16 16:59:41 -070080
81 return o
82}
83
84func GetBBROpts() BBRCliOptions {
85
86 bbsimIp := flag.String("bbsimIp", "127.0.0.1", "BBSim IP")
87 bbsimPort := flag.String("bbsimPort", "50060", "BBSim Port")
88 bbsimApiPort := flag.String("bbsimApiPort", "50070", "BBSim API Port")
Matteo Scandolof5c537e2019-10-28 16:45:57 -070089 logFile := flag.String("logfile", "", "Log to a file")
Matteo Scandolo40e067f2019-10-16 16:59:41 -070090
91 options := GetBBSimOpts()
92
93 bbrOptions := BBRCliOptions{
94 options,
95 *bbsimIp,
96 *bbsimPort,
97 *bbsimApiPort,
Matteo Scandolof5c537e2019-10-28 16:45:57 -070098 *logFile,
Matteo Scandolo40e067f2019-10-16 16:59:41 -070099 }
100
101 return bbrOptions
102}