Contiki 2.6

rimeaddr.c

Go to the documentation of this file.
00001 /**
00002  * \addtogroup rimeaddr
00003  * @{
00004  */
00005 
00006 /*
00007  * Copyright (c) 2007, Swedish Institute of Computer Science.
00008  * All rights reserved.
00009  *
00010  * Redistribution and use in source and binary forms, with or without
00011  * modification, are permitted provided that the following conditions
00012  * are met:
00013  * 1. Redistributions of source code must retain the above copyright
00014  *    notice, this list of conditions and the following disclaimer.
00015  * 2. Redistributions in binary form must reproduce the above copyright
00016  *    notice, this list of conditions and the following disclaimer in the
00017  *    documentation and/or other materials provided with the distribution.
00018  * 3. Neither the name of the Institute nor the names of its contributors
00019  *    may be used to endorse or promote products derived from this software
00020  *    without specific prior written permission.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
00023  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00024  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00025  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
00026  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00027  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00028  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00029  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00031  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00032  * SUCH DAMAGE.
00033  *
00034  * This file is part of the Contiki operating system.
00035  *
00036  * $Id: rimeaddr.c,v 1.9 2008/11/30 18:26:57 adamdunkels Exp $
00037  */
00038 
00039 /**
00040  * \file
00041  *         Functions for manipulating Rime addresses
00042  * \author
00043  *         Adam Dunkels <adam@sics.se>
00044  */
00045 
00046 #include "net/rime/rimeaddr.h"
00047 
00048 rimeaddr_t rimeaddr_node_addr;
00049 #if RIMEADDR_SIZE == 2
00050 const rimeaddr_t rimeaddr_null = { { 0, 0 } };
00051 #else /*RIMEADDR_SIZE == 2*/
00052 #if RIMEADDR_SIZE == 8
00053 const rimeaddr_t rimeaddr_null = { { 0, 0, 0, 0, 0, 0, 0, 0 } };
00054 #endif /*RIMEADDR_SIZE == 8*/
00055 #endif /*RIMEADDR_SIZE == 2*/
00056 
00057 
00058 /*---------------------------------------------------------------------------*/
00059 void
00060 rimeaddr_copy(rimeaddr_t *dest, const rimeaddr_t *src)
00061 {
00062   uint8_t i;
00063   for(i = 0; i < RIMEADDR_SIZE; i++) {
00064     dest->u8[i] = src->u8[i];
00065   }
00066 }
00067 /*---------------------------------------------------------------------------*/
00068 int
00069 rimeaddr_cmp(const rimeaddr_t *addr1, const rimeaddr_t *addr2)
00070 {
00071   uint8_t i;
00072   for(i = 0; i < RIMEADDR_SIZE; i++) {
00073     if(addr1->u8[i] != addr2->u8[i]) {
00074       return 0;
00075     }
00076   }
00077   return 1;
00078 }
00079 /*---------------------------------------------------------------------------*/
00080 void
00081 rimeaddr_set_node_addr(rimeaddr_t *t)
00082 {
00083   rimeaddr_copy(&rimeaddr_node_addr, t);
00084 }
00085 /*---------------------------------------------------------------------------*/
00086 /** @} */