Skip to content

Commit

Permalink
[SDFAB-1110] Add support for multiple application filters (#60)
Browse files Browse the repository at this point in the history
* First commit

* Refactor

* Generate new FARs and Application QERs for each app filter flag

* Refactor

* Refactor

* Refactor

* Refactor

* Remove debug code

* Fix incorrect handling of IDs

* Fix default protocol

* Refactor comment

* Sync changes when modifying sessions

* Use app filters also when modifying sessions to generate the correct IDs

* Fix missing app filters when modifying sessions

* Refactor

* Add precedence in app filter format

* Remove debug code

* Add test cases for app filter parser

* Fix format in app filter flag

* Add check on baseID

* Add validation step

* Remove debug code
  • Loading branch information
EmanueleGallone authored Mar 28, 2022
1 parent 6be4ce2 commit 64474e9
Show file tree
Hide file tree
Showing 7 changed files with 262 additions and 159 deletions.
148 changes: 79 additions & 69 deletions api/pfcpsim.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion api/pfcpsim.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ message CreateSessionRequest {
int32 baseID = 2;
string nodeBAddress = 3;
string ueAddressPool = 4;
string appFilter = 5;
repeated string appFilters = 5;
int32 qfi = 6; // Should be uint8
}

Expand All @@ -26,6 +26,7 @@ message ModifySessionRequest {
string ueAddressPool = 4;
bool bufferFlag = 5;
bool notifyCPFlag = 6;
repeated string appFilters = 7;
}

message ConfigureRequest {
Expand Down
4 changes: 4 additions & 0 deletions internal/pfcpctl/commands/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ func connect() pb.PFCPSimClient {
return pb.NewPFCPSimClient(conn)
}

func validateArgs(args *commonArgs) {

}

func disconnect() {
if conn != nil {
conn.Close()
Expand Down
34 changes: 25 additions & 9 deletions internal/pfcpctl/commands/sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,22 @@ import (
)

type commonArgs struct {
Count int `short:"c" long:"count" default:"1" description:"The number of sessions to create"`
BaseID int `short:"i" long:"baseID" default:"1" description:"The base ID to use"`
UePool string `short:"u" long:"ue-pool" default:"17.0.0.0/24" description:"The UE pool address"`
GnBAddress string `short:"g" long:"gnb-addr" description:"The UE pool address"`
AppFilterString string `short:"a" long:"app-filter" description:"Specify an application filter. Format: '{ip | udp | tcp}:{IPv4 Prefix | any}:{<lower-L4-port>-<upper-L4-port> | any}:{allow | deny}' . e.g. 'udp:10.0.0.0/8:80-88:allow'"`
QFI uint8 `short:"q" long:"qfi" description:"The QFI value for QERs. Max value 64."`
Count int `short:"c" long:"count" default:"1" description:"The number of sessions to create"`
BaseID int `short:"i" long:"baseID" default:"1" description:"The base ID to use"`
UePool string `short:"u" long:"ue-pool" default:"17.0.0.0/24" description:"The UE pool address"`
GnBAddress string `short:"g" long:"gnb-addr" description:"The UE pool address"`
AppFilterString []string `short:"a" long:"app-filter" default:"ip:any:any:allow:100" description:"Specify an application filter. Format: '{ip | udp | tcp}:{IPv4 Prefix | any}:{<lower-L4-port>-<upper-L4-port> | any}:{allow | deny}:{rule-precedence}' . e.g. 'udp:10.0.0.0/8:80-88:allow:100'"`
QFI uint8 `short:"q" long:"qfi" description:"The QFI value for QERs. Max value 64."`
}

func (a *commonArgs) validate() {
if a.BaseID <= 0 {
log.Fatalf("BaseID cannot be 0 or a negative number.")
}

if a.Count <= 0 {
log.Fatalf("Count cannot be 0 or a negative number.")
}
}

type sessionCreate struct {
Expand All @@ -36,8 +46,7 @@ type sessionModify struct {

type sessionDelete struct {
Args struct {
Count int `short:"c" long:"count" default:"1" description:"The number of sessions to create"`
BaseID int `short:"i" long:"baseID" default:"1" description:"The base ID to use"`
commonArgs
}
}

Expand All @@ -59,12 +68,14 @@ func (s *sessionCreate) Execute(args []string) error {
client := connect()
defer disconnect()

s.Args.validate()

res, err := client.CreateSession(context.Background(), &pb.CreateSessionRequest{
Count: int32(s.Args.Count),
BaseID: int32(s.Args.BaseID),
NodeBAddress: s.Args.GnBAddress,
UeAddressPool: s.Args.UePool,
AppFilter: s.Args.AppFilterString,
AppFilters: s.Args.AppFilterString,
Qfi: int32(s.Args.QFI),
})

Expand All @@ -81,13 +92,16 @@ func (s *sessionModify) Execute(args []string) error {
client := connect()
defer disconnect()

s.Args.validate()

res, err := client.ModifySession(context.Background(), &pb.ModifySessionRequest{
Count: int32(s.Args.Count),
BaseID: int32(s.Args.BaseID),
NodeBAddress: s.Args.GnBAddress,
UeAddressPool: s.Args.UePool,
BufferFlag: s.Args.BufferFlag,
NotifyCPFlag: s.Args.NotifyCPFlag,
AppFilters: s.Args.AppFilterString,
})

if err != nil {
Expand All @@ -103,6 +117,8 @@ func (s *sessionDelete) Execute(args []string) error {
client := connect()
defer disconnect()

s.Args.validate()

res, err := client.DeleteSession(context.Background(), &pb.DeleteSessionRequest{
Count: int32(s.Args.Count),
BaseID: int32(s.Args.BaseID),
Expand Down
Loading

0 comments on commit 64474e9

Please sign in to comment.