Radiotap Antenna Signal field is signed

Using int8_t instead of uint8_t which was erroneously used to code the
Antenna Signal radiotap field.
This commit is contained in:
Matteo Cypriani 2013-04-24 10:21:54 -04:00
parent a046dcd3fb
commit 4aed9c1ef0
5 changed files with 13 additions and 17 deletions

View File

@ -108,7 +108,7 @@ typedef struct _owl_captured_request
uint8_t mobile_ip_addr_bytes[4] ; // IP of the mobile uint8_t mobile_ip_addr_bytes[4] ; // IP of the mobile
owl_timestamp request_time ; // Timestamp on the mobile owl_timestamp request_time ; // Timestamp on the mobile
owl_timestamp capture_time ; // Timestamp of arrival on the listener owl_timestamp capture_time ; // Timestamp of arrival on the listener
uint8_t ss_dbm ; // Signal strength measured by the listener (dBm) int8_t ss_dbm ; // Signal strength measured by the listener (dBm)
/* Calibration data */ /* Calibration data */
float x_position ; float x_position ;
float y_position ; float y_position ;
@ -143,7 +143,7 @@ typedef struct _owl_request_info
uint16_t packet_id ; // Number of the current packet uint16_t packet_id ; // Number of the current packet
uint8_t ap_mac_addr_bytes[ETHER_ADDR_LEN] ; // MAC of the listener uint8_t ap_mac_addr_bytes[ETHER_ADDR_LEN] ; // MAC of the listener
owl_timestamp capture_time ; // Timestamp of arrival on the listener owl_timestamp capture_time ; // Timestamp of arrival on the listener
uint8_t ss_dbm ; // Signal strength measured by the listener (dBm) int8_t ss_dbm ; // Signal strength measured by the listener (dBm)
} owl_request_info ; } owl_request_info ;

View File

@ -76,7 +76,7 @@ typedef struct _request_info_list
// Timestamp of arrival on the listener: // Timestamp of arrival on the listener:
owl_timestamp capture_time ; owl_timestamp capture_time ;
// Signal strength received by the AP from the mobile: // Signal strength received by the AP from the mobile:
uint8_t ss_dbm ; int8_t ss_dbm ;
struct _request_info_list *next ; struct _request_info_list *next ;
} request_info_list ; } request_info_list ;

View File

@ -579,7 +579,7 @@ int read_loop(int sockfd)
"\tMobile IP: %s\n" "\tMobile IP: %s\n"
"\tRequest timestamp: %s\n" "\tRequest timestamp: %s\n"
"\tRequest arrival time on the AP: %s\n" "\tRequest arrival time on the AP: %s\n"
"\tSignal: %d dBm\n" "\tSignal: %"PRId8" dBm\n"
"\tPosition X: %f\n" "\tPosition X: %f\n"
"\tPosition Y: %f\n" "\tPosition Y: %f\n"
"\tPosition Z: %f\n" "\tPosition Z: %f\n"
@ -592,7 +592,7 @@ int read_loop(int sockfd)
mobile_ip_str, mobile_ip_str,
request_time_str, request_time_str,
capture_time_str, capture_time_str,
request.ss_dbm - 256, request.ss_dbm,
request.x_position, request.x_position,
request.y_position, request.y_position,
request.z_position, request.z_position,
@ -761,10 +761,10 @@ void* monitor_requests(void *NULL_value)
owl_mac_bytes_to_string_r(request_info_ptr-> owl_mac_bytes_to_string_r(request_info_ptr->
ap_mac_addr_bytes, ap_mac_addr_bytes,
mac_str) ; mac_str) ;
fprintf(fd, ";%s;%"PRIu16";%d", fprintf(fd, ";%s;%"PRIu16";%"PRId8,
mac_str, mac_str,
request_info_ptr->packet_id, request_info_ptr->packet_id,
request_info_ptr->ss_dbm - 256) ; request_info_ptr->ss_dbm) ;
// Delete request // Delete request
request_info_ptr = request_info_ptr->next ; request_info_ptr = request_info_ptr->next ;
@ -1421,9 +1421,9 @@ void print_request_info(request_info_list *info)
owl_mac_bytes_to_string_r(info->ap_mac_addr_bytes, ap_mac_str) ; owl_mac_bytes_to_string_r(info->ap_mac_addr_bytes, ap_mac_str) ;
fprintf(stderr, fprintf(stderr,
"\tAP MAC: %s\n" "\tAP MAC: %s\n"
"\tSignal strength: %d dBm\n", "\tSignal strength: %"PRId8" dBm\n",
ap_mac_str, ap_mac_str,
info->ss_dbm - 256 info->ss_dbm
) ; ) ;
} }
#endif // NDEBUG #endif // NDEBUG

View File

@ -1201,7 +1201,7 @@ void read_packet(const struct pcap_pkthdr *pkt_header,
"\tMobile IP: %s\n" "\tMobile IP: %s\n"
"\tRequest timestamp: %s\n" "\tRequest timestamp: %s\n"
"\tRequest arrival time on the AP: %s\n" "\tRequest arrival time on the AP: %s\n"
"\tSignal: %d dBm\n" "\tSignal: %"PRId8" dBm\n"
"\tPosition X: %f\n" "\tPosition X: %f\n"
"\tPosition Y: %f\n" "\tPosition Y: %f\n"
"\tPosition Z: %f\n" "\tPosition Z: %f\n"
@ -1215,7 +1215,7 @@ void read_packet(const struct pcap_pkthdr *pkt_header,
mobile_ip_str, mobile_ip_str,
request_time_str, request_time_str,
capture_time_str, capture_time_str,
rtap_fields[RTAP_ANTENNASIGNALDBM] ? request.ss_dbm - 256 : 0, rtap_fields[RTAP_ANTENNASIGNALDBM] ? request.ss_dbm : 0,
owl_ntohf(request.x_position), owl_ntohf(request.x_position),
owl_ntohf(request.y_position), owl_ntohf(request.y_position),
owl_ntohf(request.z_position), owl_ntohf(request.z_position),
@ -1340,8 +1340,7 @@ void extract_radiotap_data(const u_char *pkt_data,
memcpy(&request->ss_dbm, memcpy(&request->ss_dbm,
&pkt_data[rtap_position], RTAP_L_ANTENNASIGNALDBM) ; &pkt_data[rtap_position], RTAP_L_ANTENNASIGNALDBM) ;
if (VERBOSE_INFO) if (VERBOSE_INFO)
printf("Antenna signal: %d dBm\n", printf("Antenna signal: %"PRId8" dBm\n", request->ss_dbm) ;
request->ss_dbm - 256);
rtap_position += RTAP_L_ANTENNASIGNALDBM ; rtap_position += RTAP_L_ANTENNASIGNALDBM ;
break ; break ;
case RTAP_ANTENNANOISEDBM: case RTAP_ANTENNANOISEDBM:

View File

@ -227,10 +227,7 @@ bool InputUDPSocket::fill_current_request()
owl_ntoh_timestamp(&request_info.capture_time) ; owl_ntoh_timestamp(&request_info.capture_time) ;
Timestamp capture_time(request_info.capture_time) ; Timestamp capture_time(request_info.capture_time) ;
// Substracting 256 is not mandatory here since it is done ss_t ss = request_info.ss_dbm ;
// automatically when casting from unsigned to signed, but
// I write it anyway for the sake of clarity.
ss_t ss = request_info.ss_dbm - 256 ;
if (Configuration::is_configured("verbose")) if (Configuration::is_configured("verbose"))
cerr cerr