Skip to content

Commit

Permalink
all: Extract serving relay forwarding limits message
Browse files Browse the repository at this point in the history
  • Loading branch information
adriansmares committed Dec 8, 2023
1 parent 47f3303 commit d6c4cff
Show file tree
Hide file tree
Showing 15 changed files with 2,468 additions and 2,321 deletions.
24 changes: 12 additions & 12 deletions api/ttn/lorawan/v3/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@
- [Message `RelayParameters`](#ttn.lorawan.v3.RelayParameters)
- [Message `ResetAndGetEndDeviceRequest`](#ttn.lorawan.v3.ResetAndGetEndDeviceRequest)
- [Message `ServedRelayParameters`](#ttn.lorawan.v3.ServedRelayParameters)
- [Message `ServingRelayForwardingLimits`](#ttn.lorawan.v3.ServingRelayForwardingLimits)
- [Message `ServingRelayParameters`](#ttn.lorawan.v3.ServingRelayParameters)
- [Message `ServingRelayParameters.ForwardingLimits`](#ttn.lorawan.v3.ServingRelayParameters.ForwardingLimits)
- [Message `ServingRelayParameters.UplinkForwardingRule`](#ttn.lorawan.v3.ServingRelayParameters.UplinkForwardingRule)
- [Message `Session`](#ttn.lorawan.v3.Session)
- [Message `SetEndDeviceRequest`](#ttn.lorawan.v3.SetEndDeviceRequest)
Expand Down Expand Up @@ -4404,6 +4404,16 @@ This is used internally by the Network Server.
| `backoff` | <p>`uint32.lte`: `63`</p> |
| `serving_device_id` | <p>`string.max_len`: `36`</p><p>`string.pattern`: `^[a-z0-9](?:[-]?[a-z0-9]){2,}$`</p> |

### <a name="ttn.lorawan.v3.ServingRelayForwardingLimits">Message `ServingRelayForwardingLimits`</a>

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `reset_behavior` | [`RelayResetLimitCounter`](#ttn.lorawan.v3.RelayResetLimitCounter) | | Reset behavior of the buckets upon limit update. |
| `join_requests` | [`RelayForwardLimits`](#ttn.lorawan.v3.RelayForwardLimits) | | Bucket configuration for join requests. If unset, no individual limits will apply to join requests, but the relay overall limitations will apply. |
| `notifications` | [`RelayForwardLimits`](#ttn.lorawan.v3.RelayForwardLimits) | | Bucket configuration for unknown device notifications. If unset, no individual limits will apply to unknown end device notifications, but the relay overall limitations will still apply. |
| `uplink_messages` | [`RelayForwardLimits`](#ttn.lorawan.v3.RelayForwardLimits) | | Bucket configuration for uplink messages across all served end devices. If unset, no individual limits will apply to uplink messages across all served end devices, but the relay overall limitations will still apply. |
| `overall` | [`RelayForwardLimits`](#ttn.lorawan.v3.RelayForwardLimits) | | Bucket configuration for all relay messages. If unset, no overall limits will apply to the relay, but individual limitations will still apply. |

### <a name="ttn.lorawan.v3.ServingRelayParameters">Message `ServingRelayParameters`</a>

| Field | Type | Label | Description |
Expand All @@ -4412,7 +4422,7 @@ This is used internally by the Network Server.
| `default_channel_index` | [`uint32`](#uint32) | | Index of the default wake on radio channel. |
| `cad_periodicity` | [`RelayCADPeriodicity`](#ttn.lorawan.v3.RelayCADPeriodicity) | | Channel activity detection periodicity. |
| `uplink_forwarding_rules` | [`ServingRelayParameters.UplinkForwardingRule`](#ttn.lorawan.v3.ServingRelayParameters.UplinkForwardingRule) | repeated | Configured uplink forwarding rules. |
| `limits` | [`ServingRelayParameters.ForwardingLimits`](#ttn.lorawan.v3.ServingRelayParameters.ForwardingLimits) | | Configured forwarding limits. If unset, the default value from Network Server configuration will be used. |
| `limits` | [`ServingRelayForwardingLimits`](#ttn.lorawan.v3.ServingRelayForwardingLimits) | | Configured forwarding limits. If unset, the default value from Network Server configuration will be used. |

#### Field Rules

Expand All @@ -4422,16 +4432,6 @@ This is used internally by the Network Server.
| `cad_periodicity` | <p>`enum.defined_only`: `true`</p> |
| `uplink_forwarding_rules` | <p>`repeated.max_items`: `16`</p> |

### <a name="ttn.lorawan.v3.ServingRelayParameters.ForwardingLimits">Message `ServingRelayParameters.ForwardingLimits`</a>

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `reset_behavior` | [`RelayResetLimitCounter`](#ttn.lorawan.v3.RelayResetLimitCounter) | | Reset behavior of the buckets upon limit update. |
| `join_requests` | [`RelayForwardLimits`](#ttn.lorawan.v3.RelayForwardLimits) | | Bucket configuration for join requests. If unset, no individual limits will apply to join requests, but the relay overall limitations will apply. |
| `notifications` | [`RelayForwardLimits`](#ttn.lorawan.v3.RelayForwardLimits) | | Bucket configuration for unknown device notifications. If unset, no individual limits will apply to unknown end device notifications, but the relay overall limitations will still apply. |
| `uplink_messages` | [`RelayForwardLimits`](#ttn.lorawan.v3.RelayForwardLimits) | | Bucket configuration for uplink messages across all served end devices. If unset, no individual limits will apply to uplink messages across all served end devices, but the relay overall limitations will still apply. |
| `overall` | [`RelayForwardLimits`](#ttn.lorawan.v3.RelayForwardLimits) | | Bucket configuration for all relay messages. If unset, no overall limits will apply to the relay, but individual limitations will still apply. |

### <a name="ttn.lorawan.v3.ServingRelayParameters.UplinkForwardingRule">Message `ServingRelayParameters.UplinkForwardingRule`</a>

| Field | Type | Label | Description |
Expand Down
52 changes: 26 additions & 26 deletions api/ttn/lorawan/v3/api.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -19323,31 +19323,6 @@
"default": "ENABLED",
"description": " - ENABLED: No restrictions are in place.\n - WARNING: Warnings are being emitted that the provider will be deprecated in the future.\n - DISABLED: New integrations cannot be set up, and old ones do not start."
},
"ServingRelayParametersForwardingLimits": {
"type": "object",
"properties": {
"reset_behavior": {
"$ref": "#/definitions/v3RelayResetLimitCounter",
"description": "Reset behavior of the buckets upon limit update."
},
"join_requests": {
"$ref": "#/definitions/v3RelayForwardLimits",
"description": "Bucket configuration for join requests.\nIf unset, no individual limits will apply to join requests, but the relay overall limitations will apply."
},
"notifications": {
"$ref": "#/definitions/v3RelayForwardLimits",
"description": "Bucket configuration for unknown device notifications.\nIf unset, no individual limits will apply to unknown end device notifications, but the relay overall\nlimitations will still apply."
},
"uplink_messages": {
"$ref": "#/definitions/v3RelayForwardLimits",
"description": "Bucket configuration for uplink messages across all served end devices.\nIf unset, no individual limits will apply to uplink messages across all served end devices, but the relay\noverall limitations will still apply."
},
"overall": {
"$ref": "#/definitions/v3RelayForwardLimits",
"description": "Bucket configuration for all relay messages.\nIf unset, no overall limits will apply to the relay, but individual limitations will still apply."
}
}
},
"ServingRelayParametersUplinkForwardingRule": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -25909,6 +25884,31 @@
}
}
},
"v3ServingRelayForwardingLimits": {
"type": "object",
"properties": {
"reset_behavior": {
"$ref": "#/definitions/v3RelayResetLimitCounter",
"description": "Reset behavior of the buckets upon limit update."
},
"join_requests": {
"$ref": "#/definitions/v3RelayForwardLimits",
"description": "Bucket configuration for join requests.\nIf unset, no individual limits will apply to join requests, but the relay overall limitations will apply."
},
"notifications": {
"$ref": "#/definitions/v3RelayForwardLimits",
"description": "Bucket configuration for unknown device notifications.\nIf unset, no individual limits will apply to unknown end device notifications, but the relay overall\nlimitations will still apply."
},
"uplink_messages": {
"$ref": "#/definitions/v3RelayForwardLimits",
"description": "Bucket configuration for uplink messages across all served end devices.\nIf unset, no individual limits will apply to uplink messages across all served end devices, but the relay\noverall limitations will still apply."
},
"overall": {
"$ref": "#/definitions/v3RelayForwardLimits",
"description": "Bucket configuration for all relay messages.\nIf unset, no overall limits will apply to the relay, but individual limitations will still apply."
}
}
},
"v3ServingRelayParameters": {
"type": "object",
"properties": {
Expand All @@ -25934,7 +25934,7 @@
"description": "Configured uplink forwarding rules."
},
"limits": {
"$ref": "#/definitions/ServingRelayParametersForwardingLimits",
"$ref": "#/definitions/v3ServingRelayForwardingLimits",
"description": "Configured forwarding limits.\nIf unset, the default value from Network Server configuration will be used."
}
}
Expand Down
44 changes: 25 additions & 19 deletions api/ttn/lorawan/v3/end_device.proto
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,30 @@ message BoolValue {
bool value = 1;
}

message ServingRelayForwardingLimits {
option (thethings.flags.message) = {
select: true,
set: true
};

// Reset behavior of the buckets upon limit update.
RelayResetLimitCounter reset_behavior = 1;
// Bucket configuration for join requests.
// If unset, no individual limits will apply to join requests, but the relay overall limitations will apply.
RelayForwardLimits join_requests = 2;
// Bucket configuration for unknown device notifications.
// If unset, no individual limits will apply to unknown end device notifications, but the relay overall
// limitations will still apply.
RelayForwardLimits notifications = 3;
// Bucket configuration for uplink messages across all served end devices.
// If unset, no individual limits will apply to uplink messages across all served end devices, but the relay
// overall limitations will still apply.
RelayForwardLimits uplink_messages = 4;
// Bucket configuration for all relay messages.
// If unset, no overall limits will apply to the relay, but individual limitations will still apply.
RelayForwardLimits overall = 5;
}

message ServingRelayParameters {
option (thethings.flags.message) = {
select: true,
Expand Down Expand Up @@ -118,27 +142,9 @@ message ServingRelayParameters {
}
// Configured uplink forwarding rules.
repeated UplinkForwardingRule uplink_forwarding_rules = 4 [(validate.rules).repeated.max_items = 16];
message ForwardingLimits {
// Reset behavior of the buckets upon limit update.
RelayResetLimitCounter reset_behavior = 1;
// Bucket configuration for join requests.
// If unset, no individual limits will apply to join requests, but the relay overall limitations will apply.
RelayForwardLimits join_requests = 2;
// Bucket configuration for unknown device notifications.
// If unset, no individual limits will apply to unknown end device notifications, but the relay overall
// limitations will still apply.
RelayForwardLimits notifications = 3;
// Bucket configuration for uplink messages across all served end devices.
// If unset, no individual limits will apply to uplink messages across all served end devices, but the relay
// overall limitations will still apply.
RelayForwardLimits uplink_messages = 4;
// Bucket configuration for all relay messages.
// If unset, no overall limits will apply to the relay, but individual limitations will still apply.
RelayForwardLimits overall = 5;
}
// Configured forwarding limits.
// If unset, the default value from Network Server configuration will be used.
ForwardingLimits limits = 5;
ServingRelayForwardingLimits limits = 5;
}

message ServedRelayParameters {
Expand Down
2 changes: 1 addition & 1 deletion pkg/networkserver/mac/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func relayForwardLimitsFields(limits *ttnpb.RelayForwardLimits, prefix string) [
}
}

func relayConfigureForwardLimitsFields(limits *ttnpb.ServingRelayParameters_ForwardingLimits) log.Fielder {
func relayConfigureForwardLimitsFields(limits *ttnpb.ServingRelayForwardingLimits) log.Fielder {
if limits == nil {
return log.Fields()
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/networkserver/mac/relay_configure_fwd_limit.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
var (
// defaultRelayForwardingLimits is the default relay forward limits, based on the contents of the
// relay specification.
defaultRelayForwardingLimits = &ttnpb.ServingRelayParameters_ForwardingLimits{
defaultRelayForwardingLimits = &ttnpb.ServingRelayForwardingLimits{
JoinRequests: &ttnpb.RelayForwardLimits{
BucketSize: ttnpb.RelayLimitBucketSize_RELAY_LIMIT_BUCKET_SIZE_2,
ReloadRate: 4,
Expand Down Expand Up @@ -142,7 +142,7 @@ func HandleRelayConfigureFwdLimitAns(
// either of these conditions is not true, the current serving parameters will be nil.
return nil
}
currentServing.Limits = &ttnpb.ServingRelayParameters_ForwardingLimits{
currentServing.Limits = &ttnpb.ServingRelayForwardingLimits{
ResetBehavior: req.ResetLimitCounter,
JoinRequests: req.JoinRequestLimits,
Notifications: req.NotifyLimits,
Expand Down
28 changes: 14 additions & 14 deletions pkg/networkserver/mac/relay_configure_fwd_limit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TestDeviceNeedsRelayConfigureFwdLimitReq(t *testing.T) {
Relay: &ttnpb.RelayParameters{
Mode: &ttnpb.RelayParameters_Serving{
Serving: &ttnpb.ServingRelayParameters{
Limits: &ttnpb.ServingRelayParameters_ForwardingLimits{},
Limits: &ttnpb.ServingRelayForwardingLimits{},
},
},
},
Expand All @@ -85,7 +85,7 @@ func TestDeviceNeedsRelayConfigureFwdLimitReq(t *testing.T) {
Relay: &ttnpb.RelayParameters{
Mode: &ttnpb.RelayParameters_Serving{
Serving: &ttnpb.ServingRelayParameters{
Limits: &ttnpb.ServingRelayParameters_ForwardingLimits{
Limits: &ttnpb.ServingRelayForwardingLimits{
JoinRequests: &ttnpb.RelayForwardLimits{
BucketSize: ttnpb.RelayLimitBucketSize_RELAY_LIMIT_BUCKET_SIZE_2,
ReloadRate: 12,
Expand All @@ -111,7 +111,7 @@ func TestDeviceNeedsRelayConfigureFwdLimitReq(t *testing.T) {
Relay: &ttnpb.RelayParameters{
Mode: &ttnpb.RelayParameters_Serving{
Serving: &ttnpb.ServingRelayParameters{
Limits: &ttnpb.ServingRelayParameters_ForwardingLimits{
Limits: &ttnpb.ServingRelayForwardingLimits{
JoinRequests: &ttnpb.RelayForwardLimits{
BucketSize: ttnpb.RelayLimitBucketSize_RELAY_LIMIT_BUCKET_SIZE_2,
ReloadRate: 12,
Expand All @@ -129,7 +129,7 @@ func TestDeviceNeedsRelayConfigureFwdLimitReq(t *testing.T) {
Relay: &ttnpb.RelayParameters{
Mode: &ttnpb.RelayParameters_Serving{
Serving: &ttnpb.ServingRelayParameters{
Limits: &ttnpb.ServingRelayParameters_ForwardingLimits{
Limits: &ttnpb.ServingRelayForwardingLimits{
JoinRequests: &ttnpb.RelayForwardLimits{
BucketSize: ttnpb.RelayLimitBucketSize_RELAY_LIMIT_BUCKET_SIZE_2,
ReloadRate: 12,
Expand Down Expand Up @@ -190,7 +190,7 @@ func TestEnqueueRelayConfigureFwdLimitReq(t *testing.T) {
Relay: &ttnpb.RelayParameters{
Mode: &ttnpb.RelayParameters_Serving{
Serving: &ttnpb.ServingRelayParameters{
Limits: &ttnpb.ServingRelayParameters_ForwardingLimits{},
Limits: &ttnpb.ServingRelayForwardingLimits{},
},
},
},
Expand All @@ -210,7 +210,7 @@ func TestEnqueueRelayConfigureFwdLimitReq(t *testing.T) {
Relay: &ttnpb.RelayParameters{
Mode: &ttnpb.RelayParameters_Serving{
Serving: &ttnpb.ServingRelayParameters{
Limits: &ttnpb.ServingRelayParameters_ForwardingLimits{},
Limits: &ttnpb.ServingRelayForwardingLimits{},
},
},
},
Expand Down Expand Up @@ -248,7 +248,7 @@ func TestEnqueueRelayConfigureFwdLimitReq(t *testing.T) {
Relay: &ttnpb.RelayParameters{
Mode: &ttnpb.RelayParameters_Serving{
Serving: &ttnpb.ServingRelayParameters{
Limits: &ttnpb.ServingRelayParameters_ForwardingLimits{
Limits: &ttnpb.ServingRelayForwardingLimits{
JoinRequests: &ttnpb.RelayForwardLimits{
BucketSize: ttnpb.RelayLimitBucketSize_RELAY_LIMIT_BUCKET_SIZE_2,
ReloadRate: 12,
Expand Down Expand Up @@ -277,7 +277,7 @@ func TestEnqueueRelayConfigureFwdLimitReq(t *testing.T) {
Relay: &ttnpb.RelayParameters{
Mode: &ttnpb.RelayParameters_Serving{
Serving: &ttnpb.ServingRelayParameters{
Limits: &ttnpb.ServingRelayParameters_ForwardingLimits{
Limits: &ttnpb.ServingRelayForwardingLimits{
JoinRequests: &ttnpb.RelayForwardLimits{
BucketSize: ttnpb.RelayLimitBucketSize_RELAY_LIMIT_BUCKET_SIZE_2,
ReloadRate: 12,
Expand Down Expand Up @@ -369,7 +369,7 @@ func TestHandleRelayConfigureFwdLimitAns(t *testing.T) {
Relay: &ttnpb.RelayParameters{
Mode: &ttnpb.RelayParameters_Serving{
Serving: &ttnpb.ServingRelayParameters{
Limits: &ttnpb.ServingRelayParameters_ForwardingLimits{},
Limits: &ttnpb.ServingRelayForwardingLimits{},
},
},
},
Expand All @@ -385,7 +385,7 @@ func TestHandleRelayConfigureFwdLimitAns(t *testing.T) {
Relay: &ttnpb.RelayParameters{
Mode: &ttnpb.RelayParameters_Serving{
Serving: &ttnpb.ServingRelayParameters{
Limits: &ttnpb.ServingRelayParameters_ForwardingLimits{},
Limits: &ttnpb.ServingRelayForwardingLimits{},
},
},
},
Expand All @@ -394,7 +394,7 @@ func TestHandleRelayConfigureFwdLimitAns(t *testing.T) {
Relay: &ttnpb.RelayParameters{
Mode: &ttnpb.RelayParameters_Serving{
Serving: &ttnpb.ServingRelayParameters{
Limits: &ttnpb.ServingRelayParameters_ForwardingLimits{},
Limits: &ttnpb.ServingRelayForwardingLimits{},
},
},
},
Expand Down Expand Up @@ -423,7 +423,7 @@ func TestHandleRelayConfigureFwdLimitAns(t *testing.T) {
Relay: &ttnpb.RelayParameters{
Mode: &ttnpb.RelayParameters_Serving{
Serving: &ttnpb.ServingRelayParameters{
Limits: &ttnpb.ServingRelayParameters_ForwardingLimits{
Limits: &ttnpb.ServingRelayForwardingLimits{
JoinRequests: &ttnpb.RelayForwardLimits{
BucketSize: ttnpb.RelayLimitBucketSize_RELAY_LIMIT_BUCKET_SIZE_2,
ReloadRate: 12,
Expand Down Expand Up @@ -457,7 +457,7 @@ func TestHandleRelayConfigureFwdLimitAns(t *testing.T) {
Relay: &ttnpb.RelayParameters{
Mode: &ttnpb.RelayParameters_Serving{
Serving: &ttnpb.ServingRelayParameters{
Limits: &ttnpb.ServingRelayParameters_ForwardingLimits{
Limits: &ttnpb.ServingRelayForwardingLimits{
JoinRequests: &ttnpb.RelayForwardLimits{
BucketSize: ttnpb.RelayLimitBucketSize_RELAY_LIMIT_BUCKET_SIZE_2,
ReloadRate: 12,
Expand All @@ -475,7 +475,7 @@ func TestHandleRelayConfigureFwdLimitAns(t *testing.T) {
Relay: &ttnpb.RelayParameters{
Mode: &ttnpb.RelayParameters_Serving{
Serving: &ttnpb.ServingRelayParameters{
Limits: &ttnpb.ServingRelayParameters_ForwardingLimits{
Limits: &ttnpb.ServingRelayForwardingLimits{
JoinRequests: &ttnpb.RelayForwardLimits{
BucketSize: ttnpb.RelayLimitBucketSize_RELAY_LIMIT_BUCKET_SIZE_2,
ReloadRate: 12,
Expand Down
2 changes: 1 addition & 1 deletion pkg/ttnpb/end_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (v *RelayForwardLimits) FieldIsZero(p string) bool {
}

// FieldIsZero returns whether path p is zero.
func (v *ServingRelayParameters_ForwardingLimits) FieldIsZero(p string) bool {
func (v *ServingRelayForwardingLimits) FieldIsZero(p string) bool {
if v == nil {
return true
}
Expand Down
Loading

0 comments on commit d6c4cff

Please sign in to comment.