Reformatted the code to make it consistent with the rest of lwIP.

This commit is contained in:
adamdunkels 2002-11-02 20:40:06 +00:00
parent 4e4da8e019
commit 01cccf4aee

View File

@ -55,7 +55,8 @@ typedef struct slip_status_t {
static slip_status_t statusar[SLIPIF_NUM_OF_INTERFACES];
/*-----------------------------------------------------------------------------------*/
err_t slipif_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr)
err_t
slipif_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr)
{
slip_status_t *slipState = (slip_status_t *)netif->state;
struct pbuf *q;
@ -87,11 +88,10 @@ err_t slipif_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr)
return 0;
}
/*-----------------------------------------------------------------------------------*/
static struct pbuf * slipif_input( struct netif * netif )
static struct pbuf *
slipif_input( struct netif * netif )
{
slip_status_t *slipState = (slip_status_t *)netif->state;
u8_t c;
struct pbuf *p, *q;
int recved;
@ -101,23 +101,19 @@ static struct pbuf * slipif_input( struct netif * netif )
recved = i = 0;
c = 0;
while ( 1 )
{
while(1) {
c = sio_recv(slipState->sio);
switch ( c )
{
switch(c) {
case SLIP_END:
if ( p == NULL )
{
if(p == NULL) {
return slipif_input(netif);
}
if ( recved > 0 )
{
if(recved > 0) {
/* Received whole packet. */
pbuf_realloc(q, recved);
#ifdef LINK_STATS
stats.link.recv++;
++stats.link.recv;
#endif /* LINK_STATS */
DEBUGF(SLIP_DEBUG, ("slipif: Got packet\n"));
@ -127,8 +123,7 @@ static struct pbuf * slipif_input( struct netif * netif )
case SLIP_ESC:
c = sio_recv(slipState->sio);
switch ( c )
{
switch(c) {
case SLIP_ESC_END:
c = SLIP_END;
break;
@ -139,35 +134,28 @@ static struct pbuf * slipif_input( struct netif * netif )
/* FALLTHROUGH */
default:
if ( p == NULL )
{
if(p == NULL) {
DEBUGF(SLIP_DEBUG, ("slipif_input: alloc\n"));
p = pbuf_alloc(PBUF_LINK, 128, PBUF_POOL);
#ifdef LINK_STATS
if ( p == NULL )
{
stats.link.drop++;
if(p == NULL) {
++stats.link.drop;
DEBUGF(SLIP_DEBUG, ("slipif_input: no new pbuf! (DROP)\n"));
}
#endif /* LINK_STATS */
if ( q != NULL )
{
if(q != NULL) {
pbuf_chain(q, p);
}
else
{
} else {
q = p;
}
}
if ( p != NULL && recved < MAX_SIZE )
{
if(p != NULL && recved < MAX_SIZE) {
((u8_t *)p->payload)[i] = c;
recved++;
i++;
if ( i >= p->len )
{
if(i >= p->len) {
i = 0;
p = NULL;
}
@ -179,11 +167,12 @@ static struct pbuf * slipif_input( struct netif * netif )
return NULL;
}
/*-----------------------------------------------------------------------------------*/
static void slipif_loop(void *nf)
static void
slipif_loop(void *nf)
{
struct pbuf *p;
struct netif *netif = (struct netif *)nf;
// slip_status_t *slipState = (slip_status_t *) netif->state;
/* slip_status_t *slipState = (slip_status_t *) netif->state; */
while(1) {
p = slipif_input(netif);
@ -191,32 +180,13 @@ static void slipif_loop(void *nf)
}
}
/*-----------------------------------------------------------------------------------*/
// void
// sioslipif_init0(struct netif *netif)
// {
// slip_status_t * ss;
// printf("slipif_init0: netif->num=%x\n", (int)netif->num);
//
// netif->state = &statusar[0];
// netif->name[0] = 's';
// netif->name[1] = 'l';
// netif->output = sioslipif_output;
// netif->num = 0;
//
// sio_open( netif );
// ss = (slip_status_t*)(netif->state);
// printf("slipif_init0: netif=%x sio=0x%x\n", (int)netif, (int)(ss->sio));
// sys_thread_new((void *)slipif_loop, netif);
// }
/*-----------------------------------------------------------------------------------*/
void slipif_init(struct netif *netif)
void
slipif_init(struct netif *netif)
{
slip_status_t *slipState;
DEBUGF(SLIP_DEBUG, ("slipif_init: netif->num=%x\n", (int)netif->num));
if ( netif->num >= SLIPIF_NUM_OF_INTERFACES )
{
if(netif->num >= SLIPIF_NUM_OF_INTERFACES) {
DEBUGF( SLIP_DEBUG, ("ERROR: To many slipifs"));
return;
}