Skip to content

Commit

Permalink
feat: add support for selecting the default APN per subscriber (magma…
Browse files Browse the repository at this point in the history
…#15453)

* feat: add support for selecting the default APN per subscriber

Signed-off-by: Amr Elsayyad <[email protected]>

* chore: add MAGMA_ROOT env var to VSCode settings

Signed-off-by: Amr Elsayyad <[email protected]>

* fix(ci) ci/cd build fails due to unresolved dependancy in unit test

Adding `psutil` unit caused automated tests to fail due to unrezloved
dependancy in the bazel definition.

Signed-off-by: Jordan Vrtanoski <[email protected]>

---------

Signed-off-by: Amr Elsayyad <[email protected]>
Signed-off-by: Jordan Vrtanoski <[email protected]>
Co-authored-by: Jordan Vrtanoski <[email protected]>
  • Loading branch information
AmrElsayyad and jordanvrtanoski authored Aug 1, 2024
1 parent 58a101a commit 142cc3b
Show file tree
Hide file tree
Showing 21 changed files with 705 additions and 412 deletions.
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"terminal.integrated.env.linux": {
"MAGMA_ROOT": "${workspaceFolder}"
},
"terminal.integrated.env.osx": {
"MAGMA_ROOT": "${workspaceFolder}"
},
"terminal.integrated.env.windows": {
"MAGMA_ROOT": "${workspaceFolder}"
}
}
277 changes: 144 additions & 133 deletions lte/cloud/go/protos/apn.pb.go

Large diffs are not rendered by default.

24 changes: 18 additions & 6 deletions lte/cloud/go/services/lte/obsidian/handlers/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3003,7 +3003,8 @@ func TestListApns(t *testing.T) {
PreemptionVulnerability: swag.Bool(false),
PriorityLevel: swag.Uint32(15),
},
PdnType: 0,
PdnType: 0,
IsDefault: swag.Bool(false),
},
},
{
Expand All @@ -3019,7 +3020,8 @@ func TestListApns(t *testing.T) {
PreemptionVulnerability: swag.Bool(false),
PriorityLevel: swag.Uint32(5),
},
PdnType: 1,
PdnType: 1,
IsDefault: swag.Bool(false),
},
},
}, serdes.Entity)
Expand All @@ -3046,7 +3048,8 @@ func TestListApns(t *testing.T) {
PreemptionVulnerability: swag.Bool(false),
PriorityLevel: swag.Uint32(15),
},
PdnType: 0,
PdnType: 0,
IsDefault: swag.Bool(false),
},
},
"oai.ims": {
Expand All @@ -3062,7 +3065,8 @@ func TestListApns(t *testing.T) {
PreemptionVulnerability: swag.Bool(false),
PriorityLevel: swag.Uint32(5),
},
PdnType: 1,
PdnType: 1,
IsDefault: swag.Bool(false),
},
},
}),
Expand Down Expand Up @@ -3104,7 +3108,8 @@ func TestGetApn(t *testing.T) {
PreemptionVulnerability: swag.Bool(false),
PriorityLevel: swag.Uint32(15),
},
PdnType: 0,
PdnType: 0,
IsDefault: swag.Bool(false),
},
}, serdes.Entity)
assert.NoError(t, err)
Expand All @@ -3129,7 +3134,8 @@ func TestGetApn(t *testing.T) {
PreemptionVulnerability: swag.Bool(false),
PriorityLevel: swag.Uint32(15),
},
PdnType: 0,
PdnType: 0,
IsDefault: swag.Bool(false),
},
},
}
Expand Down Expand Up @@ -3160,6 +3166,7 @@ func TestUpdateApn(t *testing.T) {
PreemptionVulnerability: swag.Bool(false),
PriorityLevel: swag.Uint32(5),
},
IsDefault: swag.Bool(false),
},
}

Expand Down Expand Up @@ -3189,6 +3196,7 @@ func TestUpdateApn(t *testing.T) {
PreemptionVulnerability: swag.Bool(false),
PriorityLevel: swag.Uint32(15),
},
IsDefault: swag.Bool(false),
},
}, serdes.Entity)
assert.NoError(t, err)
Expand Down Expand Up @@ -3241,6 +3249,7 @@ func TestDeleteApn(t *testing.T) {
PreemptionVulnerability: swag.Bool(false),
PriorityLevel: swag.Uint32(15),
},
IsDefault: swag.Bool(false),
},
},
{
Expand All @@ -3256,6 +3265,7 @@ func TestDeleteApn(t *testing.T) {
PreemptionVulnerability: swag.Bool(false),
PriorityLevel: swag.Uint32(5),
},
IsDefault: swag.Bool(false),
},
},
}, serdes.Entity)
Expand Down Expand Up @@ -3289,6 +3299,7 @@ func TestDeleteApn(t *testing.T) {
PreemptionVulnerability: swag.Bool(false),
PriorityLevel: swag.Uint32(5),
},
IsDefault: swag.Bool(false),
},
GraphID: "4",
Version: 0,
Expand Down Expand Up @@ -4408,6 +4419,7 @@ func newAPN(name string) *lteModels.Apn {
MaxBandwidthDl: swag.Uint32(100),
MaxBandwidthUl: swag.Uint32(100),
},
IsDefault: swag.Bool(false),
QosProfile: &lteModels.QosProfile{
ClassID: swag.Int32(9),
PreemptionCapability: swag.Bool(true),
Expand Down

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

4 changes: 4 additions & 0 deletions lte/cloud/go/services/lte/obsidian/models/swagger.v1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2604,6 +2604,10 @@ definitions:
- 2
- 3
description: Value identifier for PDN type (0=IPv4 1=IPv6 2=IPv4v6 3=IPv4orv6)
is_default:
type: boolean
default: false
description: Is this the default APN?

apn_name:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const (
defaultQoSPriorityLevel = 15
defaultQoSPreemptionCapability = true
defaultQoSPreemptionVulnerability = false
defaultIsDefault = false
)

var DefaultAPNVal []byte
Expand All @@ -47,6 +48,7 @@ var defaultAPN = &ApnConfiguration{
PreemptionVulnerability: swag.Bool(defaultQoSPreemptionVulnerability),
PriorityLevel: swag.Uint32(defaultQoSPriorityLevel),
},
IsDefault: swag.Bool(defaultIsDefault),
}

func init() {
Expand All @@ -61,6 +63,9 @@ type ApnConfiguration struct {
// qos profile
// Required: true
QosProfile *QosProfile `json:"qos_profile"`

// is default
IsDefault *bool `json:"is_default,omitempty"`
}

func (m *ApnConfiguration) MarshalBinary() ([]byte, error) {
Expand Down Expand Up @@ -91,7 +96,7 @@ func (m *ApnConfiguration) MustMarshalBinary() []byte {
}

func (m *ApnConfiguration) String() string {
return fmt.Sprintf("{Ambr: %v, QosProfile: %v}", m.Ambr, m.QosProfile)
return fmt.Sprintf("{Ambr: %v, QosProfile: %v, IsDefault: %v}", m.Ambr, m.QosProfile, m.IsDefault)
}

type AggregatedMaximumBitrate struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ def add_to_server(self, server):
s6a_proxy_pb2_grpc.add_S6aProxyServicer_to_server(self, server)

def AuthenticationInformation(self, request, context):
"""
Handle the Authentication Information request.
Retrieves user information from the request, performs authentication operations,
increments success/failure metrics, and logs the outcome.
Returns an Authentication Information Answer message.
Args:
request: AuthenticationInformationRequest message
context: gRPC context
Returns:
AuthenticationInformationAnswer message
"""
print_grpc(request, self._print_grpc_payload, "AIR:")
imsi = request.user_name
aia = s6a_proxy_pb2.AuthenticationInformationAnswer()
Expand Down Expand Up @@ -95,6 +108,17 @@ def AuthenticationInformation(self, request, context):
print_grpc(aia, self._print_grpc_payload, "AIA:")

def UpdateLocation(self, request, context):
"""
Update the location of a subscriber based on the request information.
Args:
self: The object instance.
request: The request object containing user information.
context: The context of the request.
Returns:
s6a_proxy_pb2.UpdateLocationAnswer: The answer containing the updated location information.
"""
print_grpc(request, self._print_grpc_payload, "ULR:")
imsi = request.user_name
ula = s6a_proxy_pb2.UpdateLocationAnswer()
Expand Down Expand Up @@ -124,6 +148,8 @@ def UpdateLocation(self, request, context):
for apn in sub_data.non_3gpp.apn_config:
sec_apn = ula.apn.add()
sec_apn.context_id = context_id
if apn.is_default:
ula.default_context_id = context_id
context_id += 1
sec_apn.service_selection = apn.service_selection
sec_apn.qos_profile.class_id = apn.qos_profile.class_id
Expand Down Expand Up @@ -151,6 +177,17 @@ def UpdateLocation(self, request, context):
return ula

def PurgeUE(self, request, context):
"""
Handle a PurgeUE request.
Args:
self: The class instance.
request: The request object containing information about the PurgeUE request.
context: The context of the RPC call.
Returns:
s6a_proxy_pb2.PurgeUEAnswer: The response containing the result of the PurgeUE operation.
"""
logging.warning(
"Purge request not implemented: %s %s",
request.DESCRIPTOR.full_name, MessageToJson(request),
Expand All @@ -159,10 +196,17 @@ def PurgeUE(self, request, context):
print_grpc(pur, self._print_grpc_payload, "PUR:")
return pur

@staticmethod
def encode_msisdn(msisdn: str) -> bytes:
# Mimic how the MSISDN is encoded in ULA : 3GPP TS 29.329-f10
# For odd length MSISDN pad it with an extra 'F'/'1111'
def encode_msisdn(self, msisdn: str) -> bytes:
"""
Mimic how the MSISDN is encoded in ULA : 3GPP TS 29.329-f10
For odd length MSISDN pad it with an extra 'F'/'1111'
Args:
msisdn: The MSISDN to encode.
Returns:
bytes: The encoded MSISDN.
"""
if len(msisdn) % 2 != 0:
msisdn = msisdn + "F"
result = []
Expand Down
2 changes: 2 additions & 0 deletions lte/gateway/python/magma/subscriberdb/store/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@python_deps//:requirements.bzl", "requirement")
load("@rules_python//python:defs.bzl", "py_library")

py_library(
Expand All @@ -19,6 +20,7 @@ py_library(
":base",
":onready",
"//lte/gateway/python/magma/subscriberdb:sid",
requirement("psutil"),
],
)

Expand Down
Loading

0 comments on commit 142cc3b

Please sign in to comment.