Added *_close() function to all Rime modules

This commit is contained in:
adamdunkels 2007-03-19 22:10:16 +00:00
parent aa1389e873
commit e4a739a76c
22 changed files with 108 additions and 23 deletions

View file

@ -30,7 +30,7 @@
* *
* Author: Adam Dunkels <adam@sics.se> * Author: Adam Dunkels <adam@sics.se>
* *
* $Id: abc.c,v 1.5 2007/03/19 19:24:36 adamdunkels Exp $ * $Id: abc.c,v 1.6 2007/03/19 22:10:16 adamdunkels Exp $
*/ */
/** /**
@ -65,6 +65,12 @@ abc_open(struct abc_conn *c, u16_t channel,
list_add(channels, c); list_add(channels, c);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void
abc_close(struct abc_conn *c)
{
list_remove(channels, c);
}
/*---------------------------------------------------------------------------*/
int int
abc_send(struct abc_conn *c) abc_send(struct abc_conn *c)
{ {

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: abc.h,v 1.6 2007/03/19 19:24:37 adamdunkels Exp $ * $Id: abc.h,v 1.7 2007/03/19 22:10:16 adamdunkels Exp $
*/ */
/** /**
@ -80,6 +80,8 @@ struct abc_conn {
void abc_open(struct abc_conn *c, u16_t channel, void abc_open(struct abc_conn *c, u16_t channel,
const struct abc_callbacks *u); const struct abc_callbacks *u);
void abc_close(struct abc_conn *c);
/** /**
* \brief Send an anonymous best-effort broadcast packet * \brief Send an anonymous best-effort broadcast packet
* \param c The abc connection on which the packet should be sent * \param c The abc connection on which the packet should be sent

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: ccsabc.c,v 1.3 2007/03/19 19:24:37 adamdunkels Exp $ * $Id: ccsabc.c,v 1.4 2007/03/19 22:10:16 adamdunkels Exp $
*/ */
/** /**
@ -71,6 +71,12 @@ ccsabc_open(struct ccsabc_conn *c, u16_t channel,
sabc_open(&c->c, channel, &ccsabc); sabc_open(&c->c, channel, &ccsabc);
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void
ccsabc_close(struct ccsabc_conn *c)
{
sabc_close(&c->c);
}
/*---------------------------------------------------------------------------*/
int int
ccsabc_send_stubborn(struct ccsabc_conn *c, clock_time_t t) ccsabc_send_stubborn(struct ccsabc_conn *c, clock_time_t t)
{ {

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: ccsabc.h,v 1.3 2007/03/19 19:24:37 adamdunkels Exp $ * $Id: ccsabc.h,v 1.4 2007/03/19 22:10:16 adamdunkels Exp $
*/ */
/** /**
@ -60,6 +60,7 @@ struct ccsabc_conn {
void ccsabc_open(struct ccsabc_conn *c, u16_t channel, void ccsabc_open(struct ccsabc_conn *c, u16_t channel,
const struct ccsabc_callbacks *u); const struct ccsabc_callbacks *u);
void ccsabc_close(struct ccsabc_conn *c);
int ccsabc_send_stubborn(struct ccsabc_conn *c, clock_time_t t); int ccsabc_send_stubborn(struct ccsabc_conn *c, clock_time_t t);
void ccsabc_cancel(struct ccsabc_conn *c); void ccsabc_cancel(struct ccsabc_conn *c);

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: ibc.c,v 1.4 2007/03/19 19:24:37 adamdunkels Exp $ * $Id: ibc.c,v 1.5 2007/03/19 22:10:16 adamdunkels Exp $
*/ */
/** /**
@ -71,6 +71,12 @@ ibc_open(struct ibc_conn *c, u16_t channel,
c->u = u; c->u = u;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void
ibc_close(struct ibc_conn *c)
{
abc_close(&c->c);
}
/*---------------------------------------------------------------------------*/
int int
ibc_send(struct ibc_conn *c) ibc_send(struct ibc_conn *c)
{ {

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: ibc.h,v 1.4 2007/03/19 19:24:37 adamdunkels Exp $ * $Id: ibc.h,v 1.5 2007/03/19 22:10:16 adamdunkels Exp $
*/ */
/** /**
@ -57,6 +57,7 @@ struct ibc_conn {
void ibc_open(struct ibc_conn *c, u16_t channel, void ibc_open(struct ibc_conn *c, u16_t channel,
const struct ibc_callbacks *u); const struct ibc_callbacks *u);
void ibc_close(struct ibc_conn *c);
int ibc_send(struct ibc_conn *c); int ibc_send(struct ibc_conn *c);
#endif /* __IBC_H__ */ #endif /* __IBC_H__ */

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: mesh.c,v 1.3 2007/03/19 19:24:37 adamdunkels Exp $ * $Id: mesh.c,v 1.4 2007/03/19 22:10:17 adamdunkels Exp $
*/ */
/** /**
@ -292,6 +292,14 @@ mesh_open(const struct mesh_callbacks *callbacks,
send_datapacket_handler = send_datapacket; send_datapacket_handler = send_datapacket;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void
mesh_close(void)
{
uc_close(&mc.dataconn);
uc_close(&mc.rrepconn);
nf_close(&mc.rreqconn);
}
/*---------------------------------------------------------------------------*/
int int
mesh_send(rimeaddr_t *to) mesh_send(rimeaddr_t *to)
{ {

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: mesh.h,v 1.3 2007/03/19 19:24:37 adamdunkels Exp $ * $Id: mesh.h,v 1.4 2007/03/19 22:10:17 adamdunkels Exp $
*/ */
/** /**
@ -54,4 +54,6 @@ int mesh_send(rimeaddr_t *dest);
void mesh_data_received(rimeaddr_t *from); void mesh_data_received(rimeaddr_t *from);
void mesh_close(void);
#endif /* __MESH_H__ */ #endif /* __MESH_H__ */

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: nf.c,v 1.5 2007/03/19 19:24:37 adamdunkels Exp $ * $Id: nf.c,v 1.6 2007/03/19 22:10:17 adamdunkels Exp $
*/ */
/** /**
@ -157,6 +157,12 @@ nf_open(struct nf_conn *c, u16_t channel,
c->u = u; c->u = u;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void
nf_close(struct nf_conn *c)
{
ibc_close(&c->c);
}
/*---------------------------------------------------------------------------*/
int int
nf_send(struct nf_conn *c) nf_send(struct nf_conn *c)
{ {

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: nf.h,v 1.5 2007/03/19 19:24:37 adamdunkels Exp $ * $Id: nf.h,v 1.6 2007/03/19 22:10:17 adamdunkels Exp $
*/ */
/** /**
@ -65,6 +65,7 @@ struct nf_conn {
void nf_open(struct nf_conn *c, u16_t channel, void nf_open(struct nf_conn *c, u16_t channel,
const struct nf_callbacks *u); const struct nf_callbacks *u);
void nf_close(struct nf_conn *c);
int nf_send(struct nf_conn *c); int nf_send(struct nf_conn *c);

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: ruc.c,v 1.4 2007/03/19 19:24:37 adamdunkels Exp $ * $Id: ruc.c,v 1.5 2007/03/19 22:10:17 adamdunkels Exp $
*/ */
/** /**
@ -120,6 +120,12 @@ ruc_open(struct ruc_conn *c, u16_t channel,
c->u = u; c->u = u;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void
ruc_close(struct ruc_conn *c)
{
suc_close(&c->c);
}
/*---------------------------------------------------------------------------*/
int int
ruc_send(struct ruc_conn *c, rimeaddr_t *receiver) ruc_send(struct ruc_conn *c, rimeaddr_t *receiver)
{ {

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: ruc.h,v 1.4 2007/03/19 19:24:37 adamdunkels Exp $ * $Id: ruc.h,v 1.5 2007/03/19 22:10:17 adamdunkels Exp $
*/ */
/** /**
@ -58,6 +58,7 @@ struct ruc_conn {
void ruc_open(struct ruc_conn *c, u16_t channel, void ruc_open(struct ruc_conn *c, u16_t channel,
const struct ruc_callbacks *u); const struct ruc_callbacks *u);
void ruc_close(struct ruc_conn *c);
int ruc_send(struct ruc_conn *c, rimeaddr_t *receiver); int ruc_send(struct ruc_conn *c, rimeaddr_t *receiver);

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: sabc.c,v 1.3 2007/03/19 19:24:37 adamdunkels Exp $ * $Id: sabc.c,v 1.4 2007/03/19 22:10:17 adamdunkels Exp $
*/ */
/** /**
@ -64,6 +64,13 @@ sabc_open(struct sabc_conn *c, u16_t channel,
c->u = u; c->u = u;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void
sabc_close(struct sabc_conn *c)
{
abc_close(&c->c);
ctimer_setop(&c->t);
}
/*---------------------------------------------------------------------------*/
static void static void
send(void *ptr) send(void *ptr)
{ {

View file

@ -44,7 +44,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: sabc.h,v 1.3 2007/03/19 19:24:37 adamdunkels Exp $ * $Id: sabc.h,v 1.4 2007/03/19 22:10:17 adamdunkels Exp $
*/ */
/** /**
@ -98,7 +98,7 @@ struct sabc_conn {
*/ */
void sabc_open(struct sabc_conn *c, u16_t channel, void sabc_open(struct sabc_conn *c, u16_t channel,
const struct sabc_callbacks *u); const struct sabc_callbacks *u);
void sabc_close(struct sabc_conn *c);
/** /**
* \brief Send a stubborn message. * \brief Send a stubborn message.

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: sibc.c,v 1.4 2007/03/19 19:24:37 adamdunkels Exp $ * $Id: sibc.c,v 1.5 2007/03/19 22:10:17 adamdunkels Exp $
*/ */
/** /**
@ -63,6 +63,13 @@ sibc_open(struct sibc_conn *c, u16_t channel,
c->u = u; c->u = u;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void
sibc_close(struct sibc_conn *c)
{
ibc_close(&c->c);
ctimer_stop(&c->t);
}
/*---------------------------------------------------------------------------*/
static void static void
send(void *ptr) send(void *ptr)
{ {

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: sibc.h,v 1.4 2007/03/19 19:24:37 adamdunkels Exp $ * $Id: sibc.h,v 1.5 2007/03/19 22:10:17 adamdunkels Exp $
*/ */
/** /**
@ -61,6 +61,7 @@ struct sibc_conn {
void sibc_open(struct sibc_conn *c, u16_t channel, void sibc_open(struct sibc_conn *c, u16_t channel,
const struct sibc_callbacks *u); const struct sibc_callbacks *u);
void sibc_close(struct sibc_conn *c);
int sibc_send_stubborn(struct sibc_conn *c, clock_time_t t); int sibc_send_stubborn(struct sibc_conn *c, clock_time_t t);
void sibc_cancel(struct sibc_conn *c); void sibc_cancel(struct sibc_conn *c);

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: suc.c,v 1.4 2007/03/19 19:24:37 adamdunkels Exp $ * $Id: suc.c,v 1.5 2007/03/19 22:10:17 adamdunkels Exp $
*/ */
/** /**
@ -63,6 +63,13 @@ suc_open(struct suc_conn *c, u16_t channel,
c->u = u; c->u = u;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void
suc_close(struct suc_conn *c)
{
uc_close(&c->c);
ctimer_stop(&c->t);
}
/*---------------------------------------------------------------------------*/
static void static void
send(void *ptr) send(void *ptr)
{ {

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: suc.h,v 1.4 2007/03/19 19:24:37 adamdunkels Exp $ * $Id: suc.h,v 1.5 2007/03/19 22:10:17 adamdunkels Exp $
*/ */
/** /**
@ -62,6 +62,7 @@ struct suc_conn {
void suc_open(struct suc_conn *c, u16_t channel, void suc_open(struct suc_conn *c, u16_t channel,
const struct suc_callbacks *u); const struct suc_callbacks *u);
void suc_close(struct suc_conn *c);
int suc_send_stubborn(struct suc_conn *c, rimeaddr_t *receiver); int suc_send_stubborn(struct suc_conn *c, rimeaddr_t *receiver);
void suc_cancel(struct suc_conn *c); void suc_cancel(struct suc_conn *c);

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: tree.c,v 1.3 2007/03/19 19:24:37 adamdunkels Exp $ * $Id: tree.c,v 1.4 2007/03/19 22:10:17 adamdunkels Exp $
*/ */
/** /**
@ -193,6 +193,13 @@ tree_open(const struct tree_callbacks *cb)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
tree_close(void)
{
sibc_close(&sibc_conn);
ruc_close(&ruc_conn);
}
/*---------------------------------------------------------------------------*/
void
tree_set_sink(int should_be_sink) tree_set_sink(int should_be_sink)
{ {
if(should_be_sink) { if(should_be_sink) {

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: tree.h,v 1.2 2007/03/19 19:24:37 adamdunkels Exp $ * $Id: tree.h,v 1.3 2007/03/19 22:10:17 adamdunkels Exp $
*/ */
/** /**
@ -47,6 +47,7 @@ struct tree_callbacks {
}; };
void tree_open(const struct tree_callbacks *callbacks); void tree_open(const struct tree_callbacks *callbacks);
void tree_close(void);
void tree_send(void); void tree_send(void);

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: uc.c,v 1.4 2007/03/19 19:24:37 adamdunkels Exp $ * $Id: uc.c,v 1.5 2007/03/19 22:10:17 adamdunkels Exp $
*/ */
/** /**
@ -70,6 +70,12 @@ uc_open(struct uc_conn *c, u16_t channel,
c->u = u; c->u = u;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void
uc_close(struct uc_conn *c)
{
ibc_close(&c->c);
}
/*---------------------------------------------------------------------------*/
int int
uc_send(struct uc_conn *c, rimeaddr_t *receiver) uc_send(struct uc_conn *c, rimeaddr_t *receiver)
{ {

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: uc.h,v 1.4 2007/03/19 19:24:37 adamdunkels Exp $ * $Id: uc.h,v 1.5 2007/03/19 22:10:17 adamdunkels Exp $
*/ */
/** /**
@ -56,6 +56,8 @@ struct uc_conn {
void uc_open(struct uc_conn *c, u16_t channel, void uc_open(struct uc_conn *c, u16_t channel,
const struct uc_callbacks *u); const struct uc_callbacks *u);
void uc_close(struct uc_conn *c);
int uc_send(struct uc_conn *c, rimeaddr_t *receiver); int uc_send(struct uc_conn *c, rimeaddr_t *receiver);
#endif /* __UC_H__ */ #endif /* __UC_H__ */