Commit c7de869b authored by Alessandro Rubini's avatar Alessandro Rubini

general: move link_status to an argument to nework

We are going to have link up messages in syslog, we we'd better
pass it over and not do network thiings in main.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent da67d928
......@@ -18,6 +18,11 @@
#define PTPD_SOCK_UDP 0 /* wrong name, it should be "WRPC" */
#define PTPD_SOCK_RAW_ETHERNET 1 /* but used in ppsi, which I won't change */
#define LINK_WENT_UP 1
#define LINK_WENT_DOWN 2
#define LINK_UP 3
#define LINK_DOWN 4
// GCC-specific
#ifndef PACKED
# define PACKED __attribute__((packed))
......
......@@ -51,7 +51,7 @@ static struct wrpc_socket *rdate_socket;
void __attribute__((weak)) syslog_init(void)
{ }
void __attribute__((weak)) syslog_poll(void)
void __attribute__((weak)) syslog_poll(int l_status)
{ }
unsigned int ipv4_checksum(unsigned short *buf, int shorts)
......@@ -160,15 +160,17 @@ static void rdate_poll(void)
}
void ipv4_poll(void)
void ipv4_poll(int l_status)
{
if (l_status == LINK_WENT_UP)
needIP = 1;
bootp_poll();
icmp_poll();
rdate_poll();
syslog_poll();
syslog_poll(l_status);
}
void getIP(unsigned char *IP)
......
......@@ -34,7 +34,7 @@
#define UDP_END (UDP_CHECKSUM+2)
void ipv4_init(void);
void ipv4_poll(void);
void ipv4_poll(int l_status);
/* Internal to IP stack: */
unsigned int ipv4_checksum(unsigned short *buf, int shorts);
......@@ -61,6 +61,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(void);
void syslog_poll(int l_status);
#endif
......@@ -54,7 +54,7 @@ DEFINE_WRC_COMMAND(mac) = {
};
void syslog_poll(void)
void syslog_poll(int l_satus)
{
struct wr_sockaddr addr;
char buf[128];
......
......@@ -96,11 +96,6 @@ static void wrc_initialize(void)
}
}
#define LINK_WENT_UP 1
#define LINK_WENT_DOWN 2
#define LINK_UP 3
#define LINK_DOWN 4
static int wrc_check_link(void)
{
static int prev_link_state = -1;
......@@ -185,13 +180,10 @@ int main(void)
switch (l_status) {
case LINK_WENT_UP:
needIP = 1;
break;
case LINK_UP:
update_rx_queues();
if (HAS_IP) {
ipv4_poll();
ipv4_poll(l_status);
arp_poll();
}
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment