00029 {
00030
00031
int i, err;
00032
struct mac_ifinfo *ptr = NULL;
00033
struct mac_ifinfo_list *temp;
00034
struct mac_params *params_ptr = NULL;
00035
struct mac_params_flags *flags_ptr = NULL;
00036
char payload[
PRESET_PAYLOAD_SIZE];
00037
unsigned char ucast_mac[
MACSIZE];
00038
00039
if (argc < 2) {
00040 printf(
"Usage: ./sender name_of_interface.\n");
00041
return(-1);
00042 }
00043
00044
00045 memset(payload,
'a', PRESET_PAYLOAD_SIZE);
00046
00047
00048 ucast_mac[0] = 0x00;
00049 ucast_mac[1] = 0x02;
00050 ucast_mac[2] = 0x2D;
00051 ucast_mac[3] = 0x6D;
00052 ucast_mac[4] = 0x16;
00053 ucast_mac[5] = 0xAB;
00054
00055
00056
00057
if ( (err =
mac_get_ifinfo(&ptr)) )
00058 {
00059
#ifdef DEBUG_ERR
00060
printf(
"Error, error code: %d, %s\n\n", err, strerror(err));
00061
#endif
00062
return err;
00063 }
00064
00065
00066
if ( (err =
mac_init_params(¶ms_ptr, &flags_ptr)) )
00067 {
00068
#ifdef DEBUG_ERR
00069
printf(
"Error, error code: %d, %s\n\n", err, strerror(err));
00070
#endif
00071
return err;
00072 }
00073
00074
00075
#ifdef DEBUG_BASIC
00076
00077 temp = ptr->mac_list;
00078
while (temp != NULL)
00079 {
00080
00081
if ( !(strcmp(temp->if_name, argv[1])) )
00082 {
00083
#ifdef DEBUG_ADV
00084
fprintf(stdout,
"%s: %s (ip_addr), %s (hw_addr)\n", temp->if_name,
00085 temp->ip_addr,
pr_ether(temp->hw_addr));
00086
if(temp->mac_flag)
00087 fprintf(stdout,
"%s: Wireless interface\n", temp->if_name);
00088
else
00089 fprintf(stdout,
"%s: Not wireless interface\n", temp->if_name);
00090
if( (temp->link_struct == NULL) && (temp->pcap_descr == NULL) )
00091 fprintf(stdout,
"%s: libnet and libpcap pointers are NULL\n",
00092 temp->if_name);
00093
#endif
00094
00095 printf(
"---------- FOR INTERFACE %s -----------\n", temp->if_name);
00096
00097
00098
00099
if ( (err =
mac_get_params(params_ptr, temp, 4, mac_rssi,
00100 mac_txpower, mac_noise,
00101 mac_currentXmitRate)) )
00102 {
00103
#ifdef DEBUG_ERR
00104
printf(
"Error, error code: %d, %s\n\n", err, strerror(err));
00105
#endif
00106
return err;
00107 }
00108
00109
00110 printf(
"----------- VALUES AFTER CALL TO GET -----------------\n");
00111
for (i =
START_PARAMS_KEY; i < 4; i++)
00112 printf(
"Key: %d, Value: %d\n", params_ptr->key[i], params_ptr->value[i]);
00113
00114
if ( (err =
mac_set_params(params_ptr, temp, 4, mac_noise, 10,
00115 mac_rssi, 88, mac_txpower, 50,
00116 mac_currentXmitRate, 11000000)) )
00117 {
00118
#ifdef DEBUG_ERR
00119
printf(
"Error, error code: %d, %s\n\n", err, strerror(err));
00120
#endif
00121
return err;
00122 }
00123
00124
00125
00126
00127
00128
00129
00130 printf(
"----------- VALUES AFTER CALL TO SET -----------------\n");
00131
for (i =
START_PARAMS_KEY; i < 4; i++)
00132 {
00133 printf(
"Key: %d, Value: %d\n", params_ptr->key[i],
00134 params_ptr->value[i]);
00135 }
00136
00137
00138
00139
00140
00141
if ( (err =
mac_append_params(temp, OUTGOING, 2, mac_txpower,
00142 mac_currentXmitRate)) )
00143 {
00144
#ifdef DEBUG_ERR
00145
printf(
"Error, error code: %d, %s\n\n", err, strerror(err));
00146
#endif
00147
return err;
00148 }
00149
00150
for (i=0;i<2;i++)
00151 {
00152
00153
00154
00155
if ( (err =
mac_send_broadcast(payload, PRESET_PAYLOAD_SIZE,
00156 temp)) )
00157 {
00158
#ifdef DEBUG_ERR
00159
printf(
"Error, error code: %d, %s\n\n", err, strerror(err));
00160
#endif
00161
return err;
00162 }
00163 }
00164 }
00165 temp = temp->next;
00166 }
00167
#endif
00168
00169
00170
00171
00172
mac_free_params(¶ms_ptr, &flags_ptr);
00173
00174
mac_free_ifinfo(&ptr);
00175
00176
00177
00178
return 0;
00179 }