00001
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef _SIM_IF_H_
00037 #define _SIM_IF_H_
00038
00039 #include <stdlib.h>
00040 #include <string.h>
00041 #include <sys/time.h>
00042
00043 #include "oq.h"
00044
00045
00046 struct list_head {
00047 struct list_head *next, *prev;
00048 };
00049
00050
00051 # define OQ_MAGIC 0xAA
00052 # define OQ_RESP_INIT _IOR(OQ_MAGIC, 1, int)
00053 # define OQ_RESP_REINIT _IOR(OQ_MAGIC, 2, int)
00054 # define OQ_RESP_RESULT _IOWR(OQ_MAGIC, 3, int)
00055 # define OQ_RESP_PAUSE _IO(OQ_MAGIC, 4)
00056
00057 # define OQ_REQ_RECONFIG (INT_MAX - OQ_MAGIC)
00058 # define OQ_REQ_REPEAT ((INT_MAX - OQ_MAGIC) - 1)
00059
00060 enum { OQ_RADIO_TX = 1, OQ_RADIO_RX = 2, };
00061
00062 # define OQ_MAC_BUFS 4
00063 # define OQ_MAC_LEN 128
00064 # define V_MTU 256
00065
00066
00067 struct sock_buff {
00068 unsigned short tx_rx;
00069 unsigned short to_me;
00070 unsigned short is_base;
00071
00072 char mac[OQ_MAC_LEN];
00073 unsigned long length;
00074 unsigned long long seq_num;
00075
00076 unsigned long slot_time;
00077 unsigned int slot_idx;
00078 unsigned int next_slot;
00079
00080 int code;
00081 void *skbuf;
00082 };
00083
00084
00085
00086
00087 typedef struct oq_req_resp {
00088 struct list_head list;
00089 struct sock_buff msgs[OQ_MAC_BUFS];
00090 unsigned int num_msgs;
00091
00092 char type[MAX_NAME];
00093 int node_id;
00094 int sensor_id;
00095 char data[V_MTU];
00096 int size;
00097 struct timespec timestamp;
00098 } oq_req_resp_t;
00099
00100
00101
00102
00103 static inline oq_req_resp_t *new_req_resp(void)
00104 {
00105 struct oq_req_resp *request =
00106 (struct oq_req_resp *) malloc(sizeof(struct oq_req_resp));
00107 return request;
00108 }
00109
00110
00111
00112 static inline struct oq_req_resp *new_request(char *type, int node, int sensor,
00113 char *data, unsigned long time)
00114 {
00115 struct oq_req_resp *request = new_req_resp();
00116
00117 strncpy(request->type, type, MAX_NAME);
00118 request->node_id = node;
00119 request->sensor_id = sensor;
00120 strcpy(request->data, data);
00121 return request;
00122 }
00123
00124
00125
00126 static inline struct oq_req_resp *new_response(unsigned long arg)
00127 {
00128 struct oq_req_resp *response = new_req_resp();
00129 memcpy(response, (oq_req_resp_t *) arg, sizeof(oq_req_resp_t));
00130 return response;
00131 }
00132
00133
00134 void sim_if_service(int nodes[], int num_nodes);
00135
00136
00137 struct sensor_stats {
00138 unsigned int id;
00139 unsigned long rx_bytes, rx_errors, rx_dropped, rx_overruns;
00140 unsigned long tx_bytes, tx_errors, tx_dropped, tx_overruns;
00141 };
00142
00143
00144 #endif