Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pim_dm
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
pim_dm
Commits
48346dcf
Commit
48346dcf
authored
Jul 01, 2017
by
Pedro Oliveira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First try
parent
dd3e14f8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
0 deletions
+81
-0
Packet/PacketPimHello.py
Packet/PacketPimHello.py
+31
-0
Packet/PacketPimJoinPrune.py
Packet/PacketPimJoinPrune.py
+23
-0
Packet/PacketPimJoinPruneMulticastGroup.py
Packet/PacketPimJoinPruneMulticastGroup.py
+27
-0
No files found.
Packet/PacketPimHello.py
0 → 100644
View file @
48346dcf
import
struct
class
PacketPimHello
:
PIM_TYPE
=
0
PIM_HDR_OPTS
=
"! HH"
PIM_HDR_OPTS_LEN
=
struct
.
calcsize
(
PIM_HDR_OPTS
)
PIM_MSG_TYPES_LENGTH
=
{
1
:
2
,
20
:
4
,
}
def
__init__
(
self
):
self
.
options
=
{}
def
add_option
(
self
,
option_type
:
int
,
option_value
:
int
):
if
option_value
is
None
:
del
self
.
options
[
option_type
]
return
self
.
options
[
option_type
]
=
option_value
def
get_options
(
self
):
return
self
.
options
def
bytes
(
self
)
->
bytes
:
res
=
b''
for
(
option_type
,
option_value
)
in
self
.
options
.
items
():
option_length
=
self
.
PIM_MSG_TYPES_LENGTH
[
option_type
]
type_length_hdr
=
struct
.
pack
(
self
.
PIM_HDR_OPTS
,
option_type
,
option_length
)
res
+=
type_length_hdr
+
struct
.
pack
(
"! "
+
str
(
option_length
)
+
"s"
,
option_value
.
to_bytes
(
option_length
,
byteorder
=
'big'
))
return
res
Packet/PacketPimJoinPrune.py
0 → 100644
View file @
48346dcf
import
struct
class
PacketPimJoinPrune
:
PIM_HDR_JOIN_PRUNE
=
"! 4S BBH "
PIM_HDR_JOIN_PRUNE_LEN
=
struct
.
calcsize
(
PIM_HDR_JOIN_PRUNE
)
def
__init__
(
self
,
upstream_neighbor_address
,
hold_time
):
self
.
groups
=
[]
self
.
upstream_neighbor_address
=
upstream_neighbor_address
self
.
hold_time
=
hold_time
def
add_multicast_group
(
self
,
group
):
# TODO verificar se grupo ja esta na msg
self
.
groups
.
append
(
group
)
def
bytes
(
self
)
->
bytes
:
msg
=
struct
.
pack
(
self
.
PIM_HDR_JOIN_PRUNE
,
self
.
upstream_neighbor_address
,
0
,
len
(
self
.
groups
),
self
.
hold_time
)
for
multicast_group
in
self
.
groups
:
msg
+=
multicast_group
.
bytes
()
return
msg
Packet/PacketPimJoinPruneMulticastGroup.py
0 → 100644
View file @
48346dcf
import
struct
class
PacketPimJoinPruneMulticastGroup
:
PIM_HDR_JOIN_PRUNE_MULTICAST_GROUP
=
"! 4s HH"
PIM_HDR_JOIN_PRUNE_MULTICAST_GROUP_LEN
=
struct
.
calcsize
(
PIM_HDR_JOIN_PRUNE_MULTICAST_GROUP
)
PIM_HDR_JOINED_PRUNED_SOURCE
=
"! 4s"
PIM_HDR_JOINED_PRUNED_SOURCE_LEN
=
struct
.
calcsize
(
PIM_HDR_JOINED_PRUNED_SOURCE
)
def
__init__
(
self
,
multicast_group
,
joined_src_addresses
,
pruned_src_addresses
):
self
.
multicast_group
=
multicast_group
self
.
joined_src_addresses
=
joined_src_addresses
self
.
pruned_src_addresses
=
pruned_src_addresses
def
bytes
(
self
)
->
bytes
:
# TODO: verificar multicast_group
msg
=
struct
.
pack
(
self
.
PIM_HDR_JOIN_PRUNE_MULTICAST_GROUP
,
self
.
multicast_group
,
len
(
self
.
joined_src_addresses
),
len
(
self
.
pruned_src_addresses
))
for
joined_src_address
in
self
.
joined_src_addresses
:
msg
=
struct
.
pack
(
self
.
PIM_HDR_JOINED_PRUNED_SOURCE
,
joined_src_address
)
for
pruned_src_address
in
self
.
pruned_src_addresses
:
msg
=
struct
.
pack
(
self
.
PIM_HDR_JOINED_PRUNED_SOURCE
,
pruned_src_address
)
# TODO: verificar pruned e joined addrss
return
msg
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment