Skip to content

Commit

Permalink
Stable version 1 March. We have start with the base code of fgg89 and
Browse files Browse the repository at this point in the history
added all the changes and new functions that Unizar developed. There is
still things left to TODO
  • Loading branch information
luissequeira committed Mar 1, 2016
1 parent b2d1101 commit bb14117
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 30 deletions.
33 changes: 7 additions & 26 deletions src/odinagent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#include <clicknet/ether.h>
#include <clicknet/llc.h>
#include "odinagent.hh"
#include <iostream> // std::cout
#include <string> // std::string, std::to_string
#include <iostream>
#include <string>
#include <sstream>
#include <stdlib.h>
#include <stdio.h>
Expand Down Expand Up @@ -103,7 +103,7 @@ int
OdinAgent::configure(Vector<String> &conf, ErrorHandler *errh)
{
_interval_ms = 5000;
_channel = 1;
_channel = 6;
_new_channel = 1;
_csa = false; //
_csa_count_default = 49; // Wait (n+1) beacons before first channel switch announcement
Expand Down Expand Up @@ -361,7 +361,6 @@ OdinAgent::recv_deauth (Packet *p) {
StringAccum sa;
sa << "deauthentication " << src.unparse_colon().c_str() << "\n";


String payload = sa.take_string();
WritablePacket *odin_disconnect_packet = Packet::make(Packet::default_headroom, payload.data(), payload.length(), 0);
output(3).push(odin_disconnect_packet);
Expand All @@ -374,7 +373,6 @@ OdinAgent::recv_deauth (Packet *p) {
}



/**
* Handle a probe request. This code is
* borrowed from the ProbeResponder element
Expand Down Expand Up @@ -461,7 +459,7 @@ OdinAgent::recv_probe_request (Packet *p)
}


/**
/**
* Send a beacon/probe-response. This code is
* borrowed from the BeaconSource element
* and is modified to retrieve the BSSID/SSID
Expand Down Expand Up @@ -910,7 +908,6 @@ OdinAgent::send_open_auth_response (EtherAddress dst, uint16_t seq, uint16_t sta

EtherAddress src = EtherAddress(w->i_addr2);


w->i_dur = 0;
w->i_seq = 0;

Expand Down Expand Up @@ -1222,9 +1219,7 @@ OdinAgent::update_rx_stats(Packet *p)
if(_debug){
FILE * fp;
fp = fopen ("/root/spring/shared/updated_stats.txt", "w");
fprintf(fp, "* update_rx_stats: src = %s, rate = %i, noise = %i, signal = %i (%i dBm)\n", src.unparse_colon().c_str(), stat._rate, stat._noise, stat._signal, (stat._signal - 128)*-1); //-(value - 128)
fclose(fp);
}
*/
Expand Down Expand Up @@ -1338,16 +1333,10 @@ OdinAgent::push(int port, Packet *p)
// FIXME: Inform controller accordingly? We'll need this
// for roaming.

// JMS LVAP not found in the table
//fprintf(stderr, "*********** data packet does NOT correspond with any LVAP. Source MAC: %s\n", src.unparse_colon().c_str());

p->kill ();
return;
}

// JMS LVAP found in the table
//fprintf(stderr, "*********** data packet does correspond with any LVAP. Source MAC: %s\n", src.unparse_colon().c_str());

// There should be a WifiDecap element upstream.
output(1).push(p);
return;
Expand Down Expand Up @@ -1895,7 +1884,7 @@ OdinAgent::write_handler(const String &str, Element *e, void *user_data, ErrorHa
}

break;
}
}
}
return 0;
}
Expand Down Expand Up @@ -1940,10 +1929,9 @@ OdinAgent::print_stations_state()
for (HashTable<EtherAddress, OdinStationState>::iterator it
= _sta_mapping_table.begin(); it.live(); it++){


for (int i = 0; i < it.value()._vap_ssids.size (); i++) {
fprintf(stderr," Station -> BSSID: %s\n", (it.value()._vap_bssid).unparse_colon().c_str());
fprintf(stderr," -> IP addr: %s\n", it.value()._sta_ip_addr_v4.unparse().c_str());
//fprintf(stderr," -> IP addr: %s\n", it.value()._sta_ip_addr_v4.unparse().c_str());
}
}

Expand All @@ -1955,19 +1943,16 @@ OdinAgent::print_stations_state()
if(_sta_mapping_table.find(iter.key()) != _sta_mapping_table.end()){
fprintf(stderr," -> rate: %i\n", (iter.value()._rate));
fprintf(stderr," -> noise: %i\n", (iter.value()._noise));
// fixed by jsaldana: dbm = signal - 256
fprintf(stderr," -> signal: %i (%i dBm)\n", (iter.value()._signal), ((iter.value()._signal) - 256));
fprintf(stderr," -> signal: %i (-%i dBm)\n", (iter.value()._signal), (iter.value()._signal) - 128);
fprintf(stderr," -> packets: %i\n", (iter.value()._packets));
fprintf(stderr," -> last heard: %d.%06d \n", (iter.value()._last_received).sec(), (iter.value()._last_received).subsec());
fprintf(stderr,"\n");
}
}

}

}


/* This function erases the rx_stats of old clients */
void
cleanup_lvap (Timer *timer, void *data)
Expand Down Expand Up @@ -2000,19 +1985,15 @@ cleanup_lvap (Timer *timer, void *data)
}
}


fprintf(stderr,"\nCleaning old info from:\n");


for (Vector<EtherAddress>::const_iterator iter = buf.begin(); iter != buf.end(); iter++){

//If its our station we dont remove, we need the _last_received to see if its inactive or not
if(agent->_sta_mapping_table.find(*iter) != agent->_sta_mapping_table.end())
continue;


fprintf(stderr, " station with MAC addr: %s\n", iter->unparse_colon().c_str());

agent->_rx_stats.erase (*iter);
}

Expand Down
4 changes: 0 additions & 4 deletions src/odinagent.hh
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public:
// Methods to handle and send
// 802.11 management messages
void recv_probe_request (Packet *p);

void recv_deauth (Packet *p);
void send_beacon (EtherAddress dst, EtherAddress bssid, String my_ssid, bool probe);
void recv_assoc_request (Packet *p);
Expand All @@ -103,7 +102,6 @@ public:
int remove_vap (EtherAddress sta_mac);

//debug

void print_stations_state();


Expand Down Expand Up @@ -184,10 +182,8 @@ private:
class AvailableRates *_rtable;
int _associd;
Timer _beacon_timer;

Timer _clean_stats_timer;
Timer _general_timer;

IPAddress _default_gw_addr;
String _debugfs_string;
};
Expand Down

0 comments on commit bb14117

Please sign in to comment.