/
static_rules.go
94 lines (86 loc) · 2.72 KB
/
static_rules.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
* Copyright 2020 The Magma Authors.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*
* 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 integration
import (
"github.com/go-magma/magma/modules/feg/cloud/go/protos"
lteProtos "github.com/go-magma/magma/modules/lte/cloud/go/protos"
"github.com/go-magma/magma/modules/lte/cloud/go/services/policydb/obsidian/models"
"github.com/go-openapi/swag"
)
func getUsageInformation(monitorKey string, quota uint64) *protos.UsageMonitoringInformation {
return &protos.UsageMonitoringInformation{
MonitoringLevel: protos.MonitoringLevel_RuleLevel,
MonitoringKey: []byte(monitorKey),
Octets: &protos.Octets{TotalOctets: quota},
}
}
func getStaticPassAll(ruleID string, monitoringKey string, ratingGroup uint32, trackingType string, priority uint32,
qos *models.FlowQos) *lteProtos.PolicyRule {
rule := &models.PolicyRuleConfig{
FlowList: []*models.FlowDescription{
{
Action: swag.String("PERMIT"),
Match: &models.FlowMatch{
Direction: swag.String("UPLINK"),
IPProto: swag.String("IPPROTO_IP"),
IPV4Dst: "0.0.0.0/0",
IPV4Src: "0.0.0.0/0",
},
},
{
Action: swag.String("PERMIT"),
Match: &models.FlowMatch{
Direction: swag.String("DOWNLINK"),
IPProto: swag.String("IPPROTO_IP"),
IPV4Dst: "0.0.0.0/0",
IPV4Src: "0.0.0.0/0",
},
},
},
Qos: qos,
MonitoringKey: monitoringKey,
Priority: swag.Uint32(priority),
TrackingType: trackingType,
RatingGroup: ratingGroup,
}
return rule.ToProto(ruleID)
}
func getStaticDenyAll(ruleID string, monitoringKey string, ratingGroup uint32, trackingType string, priority uint32) *lteProtos.PolicyRule {
rule := &models.PolicyRuleConfig{
FlowList: []*models.FlowDescription{
{
Action: swag.String("DENY"),
Match: &models.FlowMatch{
Direction: swag.String("UPLINK"),
IPProto: swag.String("IPPROTO_IP"),
IPV4Dst: "0.0.0.0/0",
IPV4Src: "0.0.0.0/0",
},
},
{
Action: swag.String("DENY"),
Match: &models.FlowMatch{
Direction: swag.String("DOWNLINK"),
IPProto: swag.String("IPPROTO_IP"),
IPV4Dst: "0.0.0.0/0",
IPV4Src: "0.0.0.0/0",
},
},
},
MonitoringKey: monitoringKey,
Priority: swag.Uint32(priority),
TrackingType: trackingType,
RatingGroup: ratingGroup,
}
return rule.ToProto(ruleID)
}