Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bio-rd
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review 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
danet
bio-rd
Commits
d1c2ee56
Commit
d1c2ee56
authored
5 years ago
by
Marcus Weiner
Browse files
Options
Downloads
Patches
Plain Diff
Improve definition of LSA-Type
parent
bfb142be
Branches
net
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2
Packet/ospfv3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
protocols/ospf/packetv3/common.go
+0
-6
0 additions, 6 deletions
protocols/ospf/packetv3/common.go
protocols/ospf/packetv3/lsa.go
+45
-17
45 additions, 17 deletions
protocols/ospf/packetv3/lsa.go
protocols/ospf/packetv3/packet.go
+1
-1
1 addition, 1 deletion
protocols/ospf/packetv3/packet.go
with
46 additions
and
24 deletions
protocols/ospf/packetv3/common.go
+
0
−
6
View file @
d1c2ee56
...
...
@@ -69,12 +69,6 @@ func (r *RouterOptions) Serialize(buf *bytes.Buffer) {
buf
.
Write
(
convert
.
Uint16Byte
(
uint16
(
r
.
Flags
)))
}
type
LSType
uint16
func
(
t
LSType
)
Serialize
(
buf
*
bytes
.
Buffer
)
{
buf
.
Write
(
convert
.
Uint16Byte
(
uint16
(
t
)))
}
type
deserializableIP
struct
{
Higher
uint64
Lower
uint64
...
...
This diff is collapsed.
Click to expand it.
protocols/ospf/packetv3/lsa.go
+
45
−
17
View file @
d1c2ee56
...
...
@@ -11,25 +11,46 @@ import (
"github.com/pkg/errors"
)
type
OSPFLSAType
uint8
type
LSAType
uint16
func
(
t
LSAType
)
Serialize
(
buf
*
bytes
.
Buffer
)
{
buf
.
Write
(
convert
.
Uint16Byte
(
uint16
(
t
)))
}
func
(
t
LSAType
)
ShouldFlood
()
bool
{
return
t
&
(
1
<<
15
)
!=
0
// test for top bit
}
type
FloodingScope
uint8
const
(
FloodLinkLocal
FloodingScope
=
iota
FloodArea
FloodAS
FloodReserved
)
func
(
t
LSAType
)
FloodingScope
()
FloodingScope
{
return
FloodingScope
((
t
&
0
b0110000000000000
)
>>
13
)
// second and third bit as int
}
// OSPF LSA types
const
(
LSATypeUnknown
OSPF
LSAType
=
iota
LSATypeRouter
LSATypeNetwork
LSATypeInterAreaPrefix
LSATypeInterAreaRouter
LSATypeASExternal
LSATypeDeprecated
LSATypeNSSA
LSATypeLink
LSATypeIntraAreaPrefix
LSATypeUnknown
LSAType
=
0
LSATypeRouter
=
0x2001
LSATypeNetwork
=
0x2002
LSATypeInterAreaPrefix
=
0x2003
LSATypeInterAreaRouter
=
0x2004
LSATypeASExternal
=
0x4005
LSATypeDeprecated
=
0x2006
LSATypeNSSA
=
0x2007
LSATypeLink
=
0x0008
LSATypeIntraAreaPrefix
=
0x2009
)
type
LSA
struct
{
Age
uint16
Type
LSType
Type
LS
A
Type
ID
ID
AdvertisingRouter
ID
SequenceNumber
uint32
...
...
@@ -96,13 +117,12 @@ func DeserializeLSA(buf *bytes.Buffer) (*LSA, int, error) {
}
func
(
x
*
LSA
)
ReadBody
(
buf
*
bytes
.
Buffer
)
(
int
,
error
)
{
code
:=
OSPFLSAType
(
x
.
Type
&
8191
)
// Bitmask excludes top three bits
bodyLength
:=
x
.
Length
-
LSAHeaderLength
var
body
Serializable
var
readBytes
int
var
err
error
switch
cod
e
{
switch
x
.
Typ
e
{
case
LSATypeRouter
:
body
,
readBytes
,
err
=
DeserializeRouterLSA
(
buf
,
bodyLength
)
case
LSATypeNetwork
:
...
...
@@ -120,17 +140,25 @@ func (x *LSA) ReadBody(buf *bytes.Buffer) (int, error) {
case
LSATypeIntraAreaPrefix
:
body
,
readBytes
,
err
=
DeserializeIntraAreaPrefixLSA
(
buf
)
default
:
return
0
,
fmt
.
Errorf
(
"unknown LSA type: %x"
,
x
.
Type
)
raw
:=
make
(
UnknownLSA
,
bodyLength
)
readBytes
,
err
=
buf
.
Read
(
raw
)
body
=
raw
}
if
err
!=
nil
{
return
0
,
err
return
readBytes
,
err
}
x
.
Body
=
body
return
readBytes
,
nil
}
type
UnknownLSA
[]
byte
func
(
u
UnknownLSA
)
Serialize
(
buf
*
bytes
.
Buffer
)
{
buf
.
Write
(
u
)
}
// InterfaceMetric is the metric of a link
// This is supposed to be 24-bit long
type
InterfaceMetric
struct
{
...
...
@@ -504,7 +532,7 @@ func DeserializeLinkLSA(buf *bytes.Buffer) (*LinkLSA, int, error) {
}
type
IntraAreaPrefixLSA
struct
{
ReferencedLSType
LSType
ReferencedLSType
LS
A
Type
ReferencedLinkStateID
ID
ReferencedAdvertisingRouter
ID
Prefixes
[]
LSAPrefix
...
...
This diff is collapsed.
Click to expand it.
protocols/ospf/packetv3/packet.go
+
1
−
1
View file @
d1c2ee56
...
...
@@ -299,7 +299,7 @@ func DeserializeLinkStateRequestMsg(buf *bytes.Buffer, bodyLength uint16) (*Link
}
type
LinkStateRequest
struct
{
LSType
LSType
LSType
LS
A
Type
LinkStateID
ID
AdvertisingRouter
ID
}
...
...
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