Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_packages_modules_Connectivity
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LMODroid
platform_packages_modules_Connectivity
Commits
a1eb2e45
Commit
a1eb2e45
authored
1 year ago
by
Xiao Ma
Committed by
Gerrit Code Review
1 year ago
Browse files
Options
Downloads
Plain Diff
Merge "Move the delegated prefix validity check to IaPrefixOption class." into main
parents
22d08770
fac8a337
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
staticlibs/device/com/android/net/module/util/structs/IaPrefixOption.java
+30
-0
30 additions, 0 deletions
...e/com/android/net/module/util/structs/IaPrefixOption.java
with
30 additions
and
0 deletions
staticlibs/device/com/android/net/module/util/structs/IaPrefixOption.java
+
30
−
0
View file @
a1eb2e45
...
...
@@ -18,6 +18,8 @@ package com.android.net.module.util.structs;
import
static
com
.
android
.
net
.
module
.
util
.
NetworkStackConstants
.
DHCP6_OPTION_IAPREFIX
;
import
android.util.Log
;
import
com.android.net.module.util.Struct
;
import
com.android.net.module.util.Struct.Field
;
import
com.android.net.module.util.Struct.Type
;
...
...
@@ -52,6 +54,7 @@ import java.nio.ByteOrder;
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
public
class
IaPrefixOption
extends
Struct
{
private
static
final
String
TAG
=
IaPrefixOption
.
class
.
getSimpleName
();
public
static
final
int
LENGTH
=
25
;
// option length excluding IAprefix-options
@Field
(
order
=
0
,
type
=
Type
.
S16
)
...
...
@@ -77,6 +80,33 @@ public class IaPrefixOption extends Struct {
this
.
prefix
=
prefix
.
clone
();
}
/**
* Check whether or not IA Prefix option in IA_PD option is valid per RFC8415#section-21.22.
*/
public
boolean
isValid
(
int
t2
)
{
if
(
preferred
<
0
||
valid
<
0
)
{
Log
.
w
(
TAG
,
"IA_PD option with invalid lifetime, preferred lifetime "
+
preferred
+
", valid lifetime "
+
valid
);
return
false
;
}
if
(
preferred
>
valid
)
{
Log
.
w
(
TAG
,
"IA_PD option with preferred lifetime "
+
preferred
+
" greater than valid lifetime "
+
valid
);
return
false
;
}
if
(
prefixLen
>
64
)
{
Log
.
w
(
TAG
,
"IA_PD option with prefix length "
+
prefixLen
+
" longer than 64"
);
return
false
;
}
// Either preferred lifetime or t2 might be 0 which is valid, then ignore it.
if
(
preferred
!=
0
&&
t2
!=
0
&&
preferred
<
t2
)
{
Log
.
w
(
TAG
,
"preferred lifetime "
+
preferred
+
" is smaller than T2 "
+
t2
);
return
false
;
}
return
true
;
}
/**
* Build an IA_PD prefix option with given specific parameters.
*/
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment