blob: eee91cccc97374bb303af994e878de73f6b711f4 [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
33}
34
35type BBRCliOptions struct {
36 *BBSimCliOptions
37 BBSimIp string
38 BBSimPort string
39 BBSimApiPort string
Matteo Scandolof5c537e2019-10-28 16:45:57 -070040 LogFile string
Matteo Scandolo40e067f2019-10-16 16:59:41 -070041}
42
43func GetBBSimOpts() *BBSimCliOptions {
44
45 olt_id := flag.Int("olt_id", 0, "Number of OLT devices to be emulated")
46 nni := flag.Int("nni", 1, "Number of NNI ports per OLT device to be emulated")
47 pon := flag.Int("pon", 1, "Number of PON ports per OLT device to be emulated")
48 onu := flag.Int("onu", 1, "Number of ONU devices per PON port to be emulated")
49
Matteo Scandoloc1147092019-10-29 09:38:33 -070050 auth := flag.Bool("auth", false, "Set this flag if you want authentication to start automatically")
51 dhcp := flag.Bool("dhcp", false, "Set this flag if you want DHCP to start automatically")
52
Matteo Scandolo40e067f2019-10-16 16:59:41 -070053 s_tag := flag.Int("s_tag", 900, "S-Tag value")
54 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)")
55
56 profileCpu := flag.String("cpuprofile", "", "write cpu profile to file")
57
58 logLevel := flag.String("logLevel", "debug", "Set the log level (trace, debug, info, warn, error)")
59 logCaller := flag.Bool("logCaller", false, "Whether to print the caller filename or not")
60
61 flag.Parse()
62
63 o := new(BBSimCliOptions)
64
65 o.OltID = int(*olt_id)
66 o.NumNniPerOlt = int(*nni)
67 o.NumPonPerOlt = int(*pon)
68 o.NumOnuPerPon = int(*onu)
69 o.STag = int(*s_tag)
70 o.CTagInit = int(*c_tag_init)
71 o.ProfileCpu = profileCpu
72 o.LogLevel = *logLevel
73 o.LogCaller = *logCaller
Matteo Scandoloc1147092019-10-29 09:38:33 -070074 o.Auth = *auth
75 o.Dhcp = *dhcp
Matteo Scandolo40e067f2019-10-16 16:59:41 -070076
77 return o
78}
79
80func GetBBROpts() BBRCliOptions {
81
82 bbsimIp := flag.String("bbsimIp", "127.0.0.1", "BBSim IP")
83 bbsimPort := flag.String("bbsimPort", "50060", "BBSim Port")
84 bbsimApiPort := flag.String("bbsimApiPort", "50070", "BBSim API Port")
Matteo Scandolof5c537e2019-10-28 16:45:57 -070085 logFile := flag.String("logfile", "", "Log to a file")
Matteo Scandolo40e067f2019-10-16 16:59:41 -070086
87 options := GetBBSimOpts()
88
89 bbrOptions := BBRCliOptions{
90 options,
91 *bbsimIp,
92 *bbsimPort,
93 *bbsimApiPort,
Matteo Scandolof5c537e2019-10-28 16:45:57 -070094 *logFile,
Matteo Scandolo40e067f2019-10-16 16:59:41 -070095 }
96
97 return bbrOptions
98}