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/OrbisQuartus/server/l4/ctl_client-l4.cpp

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 
00036 #include <l4/thread/thread.h>
00037 #include <mini_mpi.h>
00038 #include <daemon.h>
00039 #include <configuration.h>
00040 #include <mini_mpi-internal.h>
00041 #include "lwip.h"
00042 
00043 
00044 extern struct sockaddr_in head_addr;
00045 extern socket_ptr_t my_socket;
00046 
00047 #define MY_NC ((struct netconn*)my_socket.nc)
00048 
00049 
00050 void rcv_ctl_commands(void *unused)
00051 {
00052         while (!daemon_quitting() && !daemon_shuttingdown()) {
00053                 struct netbuf *inbuf;
00054                 while ((inbuf = netconn_recv(MY_NC)) != NULL) {
00055                         char data[MAX_MTU+1];
00056                         int cur_len = 0;
00057                         do {
00058                                 char *fragdata;
00059                                 unsigned short len;
00060                                 int left = MAX_MTU - cur_len;
00061                                 netbuf_data(inbuf, (void**)&fragdata, &len);
00062                                 memcpy(data + cur_len, fragdata,
00063                                        len > left ? left : len);
00064                                 cur_len += len;
00065                         } while(netbuf_next(inbuf) >= 0);
00066 
00068                 }
00069         }
00070 }
00071 
00072 
00073 void ctl_client(void *unused)
00074 {
00075         l4thread_create(rcv_ctl_commands, NULL, L4THREAD_CREATE_ASYNC);
00076 
00077         while (!daemon_quitting() && !daemon_shuttingdown()) {
00078                 int i, num_nodes = 0;
00079                 for (i = 0; i < num_nodes; i++) {
00080                         char status[1024];
00082                         netconn_write(MY_NC, status, sizeof(status),
00083                                       NETCONN_COPY);
00084                 }
00085         }
00086 }


© 2007, Los Alamos National Security, LLC.