Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LOFAR
Manage
Activity
Members
Labels
Plan
Issues
Wiki
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor 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
RadioObservatory
LOFAR
Commits
5dc0dae9
Commit
5dc0dae9
authored
18 years ago
by
wierenga
Browse files
Options
Downloads
Patches
Plain Diff
Bugid:790
Simple ignore unrecognised messages to make rsuctl robust to PING and ARP messages.
parent
cdb4b1a6
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
MAC/APL/PIC/rsuctl/rsuctl
+50
-42
50 additions, 42 deletions
MAC/APL/PIC/rsuctl/rsuctl
with
50 additions
and
42 deletions
MAC/APL/PIC/rsuctl/rsuctl
+
50
−
42
View file @
5dc0dae9
...
@@ -187,48 +187,54 @@ sub savepacket
...
@@ -187,48 +187,54 @@ sub savepacket
sub
readresponse
sub
readresponse
{
{
my
(
$pcap
)
=
@_
;
my
(
$pcap
)
=
@_
;
my
(
$retval
)
=
0
;
my
$error
=
0
;
do
{
# keep going when we receive invalid messages
$retval
=
0
;
# assume success
eval
{
# wait for message to arrive
use
POSIX
qw(SIGALRM)
;
eval
{
POSIX::
sigaction
(
SIGALRM
,
use
POSIX
qw(SIGALRM)
;
POSIX::
SigAction
->
new
(
sub
{
die
}))
POSIX::
sigaction
(
SIGALRM
,
||
die
"
=== ERR error setting SIGALRM handler: $!
\n
";
POSIX::
SigAction
->
new
(
sub
{
die
}))
||
die
"
=== ERR error setting SIGALRM handler: $!
\n
";
alarm
$RESPONSETIMEOUT
;
alarm
$RESPONSETIMEOUT
;
(
0
==
loop
(
$pcap
,
1
,
\
&savepacket
,
''))
(
0
==
loop
(
$pcap
,
1
,
\
&savepacket
,
''))
||
die
"
=== ERR Failed to receive response
";
||
die
"
=== ERR Failed to receive response
";
alarm
0
;
alarm
0
;
};
};
if
(
$@
)
{
if
(
$@
)
{
$error
=
1
;
$retval
=
1
;
# fatal (timeout)
return
('',
$error
,'');
return
('',
$retval
,
'');
}
}
my
(
$ethdr
,
$type
,
$status
,
$framesize
,
$blp
,
$rsp
,
$pid
,
$regid
,
$offset
,
$size
,
$seqnr
,
$reserved
)
=
my
(
$ethdr
,
$type
,
$status
,
$framesize
,
$blp
,
$rsp
,
$pid
,
$regid
,
$offset
,
$size
,
$seqnr
,
$reserved
)
=
unpack
(
$MEPRECVFORMAT
,
$g_packet
);
unpack
(
$MEPRECVFORMAT
,
$g_packet
);
if
(
$TYPE_WRITEACK
!=
$type
&&
$TYPE_READACK
!=
$type
)
{
if
(
$TYPE_WRITEACK
!=
$type
&&
$TYPE_READACK
!=
$type
)
{
$error
=
1
;
$retval
=
2
;
# ignore invalid message
print
STDERR
"
=== ERR invalid message type:
",
$type
,
"
\n
";
print
STDERR
"
ignoring message with invalid TYPE
\n
"
if
(
$g_debug
);
}
}
if
(
$PID_RSU
!=
$pid
&&
$PID_RSR
!=
$pid
)
{
if
(
$PID_RSU
!=
$pid
&&
$PID_RSR
!=
$pid
)
{
$error
=
1
;
$retval
=
2
;
# ignore invalid message
print
STDERR
"
=== ERR invalid pid:
",
$pid
,
"
\n
";
print
STDERR
"
ignoring message with invalid PID
\n
"
if
(
$g_debug
);
}
}
printf
STDERR
"
0x%s 0x%02x 0x%02x %5d 0x%02x 0x%02x 0x%02x 0x%02x %5d %5d %5d %5d
\n
",
printf
STDERR
"
0x%s 0x%02x 0x%02x %5d 0x%02x 0x%02x 0x%02x 0x%02x %5d %5d %5d %5d
\n
",
$ethdr
,
$type
,
$status
,
$framesize
,
$blp
,
$rsp
,
$pid
,
$regid
,
$offset
,
$size
,
$seqnr
,
$reserved
if
(
$g_debug
);
$ethdr
,
$type
,
$status
,
$framesize
,
$blp
,
$rsp
,
$pid
,
$regid
,
$offset
,
$size
,
$seqnr
,
$reserved
if
(
$g_debug
);
if
(
0
==
$retval
&&
0
!=
$status
)
{
$retval
=
1
;
# fatal
print
STDERR
"
=== FATAL protocol error: status=
",
$STATUS
{
$status
},
"
\n
";
print
STDERR
"
=== Are you using the correct Ethernet interface? Use -i argument to change, e.g. -i eth1
\n
";
exit
;
}
}
until
(
$retval
!=
2
);
return
('',
$retval
,
'')
if
(
$retval
);
if
(
0
!=
$status
)
{
return
(
substr
(
$g_packet
,
14
+
$MEPHDRSIZE
),
$retval
,
$ethdr
);
$error
=
1
;
print
STDERR
"
=== FATAL protocol error: status=
",
$STATUS
{
$status
},
"
\n
";
print
STDERR
"
=== Are you using the correct Ethernet interface? Use -i argument to change, e.g. -i eth1
\n
";
exit
;
}
return
(
substr
(
$g_packet
,
14
+
$MEPHDRSIZE
),
$error
,
$ethdr
);
}
}
#
#
...
@@ -253,7 +259,8 @@ sub flash
...
@@ -253,7 +259,8 @@ sub flash
$sock
->
send_eth_frame
(
$packet
);
$sock
->
send_eth_frame
(
$packet
);
(
$payload
,
$error
)
=
readresponse
(
$pcap
);
(
$payload
,
$error
)
=
readresponse
(
$pcap
);
return
$error
if
$error
;
return
$error
if
(
$error
);
}
}
if
(
$readcb
)
{
if
(
$readcb
)
{
...
@@ -262,8 +269,8 @@ sub flash
...
@@ -262,8 +269,8 @@ sub flash
$sock
->
send_eth_frame
(
$packet
);
$sock
->
send_eth_frame
(
$packet
);
(
$payload
,
$error
)
=
readresponse
(
$pcap
);
(
$payload
,
$error
)
=
readresponse
(
$pcap
);
return
$error
if
$error
;
return
$error
if
(
$error
)
;
$success
=
&$readcb
(
$page
,
$block
,
$payload
,
$image
)
&&
$success
;
$success
=
&$readcb
(
$page
,
$block
,
$payload
,
$image
)
&&
$success
;
}
}
...
@@ -298,8 +305,9 @@ sub writedir
...
@@ -298,8 +305,9 @@ sub writedir
((
$page
+
1
)
*
$BLOCKS_PER_PAGE
)
-
1
);
((
$page
+
1
)
*
$BLOCKS_PER_PAGE
)
-
1
);
$packet
.=
$entry
;
$packet
.=
$entry
;
my
$error
=
0
;
my
$error
=
2
;
$sock
->
send_eth_frame
(
$packet
);
$sock
->
send_eth_frame
(
$packet
);
(
$result
,
$error
)
=
readresponse
(
$pcap
);
(
$result
,
$error
)
=
readresponse
(
$pcap
);
return
$error
;
return
$error
;
...
...
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