Juha Hyttinen | 5f8ffa0 | 2020-02-06 15:28:59 +0200 | [diff] [blame] | 1 | /* |
| 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 | |
| 20 | package teststub |
| 21 | |
| 22 | import ( |
| 23 | "strconv" |
| 24 | ) |
| 25 | |
| 26 | //----------------------------------------------------------------------------- |
| 27 | // |
| 28 | //----------------------------------------------------------------------------- |
| 29 | |
| 30 | type RmrRouteTable struct { |
Juha Hyttinen | 896c3ac | 2020-02-24 12:49:20 +0200 | [diff] [blame] | 31 | routes []string |
| 32 | meids []string |
Juha Hyttinen | 5f8ffa0 | 2020-02-06 15:28:59 +0200 | [diff] [blame] | 33 | } |
| 34 | |
Juha Hyttinen | 896c3ac | 2020-02-24 12:49:20 +0200 | [diff] [blame] | 35 | func (rrt *RmrRouteTable) AddRoute(mtype int, src string, subid int, trg string) { |
Juha Hyttinen | 5f8ffa0 | 2020-02-06 15:28:59 +0200 | [diff] [blame] | 36 | |
| 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 Hyttinen | 896c3ac | 2020-02-24 12:49:20 +0200 | [diff] [blame] | 46 | rrt.routes = append(rrt.routes, line) |
Juha Hyttinen | 5f8ffa0 | 2020-02-06 15:28:59 +0200 | [diff] [blame] | 47 | } |
| 48 | |
Juha Hyttinen | 896c3ac | 2020-02-24 12:49:20 +0200 | [diff] [blame] | 49 | func (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 | |
| 61 | func (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 | |
| 71 | func (rrt *RmrRouteTable) GetTable() string { |
Juha Hyttinen | 5f8ffa0 | 2020-02-06 15:28:59 +0200 | [diff] [blame] | 72 | allrt := "newrt|start\n" |
Juha Hyttinen | 896c3ac | 2020-02-24 12:49:20 +0200 | [diff] [blame] | 73 | for _, val := range rrt.routes { |
Juha Hyttinen | 5f8ffa0 | 2020-02-06 15:28:59 +0200 | [diff] [blame] | 74 | allrt += val + "\n" |
| 75 | } |
| 76 | allrt += "newrt|end\n" |
Juha Hyttinen | 7348625 | 2020-04-06 15:01:52 +0300 | [diff] [blame^] | 77 | allrt += "meid_map | start\n" |
| 78 | for _, val := range rrt.meids { |
| 79 | allrt += val + "\n" |
Juha Hyttinen | 896c3ac | 2020-02-24 12:49:20 +0200 | [diff] [blame] | 80 | } |
Juha Hyttinen | 7348625 | 2020-04-06 15:01:52 +0300 | [diff] [blame^] | 81 | allrt += "meid_map | end | " + strconv.FormatInt(int64(len(rrt.meids)), 10) + "\n" |
Juha Hyttinen | 5f8ffa0 | 2020-02-06 15:28:59 +0200 | [diff] [blame] | 82 | return allrt |
| 83 | } |