Add RPL nodes and border router to minimal-net platform (cygwin only)
This commit is contained in:
parent
6749281a87
commit
c48b7ab78d
10 changed files with 843 additions and 78 deletions
|
@ -158,7 +158,8 @@ make_tcp_stats(void *arg)
|
|||
struct httpd_state *s = (struct httpd_state *)arg;
|
||||
conn = &uip_conns[s->u.count];
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
#if UIP_CONF_IPV6
|
||||
{
|
||||
char buf[48];
|
||||
httpd_sprint_ip6(conn->ripaddr, buf);
|
||||
return snprintf((char *)uip_appdata, uip_mss(),
|
||||
|
@ -171,6 +172,7 @@ make_tcp_stats(void *arg)
|
|||
conn->timer,
|
||||
(uip_outstanding(conn))? '*':' ',
|
||||
(uip_stopped(conn))? '!':' ');
|
||||
}
|
||||
#else
|
||||
return snprintf((char *)uip_appdata, uip_mss(),
|
||||
"<tr align=\"center\"><td>%d</td><td>%u.%u.%u.%u:%u</td><td>%s</td><td>%u</td><td>%u</td><td>%c %c</td></tr>\r\n",
|
||||
|
@ -227,6 +229,114 @@ PT_THREAD(processes(struct httpd_state *s, char *ptr))
|
|||
}
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
#if UIP_CONF_IPV6
|
||||
/*---------------------------------------------------------------------------*/
|
||||
#define HTTPD_STRING_ATTR
|
||||
#define httpd_snprintf snprintf
|
||||
#define httpd_cgi_sprint_ip6 httpd_sprint_ip6
|
||||
|
||||
static const char httpd_cgi_addrh[] HTTPD_STRING_ATTR = "<code>";
|
||||
static const char httpd_cgi_addrf[] HTTPD_STRING_ATTR = "</code>[Room for %u more]";
|
||||
static const char httpd_cgi_addrb[] HTTPD_STRING_ATTR = "<br>";
|
||||
static const char httpd_cgi_addrn[] HTTPD_STRING_ATTR = "(none)<br>";
|
||||
extern uip_ds6_nbr_t uip_ds6_nbr_cache[];
|
||||
extern uip_ds6_route_t uip_ds6_routing_table[];
|
||||
extern uip_ds6_netif_t uip_ds6_if;
|
||||
|
||||
static unsigned short
|
||||
make_addresses(void *p)
|
||||
{
|
||||
uint8_t i,j=0;
|
||||
uint16_t numprinted;
|
||||
numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(),httpd_cgi_addrh);
|
||||
for (i=0; i<UIP_DS6_ADDR_NB;i++) {
|
||||
if (uip_ds6_if.addr_list[i].isused) {
|
||||
j++;
|
||||
// numprinted += httpd_cgi_sprint_ip6(uip_ds6_if.addr_list[i].ipaddr, uip_appdata + numprinted);
|
||||
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrb);
|
||||
}
|
||||
}
|
||||
//if (j==0) numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrn);
|
||||
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrf, UIP_DS6_ADDR_NB-j);
|
||||
return numprinted;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(addresses(struct httpd_state *s, char *ptr))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
PSOCK_GENERATOR_SEND(&s->sout, make_addresses, s->u.ptr);
|
||||
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned short
|
||||
make_neighbors(void *p)
|
||||
{
|
||||
uint8_t i,j=0;
|
||||
uint16_t numprinted;
|
||||
numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(),httpd_cgi_addrh);
|
||||
for (i=0; i<UIP_DS6_NBR_NB;i++) {
|
||||
if (uip_ds6_nbr_cache[i].isused) {
|
||||
j++;
|
||||
// numprinted += httpd_cgi_sprint_ip6(uip_ds6_nbr_cache[i].ipaddr, uip_appdata + numprinted);
|
||||
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrb);
|
||||
}
|
||||
}
|
||||
//if (j==0) numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrn);
|
||||
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrf,UIP_DS6_NBR_NB-j);
|
||||
return numprinted;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(neighbors(struct httpd_state *s, char *ptr))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
PSOCK_GENERATOR_SEND(&s->sout, make_neighbors, s->u.ptr);
|
||||
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static unsigned short
|
||||
make_routes(void *p)
|
||||
{
|
||||
static const char httpd_cgi_rtes1[] HTTPD_STRING_ATTR = "(%u (via ";
|
||||
static const char httpd_cgi_rtes2[] HTTPD_STRING_ATTR = ") %us<br>";
|
||||
static const char httpd_cgi_rtes3[] HTTPD_STRING_ATTR = ")<br>";
|
||||
uint8_t i,j=0;
|
||||
uint16_t numprinted;
|
||||
numprinted = httpd_snprintf((char *)uip_appdata, uip_mss(),httpd_cgi_addrh);
|
||||
for (i=0; i<UIP_DS6_ROUTE_NB;i++) {
|
||||
if (uip_ds6_routing_table[i].isused) {
|
||||
j++;
|
||||
// numprinted += httpd_cgi_sprint_ip6(uip_ds6_routing_table[i].ipaddr, uip_appdata + numprinted);
|
||||
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes1, uip_ds6_routing_table[i].length);
|
||||
// numprinted += httpd_cgi_sprint_ip6(uip_ds6_routing_table[i].nexthop, uip_appdata + numprinted);
|
||||
if(uip_ds6_routing_table[i].state.lifetime < 3600*24) {
|
||||
//if(uip_ds6_routing_table[i].state.lifetime < 3600) {
|
||||
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes2, uip_ds6_routing_table[i].state.lifetime);
|
||||
} else {
|
||||
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_rtes3);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (j==0) numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrn);
|
||||
numprinted += httpd_snprintf((char *)uip_appdata+numprinted, uip_mss()-numprinted, httpd_cgi_addrf,UIP_DS6_ROUTE_NB-j);
|
||||
return numprinted;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static
|
||||
PT_THREAD(routes(struct httpd_state *s, char *ptr))
|
||||
{
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
PSOCK_GENERATOR_SEND(&s->sout, make_routes, s->u.ptr);
|
||||
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
#endif /* UIP_CONF_IPV6 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
httpd_cgi_add(struct httpd_cgi_call *c)
|
||||
|
@ -242,10 +352,19 @@ httpd_cgi_add(struct httpd_cgi_call *c)
|
|||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#if UIP_CONF_IPV6
|
||||
static const char adrs_name[] HTTPD_STRING_ATTR = "addresses";
|
||||
static const char nbrs_name[] HTTPD_STRING_ATTR = "neighbors";
|
||||
static const char rtes_name[] HTTPD_STRING_ATTR = "routes";
|
||||
#endif
|
||||
HTTPD_CGI_CALL(file, file_name, file_stats);
|
||||
HTTPD_CGI_CALL(tcp, tcp_name, tcp_stats);
|
||||
HTTPD_CGI_CALL(proc, proc_name, processes);
|
||||
#if UIP_CONF_IPV6
|
||||
HTTPD_CGI_CALL(adrs, adrs_name, addresses);
|
||||
HTTPD_CGI_CALL(nbrs, nbrs_name, neighbors);
|
||||
HTTPD_CGI_CALL(rtes, rtes_name, routes);
|
||||
#endif
|
||||
|
||||
void
|
||||
httpd_cgi_init(void)
|
||||
|
@ -253,5 +372,10 @@ httpd_cgi_init(void)
|
|||
httpd_cgi_add(&file);
|
||||
httpd_cgi_add(&tcp);
|
||||
httpd_cgi_add(&proc);
|
||||
#if UIP_CONF_IPV6
|
||||
httpd_cgi_add(&adrs);
|
||||
httpd_cgi_add(&nbrs);
|
||||
httpd_cgi_add(&rtes);
|
||||
#endif
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue