Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HP_2101nw
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
Kainhofer
HP_2101nw
Commits
4b2159d1
Commit
4b2159d1
authored
13 years ago
by
root
Browse files
Options
Downloads
Patches
Plain Diff
appliance_setup: fix some 8888 bugs
parent
9cb2b133
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
appliance_setup/device_types.py
+9
-6
9 additions, 6 deletions
appliance_setup/device_types.py
with
9 additions
and
6 deletions
appliance_setup/device_types.py
+
9
−
6
View file @
4b2159d1
...
@@ -225,16 +225,17 @@ import re
...
@@ -225,16 +225,17 @@ import re
class
Ether8888Packet
:
class
Ether8888Packet
:
ethHeaderFmt
=
"
!6s6sH
"
ethHeaderFmt
=
"
!6s6sH
"
headerFmt
=
"
<2s2s2sHH
"
headerFmt
=
"
<2s2s2sHH
"
localAddr
=
"
\
x00\x00\x00\x00\x00\x0
0
"
localAddr
=
"
\
0\0\0\0\0\
0
"
remoteAddr
=
"
\xff\xff\xff\xff\xff\xff
"
remoteAddr
=
"
\xff\xff\xff\xff\xff\xff
"
proto
=
0x8888
proto
=
0x8888
zero
=
"
\0\0
"
def
__init__
(
self
,
localAddr
=
"
\x00\x00\x00\x00\x00\x00
"
,
remoteAddr
=
"
\xff\xff\xff\xff\xff\xff
"
,
proto
=
0x8888
):
def
__init__
(
self
,
localAddr
=
"
\x00\x00\x00\x00\x00\x00
"
,
remoteAddr
=
"
\xff\xff\xff\xff\xff\xff
"
,
proto
=
0x8888
):
self
.
proto
=
proto
self
.
proto
=
proto
self
.
localAddr
=
localAddr
self
.
localAddr
=
localAddr
self
.
remoteAddr
=
remoteAddr
self
.
remoteAddr
=
remoteAddr
def
decode
(
self
,
data
):
def
decode
(
self
,
data
):
self
.
dst
Addr
,
self
.
src
Addr
,
self
.
proto
=
struct
.
unpack
(
self
.
ethHeaderFmt
,
data
[:
14
])
self
.
local
Addr
,
self
.
remote
Addr
,
self
.
proto
=
struct
.
unpack
(
self
.
ethHeaderFmt
,
data
[:
14
])
if
self
.
proto
!=
0x8888
:
if
self
.
proto
!=
0x8888
:
# FIXME: Error message about invalid packet
# FIXME: Error message about invalid packet
return
False
return
False
...
@@ -250,7 +251,9 @@ class Ether8888Packet:
...
@@ -250,7 +251,9 @@ class Ether8888Packet:
def
encode
(
self
,
cmd
,
unknown
,
nrPackets
,
dataLen
,
data
):
def
encode
(
self
,
cmd
,
unknown
,
nrPackets
,
dataLen
,
data
):
# Ethernet II header
# Ethernet II header
d
=
struct
.
pack
(
self
.
ethHeaderFmt
,
self
.
dstAddr
,
self
.
srcAddr
,
self
.
proto
)
(
self
.
cmd
,
self
.
unknown
,
self
.
nrPackets
,
self
.
dataLen
,
self
.
payload
)
=
(
cmd
,
unknown
,
nrPackets
,
dataLen
,
data
)
d
=
struct
.
pack
(
self
.
ethHeaderFmt
,
self
.
remoteAddr
,
self
.
localAddr
,
self
.
proto
)
d
+=
struct
.
pack
(
self
.
headerFmt
,
self
.
cmd
,
self
.
unknown
,
self
.
zero
,
d
+=
struct
.
pack
(
self
.
headerFmt
,
self
.
cmd
,
self
.
unknown
,
self
.
zero
,
self
.
nrPackets
,
self
.
dataLen
)
self
.
nrPackets
,
self
.
dataLen
)
d
+=
data
d
+=
data
...
@@ -296,9 +299,9 @@ class Ether8888DeviceFactory (DeviceFactory):
...
@@ -296,9 +299,9 @@ class Ether8888DeviceFactory (DeviceFactory):
for
sock
in
sread
:
for
sock
in
sread
:
rxFrame
=
sock
.
recv
(
1500
)
rxFrame
=
sock
.
recv
(
1500
)
pack
=
Ether8888Packet
()
pack
=
Ether8888Packet
()
if
pack
.
decode
(
rxFrame
)
and
(
not
pack
.
dst
Addr
==
bcAddr
):
if
pack
.
decode
(
rxFrame
)
and
(
not
pack
.
remote
Addr
==
bcAddr
):
ifName
,
ifProto
,
pktType
,
hwType
,
hwAddr
=
sock
.
getsockname
()
ifName
,
ifProto
,
pktType
,
hwType
,
hwAddr
=
sock
.
getsockname
()
devices
.
append
(
Ether8888Device
(
ui
,
ifName
,
ifProto
,
pack
.
src
Addr
,
"
Vonets VAP11G wireless bridge
"
));
devices
.
append
(
Ether8888Device
(
ui
,
ifName
,
ifProto
,
pack
.
local
Addr
,
"
Vonets VAP11G wireless bridge
"
));
for
s
in
sockets
:
for
s
in
sockets
:
s
.
close
();
s
.
close
();
...
@@ -365,7 +368,7 @@ class Ether8888Device (Device):
...
@@ -365,7 +368,7 @@ class Ether8888Device (Device):
def
bulk_data_write
(
self
,
data
,
length
):
def
bulk_data_write
(
self
,
data
,
length
):
packet
=
Ether8888Packet
(
localAddr
=
self
.
localAddr
,
remoteAddr
=
self
.
remoteAddr
)
packet
=
Ether8888Packet
(
localAddr
=
self
.
localAddr
,
remoteAddr
=
self
.
remoteAddr
)
request
=
packet
.
encode
(
"
\x01\x01
"
,
"
\0\0
"
,
"
\0\0
"
,
0
,
length
,
data
)
request
=
packet
.
encode
(
"
\x01\x01
"
,
"
\0\0
"
,
0
,
length
,
data
)
self
.
ui
.
debug
(
"
Request:
"
+
request
)
self
.
ui
.
debug
(
"
Request:
"
+
request
)
res
=
None
res
=
None
try
:
try
:
...
...
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