Indent tcpip.c

This commit is contained in:
Simon Duquennoy 2016-04-22 21:41:03 +02:00 committed by Simon Duquennoy
parent 5b5f07ba52
commit 0296e6aba0

View File

@ -219,7 +219,7 @@ struct uip_conn *
tcp_connect(const uip_ipaddr_t *ripaddr, uint16_t port, void *appstate)
{
struct uip_conn *c;
c = uip_connect(ripaddr, port);
if(c == NULL) {
return NULL;
@ -227,9 +227,9 @@ tcp_connect(const uip_ipaddr_t *ripaddr, uint16_t port, void *appstate)
c->appstate.p = PROCESS_CURRENT();
c->appstate.state = appstate;
tcpip_poll_tcp(c);
return c;
}
#endif /* UIP_ACTIVE_OPEN */
@ -300,7 +300,7 @@ udp_new(const uip_ipaddr_t *ripaddr, uint16_t port, void *appstate)
{
struct uip_udp_conn *c;
uip_udp_appstate_t *s;
c = uip_udp_new(ripaddr, port);
if(c == NULL) {
return NULL;
@ -365,151 +365,151 @@ eventhandler(process_event_t ev, process_data_t data)
struct process *p;
switch(ev) {
case PROCESS_EVENT_EXITED:
/* This is the event we get if a process has exited. We go through
case PROCESS_EVENT_EXITED:
/* This is the event we get if a process has exited. We go through
the TCP/IP tables to see if this process had any open
connections or listening TCP ports. If so, we'll close those
connections. */
p = (struct process *)data;
p = (struct process *)data;
#if UIP_TCP
l = s.listenports;
for(i = 0; i < UIP_LISTENPORTS; ++i) {
if(l->p == p) {
uip_unlisten(l->port);
l->port = 0;
l->p = PROCESS_NONE;
}
++l;
l = s.listenports;
for(i = 0; i < UIP_LISTENPORTS; ++i) {
if(l->p == p) {
uip_unlisten(l->port);
l->port = 0;
l->p = PROCESS_NONE;
}
{
struct uip_conn *cptr;
for(cptr = &uip_conns[0]; cptr < &uip_conns[UIP_CONNS]; ++cptr) {
if(cptr->appstate.p == p) {
cptr->appstate.p = PROCESS_NONE;
cptr->tcpstateflags = UIP_CLOSED;
}
++l;
}
{
struct uip_conn *cptr;
for(cptr = &uip_conns[0]; cptr < &uip_conns[UIP_CONNS]; ++cptr) {
if(cptr->appstate.p == p) {
cptr->appstate.p = PROCESS_NONE;
cptr->tcpstateflags = UIP_CLOSED;
}
}
}
#endif /* UIP_TCP */
#if UIP_UDP
{
struct uip_udp_conn *cptr;
{
struct uip_udp_conn *cptr;
for(cptr = &uip_udp_conns[0];
cptr < &uip_udp_conns[UIP_UDP_CONNS]; ++cptr) {
if(cptr->appstate.p == p) {
cptr->lport = 0;
}
for(cptr = &uip_udp_conns[0];
cptr < &uip_udp_conns[UIP_UDP_CONNS]; ++cptr) {
if(cptr->appstate.p == p) {
cptr->lport = 0;
}
}
}
#endif /* UIP_UDP */
break;
break;
case PROCESS_EVENT_TIMER:
/* We get this event if one of our timers have expired. */
{
/* Check the clock so see if we should call the periodic uIP
case PROCESS_EVENT_TIMER:
/* We get this event if one of our timers have expired. */
{
/* Check the clock so see if we should call the periodic uIP
processing. */
if(data == &periodic &&
etimer_expired(&periodic)) {
if(data == &periodic &&
etimer_expired(&periodic)) {
#if UIP_TCP
for(i = 0; i < UIP_CONNS; ++i) {
if(uip_conn_active(i)) {
/* Only restart the timer if there are active
for(i = 0; i < UIP_CONNS; ++i) {
if(uip_conn_active(i)) {
/* Only restart the timer if there are active
connections. */
etimer_restart(&periodic);
uip_periodic(i);
etimer_restart(&periodic);
uip_periodic(i);
#if NETSTACK_CONF_WITH_IPV6
tcpip_ipv6_output();
tcpip_ipv6_output();
#else
if(uip_len > 0) {
PRINTF("tcpip_output from periodic len %d\n", uip_len);
tcpip_output();
PRINTF("tcpip_output after periodic len %d\n", uip_len);
}
#endif /* NETSTACK_CONF_WITH_IPV6 */
}
if(uip_len > 0) {
PRINTF("tcpip_output from periodic len %d\n", uip_len);
tcpip_output();
PRINTF("tcpip_output after periodic len %d\n", uip_len);
}
#endif /* NETSTACK_CONF_WITH_IPV6 */
}
}
#endif /* UIP_TCP */
#if UIP_CONF_IP_FORWARD
uip_fw_periodic();
uip_fw_periodic();
#endif /* UIP_CONF_IP_FORWARD */
}
}
#if NETSTACK_CONF_WITH_IPV6
#if UIP_CONF_IPV6_REASSEMBLY
/*
* check the timer for reassembly
*/
if(data == &uip_reass_timer &&
etimer_expired(&uip_reass_timer)) {
uip_reass_over();
tcpip_ipv6_output();
}
/*
* check the timer for reassembly
*/
if(data == &uip_reass_timer &&
etimer_expired(&uip_reass_timer)) {
uip_reass_over();
tcpip_ipv6_output();
}
#endif /* UIP_CONF_IPV6_REASSEMBLY */
/*
* check the different timers for neighbor discovery and
* stateless autoconfiguration
*/
/*if(data == &uip_ds6_timer_periodic &&
/*
* check the different timers for neighbor discovery and
* stateless autoconfiguration
*/
/*if(data == &uip_ds6_timer_periodic &&
etimer_expired(&uip_ds6_timer_periodic)) {
uip_ds6_periodic();
tcpip_ipv6_output();
}*/
#if !UIP_CONF_ROUTER
if(data == &uip_ds6_timer_rs &&
etimer_expired(&uip_ds6_timer_rs)) {
uip_ds6_send_rs();
tcpip_ipv6_output();
}
if(data == &uip_ds6_timer_rs &&
etimer_expired(&uip_ds6_timer_rs)) {
uip_ds6_send_rs();
tcpip_ipv6_output();
}
#endif /* !UIP_CONF_ROUTER */
if(data == &uip_ds6_timer_periodic &&
etimer_expired(&uip_ds6_timer_periodic)) {
uip_ds6_periodic();
tcpip_ipv6_output();
}
if(data == &uip_ds6_timer_periodic &&
etimer_expired(&uip_ds6_timer_periodic)) {
uip_ds6_periodic();
tcpip_ipv6_output();
}
#endif /* NETSTACK_CONF_WITH_IPV6 */
}
break;
}
break;
#if UIP_TCP
case TCP_POLL:
if(data != NULL) {
uip_poll_conn(data);
case TCP_POLL:
if(data != NULL) {
uip_poll_conn(data);
#if NETSTACK_CONF_WITH_IPV6
tcpip_ipv6_output();
tcpip_ipv6_output();
#else /* NETSTACK_CONF_WITH_IPV6 */
if(uip_len > 0) {
PRINTF("tcpip_output from tcp poll len %d\n", uip_len);
tcpip_output();
}
#endif /* NETSTACK_CONF_WITH_IPV6 */
/* Start the periodic polling, if it isn't already active. */
start_periodic_tcp_timer();
if(uip_len > 0) {
PRINTF("tcpip_output from tcp poll len %d\n", uip_len);
tcpip_output();
}
break;
#endif /* NETSTACK_CONF_WITH_IPV6 */
/* Start the periodic polling, if it isn't already active. */
start_periodic_tcp_timer();
}
break;
#endif /* UIP_TCP */
#if UIP_UDP
case UDP_POLL:
if(data != NULL) {
uip_udp_periodic_conn(data);
case UDP_POLL:
if(data != NULL) {
uip_udp_periodic_conn(data);
#if NETSTACK_CONF_WITH_IPV6
tcpip_ipv6_output();
tcpip_ipv6_output();
#else
if(uip_len > 0) {
tcpip_output();
}
#endif /* UIP_UDP */
if(uip_len > 0) {
tcpip_output();
}
break;
#endif /* UIP_UDP */
}
break;
#endif /* UIP_UDP */
case PACKET_INPUT:
packet_input();
break;
case PACKET_INPUT:
packet_input();
break;
};
}
/*---------------------------------------------------------------------------*/
@ -563,25 +563,25 @@ tcpip_ipv6_output(void)
nexthop = uip_ds6_defrt_choose();
if(nexthop == NULL) {
#ifdef UIP_FALLBACK_INTERFACE
PRINTF("FALLBACK: removing ext hdrs & setting proto %d %d\n",
uip_ext_len, *((uint8_t *)UIP_IP_BUF + 40));
if(uip_ext_len > 0) {
extern void remove_ext_hdr(void);
uint8_t proto = *((uint8_t *)UIP_IP_BUF + 40);
remove_ext_hdr();
/* This should be copied from the ext header... */
UIP_IP_BUF->proto = proto;
}
/* Inform the other end that the destination is not reachable. If it's
* not informed routes might get lost unexpectedly until there's a need
* to send a new packet to the peer */
if(UIP_FALLBACK_INTERFACE.output() < 0) {
PRINTF("FALLBACK: output error. Reporting DST UNREACH\n");
uip_icmp6_error_output(ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADDR, 0);
uip_flags = 0;
tcpip_ipv6_output();
return;
}
PRINTF("FALLBACK: removing ext hdrs & setting proto %d %d\n",
uip_ext_len, *((uint8_t *)UIP_IP_BUF + 40));
if(uip_ext_len > 0) {
extern void remove_ext_hdr(void);
uint8_t proto = *((uint8_t *)UIP_IP_BUF + 40);
remove_ext_hdr();
/* This should be copied from the ext header... */
UIP_IP_BUF->proto = proto;
}
/* Inform the other end that the destination is not reachable. If it's
* not informed routes might get lost unexpectedly until there's a need
* to send a new packet to the peer */
if(UIP_FALLBACK_INTERFACE.output() < 0) {
PRINTF("FALLBACK: output error. Reporting DST UNREACH\n");
uip_icmp6_error_output(ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADDR, 0);
uip_flags = 0;
tcpip_ipv6_output();
return;
}
#else
PRINTF("tcpip_ipv6_output: Destination off-link but no route\n");
#endif /* !UIP_FALLBACK_INTERFACE */
@ -655,13 +655,13 @@ tcpip_ipv6_output(void)
uip_packetqueue_set_buflen(&nbr->packethandle, uip_len);
}
#endif
/* RFC4861, 7.2.2:
* "If the source address of the packet prompting the solicitation is the
* same as one of the addresses assigned to the outgoing interface, that
* address SHOULD be placed in the IP Source Address of the outgoing
* solicitation. Otherwise, any one of the addresses assigned to the
* interface should be used."*/
if(uip_ds6_is_my_addr(&UIP_IP_BUF->srcipaddr)){
/* RFC4861, 7.2.2:
* "If the source address of the packet prompting the solicitation is the
* same as one of the addresses assigned to the outgoing interface, that
* address SHOULD be placed in the IP Source Address of the outgoing
* solicitation. Otherwise, any one of the addresses assigned to the
* interface should be used."*/
if(uip_ds6_is_my_addr(&UIP_IP_BUF->srcipaddr)){
uip_nd6_ns_output(&UIP_IP_BUF->srcipaddr, NULL, &nbr->ipaddr);
} else {
uip_nd6_ns_output(NULL, NULL, &nbr->ipaddr);
@ -747,7 +747,7 @@ void
tcpip_uipcall(void)
{
uip_udp_appstate_t *ts;
#if UIP_UDP
if(uip_conn != NULL) {
ts = &uip_conn->appstate;
@ -759,30 +759,30 @@ tcpip_uipcall(void)
#endif /* UIP_UDP */
#if UIP_TCP
{
unsigned char i;
struct listenport *l;
{
unsigned char i;
struct listenport *l;
/* If this is a connection request for a listening port, we must
/* If this is a connection request for a listening port, we must
mark the connection with the right process ID. */
if(uip_connected()) {
l = &s.listenports[0];
for(i = 0; i < UIP_LISTENPORTS; ++i) {
if(l->port == uip_conn->lport &&
l->p != PROCESS_NONE) {
ts->p = l->p;
ts->state = NULL;
break;
}
++l;
}
/* Start the periodic polling, if it isn't already active. */
start_periodic_tcp_timer();
}
}
if(uip_connected()) {
l = &s.listenports[0];
for(i = 0; i < UIP_LISTENPORTS; ++i) {
if(l->port == uip_conn->lport &&
l->p != PROCESS_NONE) {
ts->p = l->p;
ts->state = NULL;
break;
}
++l;
}
/* Start the periodic polling, if it isn't already active. */
start_periodic_tcp_timer();
}
}
#endif /* UIP_TCP */
if(ts->p != NULL) {
process_post_synch(ts->p, tcpip_event, ts->state);
}
@ -793,14 +793,14 @@ PROCESS_THREAD(tcpip_process, ev, data)
PROCESS_BEGIN();
#if UIP_TCP
{
unsigned char i;
{
unsigned char i;
for(i = 0; i < UIP_LISTENPORTS; ++i) {
s.listenports[i].port = 0;
}
s.p = PROCESS_CURRENT();
}
for(i = 0; i < UIP_LISTENPORTS; ++i) {
s.listenports[i].port = 0;
}
s.p = PROCESS_CURRENT();
}
#endif
tcpip_event = process_alloc_event();
@ -813,7 +813,7 @@ PROCESS_THREAD(tcpip_process, ev, data)
#ifdef UIP_FALLBACK_INTERFACE
UIP_FALLBACK_INTERFACE.init();
#endif
/* initialize RPL if configured for using RPL */
/* initialize RPL if configured for using RPL */
#if NETSTACK_CONF_WITH_IPV6 && UIP_CONF_IPV6_RPL
rpl_init();
#endif /* UIP_CONF_IPV6_RPL */
@ -822,7 +822,7 @@ PROCESS_THREAD(tcpip_process, ev, data)
PROCESS_YIELD();
eventhandler(ev, data);
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/