N-sim
Emulation and simulation of
Wireless Sensor Networks



   Home


   Project Page


   Download


   CVS



   Installation


   Configuration


   Plug-ins




 Hosted by
SourceForge.net Logo

/home/brennan/n-sim/Vaike/linux/system-addons/networking/mesh_net.h

Go to the documentation of this file.
00001 
00014 /*
00015  * Copyright 2007. Los Alamos National Security, LLC. This material
00016  * was produced under U.S. Government contract DE-AC52-06NA25396 for
00017  * Los Alamos National Laboratory (LANL), which is operated by Los
00018  * Alamos National Security, LLC, for the Department of Energy. The
00019  * U.S. Government has rights to use, reproduce, and distribute this
00020  * software. NEITHER THE GOVERNMENT NOR LOS ALAMOS NATIONAL SECURITY,
00021  * LLC, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL
00022  * LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified to
00023  * produce derivative works, such modified software should be clearly
00024  * marked, so as not to confuse it with the version available from LANL.
00025  *
00026  * Additionally, this program is free software; you can redistribute
00027  * it and/or modify it under the terms of the GNU General Public
00028  * License as published by the Free Software Foundation; version 2 of
00029  * the License. Accordingly, this program is distributed in the hope
00030  * it will be useful, but WITHOUT ANY WARRANTY; without even the
00031  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00032  * PURPOSE. See the GNU General Public License for more details.
00033  */
00034 
00035 #ifndef _MESH_NET_H_
00036 #define _MESH_NET_H_
00037 
00038 #include <netinet/in.h>
00039 #include <netinet/ip.h>
00040 #include <netinet/udp.h>
00041 #include <net/ethernet.h>
00042 
00043 struct _self;
00044 struct _protocol;
00045 
00046 #define NET_ADDR_LEN   23
00047 #define MAC_ADDR_LEN   8  /* ETH_ALEN == 6 */
00048 
00049 
00050 typedef u_int32_t seqnum_t;
00051 
00052 struct mesh_hdr {
00053   u_int8_t raw;
00054   u_int8_t nack;
00055   u_int16_t protocol_id;
00056   seqnum_t seq_num;
00057 };
00058 
00059 #define MESH_HEADER_SPACE  (ETHER_HDR_LEN + sizeof(struct ip) + \
00060                             sizeof(struct udphdr) + sizeof(struct mesh_hdr))
00061 
00062 
00063 int reliable_net(struct _self *self);
00064 int mesh_socket(char *ifname, unsigned int port);
00065 
00066 
00067 ssize_t mesh_raw_send(struct _protocol *proto,
00068                       int sd, void *buf, size_t len, struct sockaddr_in *to);
00069 ssize_t mesh_send(struct _protocol *proto,
00070                   int sd, void *buf, size_t len, struct sockaddr_in *to);
00071 ssize_t mesh_recv(struct _self *self,
00072                   int sd, void *buf, size_t len, struct sockaddr_in *from);
00073 
00074 ssize_t mesh_send_nextdoor(struct _self *self, int sd, void *buf, size_t len,
00075                            double angle, double dist);
00076 ssize_t mesh_recv_nextdoor(struct _self *self, int sd, void *buf, size_t len,
00077                            double *angle, double *dist);
00078 
00079 int timed_recv(int sd, void *buf, int bytes, struct sockaddr_in *sa,
00080                int timeout);
00081 int timed_recv_peek(int sd, void *buf, int bytes, struct sockaddr_in *sa,
00082                     int timeout);
00083 
00084 
00085 ssize_t mesh_sendmsg(char *ifname, char *ifaddr,
00086                      int sd, void *buf, size_t len, struct sockaddr_in *to);
00087 ssize_t mesh_recvmsg(int sd, void *buf, size_t len, struct sockaddr_in *from,
00088                      struct msghdr *msg_header, size_t ctl_msg_size);
00089 
00090 
00091 #endif  //  _MESH_NET_H_


© 2007, Los Alamos National Security, LLC.