Code Search for Developers
 
 
  

dqt.h from EmStar at Krugle


Show dqt.h syntax highlighted

/*
 *
 * Copyright (c) 2003 The Regents of the University of California.  All 
 * rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * - Redistributions of source code must retain the above copyright
 *   notice, this list of conditions and the following disclaimer.
 *
 * - Neither the name of the University nor the names of its
 *   contributors may be used to endorse or promote products derived
 *   from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS''
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 * PARTICULAR  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */
 

#ifndef DQT_H
#define DQT_H

#include "link/link.h"

  /* An application populates the dqt_pkt_t header as follows:
     cmd = DQT_UP or DQT_DOWN
     quadrant = DQT_{LOW,HIGH}X_{LOW,HIGH}Y only if cmd is DQT_DOWN,
                if cmd is up, then quadrant will be set to child
                message came from
     level = src_level, this must be translated to dst level before sent
     cell_{x,y} = cell location of src, translated to dst before sent. It
     is expected that the application leave these fields intact as messages
     propagate up and down the tree. The dqt layer handles populating it
     upon tree entry.
  */
/*
typedef struct dqt_pkt {
  uint8_t cmd;
  uint8_t quadrant;
  uint8_t level;
  uint8_t flags;
  uint16_t cell_x;
  uint16_t cell_y;
  uint32_t random_id;
  uint32_t seqno;
  uint32_t flowid;
  uint8_t data[0];
} dqt_pkt_t;
*/
typedef struct dqt_pkt {
    unsigned int cmd : 4;
    unsigned int quadrant : 4;
    unsigned int level : 4;
    unsigned int flags : 4;
    uint8_t cell_x;
    uint8_t cell_y;
    uint16_t random_id;
    uint8_t seqno;
    uint8_t flowid;
    uint8_t data[0];
} dqt_pkt_t;

#define DQTD_DEFAULT_INDEX 3
/* #define DQTD_DEFAULT_INDEX LINK_INDEX_AUTO */
#define DQTD_MAX_MTU       65536 /* dqt_pkt_t + link_pkt_t + data */

/*command values */
#define DQT_UP          0x1
#define DQT_DOWN        0x2
#define DQT_TO_LOCATION 0x3
 
/* quadrant values */
#define DQT_NA          0x0
#define DQT_LOWX_LOWY   0x1 
#define DQT_LOWX_HIGHY  0x2
#define DQT_HIGHX_LOWY  0x4
#define DQT_HIGHX_HIGHY 0x8

/* flags values */
#define DQT_UNDELIVERABLE 0x1
#define DQT_REQUEST_ACK   0x2
#define DQT_ACK           0x4

#define DQT_DEFAULT_TREE_LEVELS 5
#define DQT_DEFAULT_NODE_ROTATION_PERIOD 60000 /* milliseconds */
#define DQT_NODE_ROTATION_CONSTANT 1
#define DQT_NODE_ROTATION_EXPONENTIAL 2
#define DQT_NODE_ROTATION_LINEAR 3
#define DQT_DEFAULT_NODE_ROTATION_TIMING DQT_NODE_ROTATION_CONSTANT
#define DQT_MAX_TREE_LEVELS 11 /* 4^(11-1) ~ 1,000,000 leaves,*/

#define DQT_SUCCESS 0
#define DQT_FAILURE 1
#define DQT_TRUE 1
#define DQT_FALSE 0

inline void dump_dqt_packet(link_pkt_t *l, char *w, int lvl){
  dqt_pkt_t *d = (dqt_pkt_t *)(l->data);
  elog(LOG_DEBUG(lvl), "************************************************");
  elog(LOG_DEBUG(lvl), "%s",w);
  /* since id and loc are in union, only one will make sense */
  elog(LOG_DEBUG(lvl), "LINK: %s (%f, %f) -> %s (%f, %f) pkttype %d",
       print_if_id(l->src.id), l->src.loc.x, l->src.loc.y, 
       print_if_id(l->dst.id), l->dst.loc.x, l->dst.loc.y, l->type);
  elog(LOG_DEBUG(lvl), "DQT:  cmd %d quad %d level %d cell (%d,%d) flags %d id %d seqno %d flowid %d",
       d->cmd, d->quadrant, d->level, d->cell_x, d->cell_y, d->flags, 
       d->random_id, d->seqno, d->flowid);
  elog(LOG_DEBUG(lvl), "************************************************");
}


#endif




See more files for this project here

EmStar

EmStar is a software system for developing and deploying wireless sensor networks involving Linux-based platforms. As the wireless sensor network community has attempted to deploy more complex designs---large-scale, long-lived systems that need self-organization and adaptivity---a number of difficult software design issues have arisen. Advances in software design have not kept pace with the capabilities of hardware. This is because designing for an adaptive, efficient, and useful sensor network has turned out to be surprisingly complex and difficult. EmStar is a Linux-based software framework, whose goal is to dramatically reduce this complexity, enabling work to be shared and reused, and simplifying and speeding the design of new sensor network applications.

Project homepage: http://cvs.cens.ucla.edu/emstar/
Programming language(s): C,Shell Script
License: other

  dqt.h