blob: cb7adebfa2560f9c722d63178b192f3e93d75799 [file] [log] [blame]
/*
==================================================================================
Copyright (c) 2019 AT&T Intellectual Property.
Copyright (c) 2019 Nokia
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================================
*/
package teststub
import (
"strconv"
)
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
type RmrRouteTable struct {
routes []string
meids []string
}
func (rrt *RmrRouteTable) AddRoute(mtype int, src string, subid int, trg string) {
line := "mse|"
line += strconv.FormatInt(int64(mtype), 10)
if len(src) > 0 {
line += "," + src
}
line += "|"
line += strconv.FormatInt(int64(subid), 10)
line += "|"
line += trg
rrt.routes = append(rrt.routes, line)
}
func (rrt *RmrRouteTable) AddMeid(trg string, meids []string) {
line := "mme_ar"
line += "|"
line += trg
line += "|"
for _, str := range meids {
line += " " + str
}
rrt.meids = append(rrt.meids, line)
}
func (rrt *RmrRouteTable) DelMeid(meids []string) {
line := "mme_del"
line += "|"
for _, str := range meids {
line += " " + str
}
rrt.meids = append(rrt.meids, line)
}
func (rrt *RmrRouteTable) GetTable() string {
allrt := "newrt|start\n"
for _, val := range rrt.routes {
allrt += val + "\n"
}
allrt += "newrt|end\n"
if len(rrt.meids) > 0 {
allrt += "meid_map | start\n"
for _, val := range rrt.meids {
allrt += val + "\n"
}
allrt += "meid_map | end | " + strconv.FormatInt(int64(len(rrt.meids)), 10) + "\n"
}
return allrt
}