blob: cb7adebfa2560f9c722d63178b192f3e93d75799 [file] [log] [blame]
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001/*
2==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17==================================================================================
18*/
19
20package teststub
21
22import (
23 "strconv"
24)
25
26//-----------------------------------------------------------------------------
27//
28//-----------------------------------------------------------------------------
29
30type RmrRouteTable struct {
Juha Hyttinen896c3ac2020-02-24 12:49:20 +020031 routes []string
32 meids []string
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020033}
34
Juha Hyttinen896c3ac2020-02-24 12:49:20 +020035func (rrt *RmrRouteTable) AddRoute(mtype int, src string, subid int, trg string) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020036
37 line := "mse|"
38 line += strconv.FormatInt(int64(mtype), 10)
39 if len(src) > 0 {
40 line += "," + src
41 }
42 line += "|"
43 line += strconv.FormatInt(int64(subid), 10)
44 line += "|"
45 line += trg
Juha Hyttinen896c3ac2020-02-24 12:49:20 +020046 rrt.routes = append(rrt.routes, line)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020047}
48
Juha Hyttinen896c3ac2020-02-24 12:49:20 +020049func (rrt *RmrRouteTable) AddMeid(trg string, meids []string) {
50
51 line := "mme_ar"
52 line += "|"
53 line += trg
54 line += "|"
55 for _, str := range meids {
56 line += " " + str
57 }
58 rrt.meids = append(rrt.meids, line)
59}
60
61func (rrt *RmrRouteTable) DelMeid(meids []string) {
62
63 line := "mme_del"
64 line += "|"
65 for _, str := range meids {
66 line += " " + str
67 }
68 rrt.meids = append(rrt.meids, line)
69}
70
71func (rrt *RmrRouteTable) GetTable() string {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020072 allrt := "newrt|start\n"
Juha Hyttinen896c3ac2020-02-24 12:49:20 +020073 for _, val := range rrt.routes {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020074 allrt += val + "\n"
75 }
76 allrt += "newrt|end\n"
Juha Hyttinen896c3ac2020-02-24 12:49:20 +020077 if len(rrt.meids) > 0 {
78 allrt += "meid_map | start\n"
79 for _, val := range rrt.meids {
80 allrt += val + "\n"
81 }
82 allrt += "meid_map | end | " + strconv.FormatInt(int64(len(rrt.meids)), 10) + "\n"
83 }
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020084 return allrt
85}