Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
32
Issues
32
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Software for White Rabbit PTP Core
Commits
c7401a84
Commit
c7401a84
authored
Feb 15, 2016
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net: all poll functions return 0/1
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
7e3805a6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
28 deletions
+38
-28
arp.c
lib/arp.c
+6
-3
ipv4.c
lib/ipv4.c
+24
-18
ipv4.h
lib/ipv4.h
+3
-3
syslog.c
lib/syslog.c
+5
-4
No files found.
lib/arp.c
View file @
c7401a84
...
...
@@ -88,17 +88,20 @@ static int process_arp(uint8_t * buf, int len)
return
ARP_END
;
}
void
arp_poll
(
void
)
int
arp_poll
(
void
)
{
uint8_t
buf
[
ARP_END
+
100
];
struct
wr_sockaddr
addr
;
int
len
;
if
(
ip_status
==
IP_TRAINING
)
return
;
/* can't do ARP w/o an address... */
return
0
;
/* can't do ARP w/o an address... */
if
((
len
=
ptpd_netif_recvfrom
(
arp_socket
,
&
addr
,
buf
,
sizeof
(
buf
),
0
))
>
0
)
&
addr
,
buf
,
sizeof
(
buf
),
0
))
>
0
)
{
if
((
len
=
process_arp
(
buf
,
len
))
>
0
)
ptpd_netif_sendto
(
arp_socket
,
&
addr
,
buf
,
len
,
0
);
return
1
;
}
return
0
;
}
lib/ipv4.c
View file @
c7401a84
...
...
@@ -51,8 +51,8 @@ static struct wrpc_socket *rdate_socket;
void
__attribute__
((
weak
))
syslog_init
(
void
)
{
}
void
__attribute__
((
weak
))
syslog_poll
(
int
l_status
)
{
}
int
__attribute__
((
weak
))
syslog_poll
(
int
l_status
)
{
return
0
;
}
unsigned
int
ipv4_checksum
(
unsigned
short
*
buf
,
int
shorts
)
{
...
...
@@ -94,11 +94,11 @@ static int bootp_retry = 0;
static
uint32_t
bootp_tics
;
/* receive bootp through the UDP mechanism */
static
void
bootp_poll
(
void
)
static
int
bootp_poll
(
void
)
{
struct
wr_sockaddr
addr
;
uint8_t
buf
[
400
];
int
len
;
int
len
,
ret
=
0
;
if
(
!
bootp_tics
)
/* first time ever */
bootp_tics
=
timer_get_tics
()
-
1
;
...
...
@@ -107,20 +107,21 @@ static void bootp_poll(void)
buf
,
sizeof
(
buf
),
NULL
);
if
(
ip_status
!=
IP_TRAINING
)
return
;
return
0
;
if
(
len
>
0
)
process_bootp
(
buf
,
len
);
ret
=
process_bootp
(
buf
,
len
);
if
(
time_before
(
timer_get_tics
(),
bootp_tics
))
return
;
return
ret
;
len
=
prepare_bootp
(
&
addr
,
buf
,
++
bootp_retry
);
ptpd_netif_sendto
(
bootp_socket
,
&
addr
,
buf
,
len
,
0
);
bootp_tics
=
timer_get_tics
()
+
TICS_PER_SECOND
;
return
1
;
}
static
void
icmp_poll
(
void
)
static
int
icmp_poll
(
void
)
{
struct
wr_sockaddr
addr
;
uint8_t
buf
[
128
];
...
...
@@ -129,15 +130,16 @@ static void icmp_poll(void)
len
=
ptpd_netif_recvfrom
(
icmp_socket
,
&
addr
,
buf
,
sizeof
(
buf
),
NULL
);
if
(
len
<=
0
)
return
;
return
0
;
if
(
ip_status
==
IP_TRAINING
)
return
;
return
0
;
if
((
len
=
process_icmp
(
buf
,
len
))
>
0
)
ptpd_netif_sendto
(
icmp_socket
,
&
addr
,
buf
,
len
,
0
);
return
1
;
}
static
void
rdate_poll
(
void
)
static
int
rdate_poll
(
void
)
{
struct
wr_sockaddr
addr
;
uint64_t
secs
;
...
...
@@ -148,7 +150,7 @@ static void rdate_poll(void)
len
=
ptpd_netif_recvfrom
(
rdate_socket
,
&
addr
,
buf
,
sizeof
(
buf
),
NULL
);
if
(
len
<=
0
)
return
;
return
0
;
shw_pps_gen_get_time
(
&
secs
,
NULL
);
result
=
htonl
((
uint32_t
)(
secs
+
2208988800LL
));
...
...
@@ -159,20 +161,24 @@ static void rdate_poll(void)
fill_udp
(
buf
,
len
,
NULL
);
ptpd_netif_sendto
(
rdate_socket
,
&
addr
,
buf
,
len
,
0
);
return
1
;
}
void
ipv4_poll
(
int
l_status
)
int
ipv4_poll
(
int
l_status
)
{
int
ret
=
0
;
if
(
l_status
==
LINK_WENT_UP
&&
ip_status
==
IP_OK_BOOTP
)
ip_status
=
IP_TRAINING
;
bootp_poll
();
ret
=
bootp_poll
();
ret
+=
icmp_poll
();
icmp
_poll
();
ret
+=
rdate
_poll
();
r
date_poll
(
);
r
et
+=
syslog_poll
(
l_status
);
syslog_poll
(
l_status
)
;
return
ret
!=
0
;
}
void
getIP
(
unsigned
char
*
IP
)
...
...
lib/ipv4.h
View file @
c7401a84
...
...
@@ -34,13 +34,13 @@
#define UDP_END (UDP_CHECKSUM+2)
void
ipv4_init
(
void
);
void
ipv4_poll
(
int
l_status
);
int
ipv4_poll
(
int
l_status
);
/* Internal to IP stack: */
unsigned
int
ipv4_checksum
(
unsigned
short
*
buf
,
int
shorts
);
void
arp_init
(
void
);
void
arp_poll
(
void
);
int
arp_poll
(
void
);
enum
ip_status
{
IP_TRAINING
,
...
...
@@ -66,6 +66,6 @@ struct wr_udp_addr {
void
fill_udp
(
uint8_t
*
buf
,
int
len
,
struct
wr_udp_addr
*
uaddr
);
void
syslog_init
(
void
);
void
syslog_poll
(
int
l_status
);
int
syslog_poll
(
int
l_status
);
#endif
lib/syslog.c
View file @
c7401a84
...
...
@@ -55,7 +55,7 @@ DEFINE_WRC_COMMAND(mac) = {
};
void
syslog_poll
(
int
l_status
)
int
syslog_poll
(
int
l_status
)
{
struct
wr_sockaddr
addr
;
char
buf
[
256
];
...
...
@@ -67,9 +67,9 @@ void syslog_poll(int l_status)
int
len
=
0
;
if
(
ip_status
==
IP_TRAINING
)
return
;
return
0
;
if
(
!
syslog_addr
.
daddr
)
return
;
return
0
;
if
(
!
tics
)
{
/* first time ever, or new syslog server */
...
...
@@ -101,7 +101,7 @@ void syslog_poll(int l_status)
goto
send
;
}
return
;
return
0
;
send:
len
+=
UDP_END
;
...
...
@@ -109,5 +109,6 @@ send:
fill_udp
((
void
*
)
buf
,
len
,
&
syslog_addr
);
memcpy
(
&
addr
.
mac
,
syslog_mac
,
6
);
ptpd_netif_sendto
(
syslog_socket
,
&
addr
,
buf
,
len
,
0
);
return
1
;
}
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