-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Elazar Gershuni <[email protected]>
- Loading branch information
Showing
38 changed files
with
3,287 additions
and
1,346 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
Copyright 2023- IBM Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package connection | ||
|
||
import ( | ||
"github.com/np-guard/models/pkg/netp" | ||
"github.com/np-guard/models/pkg/netset" | ||
) | ||
|
||
type Set = netset.TransportSet | ||
|
||
func NewTCPorUDP(protocol netp.ProtocolString, srcMinP, srcMaxP, dstMinP, dstMaxP int64) *Set { | ||
return netset.NewTCPorUDPTransport(protocol, srcMinP, srcMaxP, dstMinP, dstMaxP) | ||
} | ||
|
||
func AllICMP() *Set { | ||
return netset.AllOrNothingTransport(false, true) | ||
} | ||
|
||
func NewTCPSet() *Set { | ||
return NewTCPorUDP(netp.ProtocolStringTCP, netp.MinPort, netp.MaxPort, netp.MinPort, netp.MaxPort) | ||
} | ||
|
||
func ICMPConnection(icmpType, icmpCode *int64) (*Set, error) { | ||
icmp, err := netp.ICMPFromTypeAndCode64(icmpType, icmpCode) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return netset.NewICMPTransport(icmp), nil | ||
} | ||
|
||
func All() *Set { | ||
return netset.AllTransportSet() | ||
} | ||
|
||
func None() *Set { | ||
return netset.AllOrNothingTransport(false, false) | ||
} |
Oops, something went wrong.