00021 {
00022
00023
int i, j, l, err;
00024
struct mac_ifinfo *ifinfo_ptr = NULL;
00025
struct mac_ifinfo_list *temp;
00026
struct mac_params *params_ptr = NULL;
00027
struct mac_params_flags *flags_ptr = NULL;
00028
struct ether_header *eth_hdr = NULL;
00029
char *payload = NULL;
00030
unsigned short len = 0;
00031
unsigned char *send_parameter_info = NULL, *recv_parameter_info = NULL;
00032
00033
if (argc < 2) {
00034 printf(
"Usage: ./receiver name_of_interface.\n");
00035
return(-1);
00036 }
00037
00038
00039
00040
00041
if ( (err =
mac_get_ifinfo(&ifinfo_ptr)) )
00042 {
00043
#ifdef DEBUG_ERR
00044
printf(
"Error, error code: %d, %s\n\n", err, strerror(err));
00045
#endif
00046
return err;
00047 }
00048
00049
00050
if ( (err =
mac_init_params(¶ms_ptr, &flags_ptr)) )
00051 {
00052
#ifdef DEBUG_ERR
00053
printf(
"Error, error code: %d, %s\n\n", err, strerror(err));
00054
#endif
00055
return err;
00056 }
00057
00058
00059
#ifdef DEBUG_BASIC
00060
00061 temp = ifinfo_ptr->mac_list;
00062
while (temp != NULL)
00063 {
00064
00065
if ( !(strcmp(temp->if_name, argv[1])) )
00066 {
00067 printf(
"----------- FOR INTERFACE %s ---------\n", temp->if_name);
00068
00069
00070
00071
if ( (err =
mac_get_params(params_ptr, temp, 4, mac_rssi,
00072 mac_txpower, mac_noise,
00073 mac_currentXmitRate)) )
00074 {
00075
#ifdef DEBUG_ERR
00076
printf(
"Error, error code: %d, %s\n\n", err, strerror(err));
00077
#endif
00078
return err;
00079 }
00080
00081
00082 printf(
"----------- VALUES AFTER CALL TO GET ------------\n");
00083
for (i =
START_PARAMS_KEY; i < 4; i++)
00084 printf(
"Key: %d, Value: %d\n", params_ptr->key[i],
00085 params_ptr->value[i]);
00086
00087
if ( (err =
mac_set_params(params_ptr, temp, 3,
00088 mac_noise, 10, mac_rssi, 88,
00089 mac_currentXmitRate, 2000000)) )
00090 {
00091
#ifdef DEBUG_ERR
00092
printf(
"Error, error code: %d, %s\n\n", err, strerror(err));
00093
#endif
00094
return err;
00095 }
00096
00097
00098
00099
00100
00101
00102
00103 printf(
"------------ VALUES AFTER CALL TO SET -----------------\n");
00104
for (i =
START_PARAMS_KEY; i < 4; i++)
00105 {
00106 printf(
"Key: %d, Value: %d\n", params_ptr->key[i],
00107 params_ptr->value[i]);
00108 }
00109
00110
00111
00112
00113
00114
if ( (err =
mac_append_params(temp, INCOMING, 2,
00115 mac_noise, mac_rssi)) )
00116 {
00117
#ifdef DEBUG_ERR
00118
printf(
"Error, error code: %d, %s\n\n", err, strerror(err));
00119
#endif
00120
return err;
00121 }
00122
00123
00124
for (i=0;i<2;i++)
00125 {
00126 eth_hdr = NULL;
00127 payload = NULL;
00128 len = 0;
00129 send_parameter_info = NULL;
00130 recv_parameter_info = NULL;
00131
00132
if ( (err =
mac_recv(ð_hdr, &payload, &len,
00133 &send_parameter_info,
00134 &recv_parameter_info, temp,
"")) )
00135 {
00136
#ifdef DEBUG_ERR
00137
printf(
"Error, error code: %d, %s\n\n", err, strerror(err));
00138
#endif
00139
return err;
00140 }
00141
00142 printf(
"Src MAC addr: %s\n",
00143
pr_ether((
unsigned char *)((eth_hdr)->ether_shost)));
00144 printf(
"Dst MAC addr: %s\n",
00145
pr_ether((
unsigned char *)((eth_hdr)->ether_dhost)));
00146 printf(
"TYPE: %x\n", htons( (eth_hdr)->ether_type ) );
00147
00148
00149 printf(
"Length of just payload: %d\n", len);
00150
00151
00152
if ( (send_parameter_info) != NULL )
00153 {
00154
00155 params_ptr->number_of_params = *send_parameter_info;
00156
00157
00158
00159 l =
SIZEOF_PARAMS_LIST_LEN +
00160 ( (params_ptr->number_of_params) *
00161 (
SIZEOF_PARAMS_LIST_KEY +
SIZEOF_PARAMS_LIST_VALUE) );
00162
for(j=
SIZEOF_PARAMS_LIST_LEN;j < l;
00163 j=j+
SIZEOF_PARAMS_LIST_VALUE)
00164 {
00165 printf(
"Param key: %d\n", send_parameter_info[j]);
00166 j = j+
SIZEOF_PARAMS_LIST_KEY;
00167 printf(
"Param value: %hd",
00168 *((
unsigned short *)(send_parameter_info + j)));
00169 printf(
"\n");
00170 }
00171
00172
00173
if ( (recv_parameter_info) != NULL )
00174 {
00175
00176 params_ptr->number_of_params = *recv_parameter_info;
00177
00178
00179
00180 l =
SIZEOF_PARAMS_LIST_LEN +
00181 ((params_ptr->number_of_params) *
00182 (
SIZEOF_PARAMS_LIST_KEY +
SIZEOF_PARAMS_LIST_VALUE));
00183
for(j=
SIZEOF_PARAMS_LIST_LEN;j < l;
00184 j=j+
SIZEOF_PARAMS_LIST_VALUE)
00185 {
00186 printf(
"Param key: %d\n", recv_parameter_info[j]);
00187
if (recv_parameter_info[j] ==
mac_noise) {
00188 j = j+
SIZEOF_PARAMS_LIST_KEY;
00189 printf(
"Param value: %d",
00190 *((
unsigned short *)(recv_parameter_info + j)) - 256);
00191 printf(
"\n");
00192 }
else {
00193 j = j+
SIZEOF_PARAMS_LIST_KEY;
00194 printf(
"Param value: %hd",
00195 *((
unsigned short *)(recv_parameter_info + j)));
00196 printf(
"\n");
00197 }
00198 }
00199 }
00200 }
00201
else
00202 {
00203
if ( (recv_parameter_info) != NULL )
00204 {
00205
00206 params_ptr->number_of_params = *recv_parameter_info;
00207
00208
00209
00210 l =
SIZEOF_PARAMS_LIST_LEN +
00211 ((params_ptr->number_of_params) *
00212 (
SIZEOF_PARAMS_LIST_KEY +
SIZEOF_PARAMS_LIST_VALUE));
00213
for(j=
SIZEOF_PARAMS_LIST_LEN;j < l;
00214 j=j+
SIZEOF_PARAMS_LIST_VALUE)
00215 {
00216 printf(
"Param key: %d\n", recv_parameter_info[j]);
00217
if (recv_parameter_info[j] ==
mac_noise) {
00218 j = j+
SIZEOF_PARAMS_LIST_KEY;
00219 printf(
"Param value: %d",
00220 *((
unsigned short *)(recv_parameter_info + j)) - 256);
00221 printf(
"\n");
00222 }
else {
00223 j = j+
SIZEOF_PARAMS_LIST_KEY;
00224 printf(
"Param value: %hd",
00225 *((
unsigned short *)(recv_parameter_info + j)));
00226 printf(
"\n");
00227 }
00228 }
00229 }
00230 }
00231 }
00232 }
00233 temp = temp->next;
00234 }
00235
#endif
00236
00237
00238
00239
00240
mac_free_params(¶ms_ptr, &flags_ptr);
00241
00242
mac_free_ifinfo(&ifinfo_ptr);
00243
00244
00245
00246
return 0;
00247 }