#include <sys/types.h>
#include <sys/socket.h>
#include <linux/types.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <linux/if_ether.h>
#include <dbus/dbus.h>
#include <wlancond.h>
#include <eap-dbus.h>
#include <glib.h>
#include <glib-object.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include "wpa.h"
#include "wapi.h"
#include "daemon.h"
#include "dbus-handler.h"
#include "log.h"
#include "libnl-handler.h"
Go to the source code of this file.
Functions | |
static int | nl80211_scan_result_handler (struct nl_msg *msg, void *arg) |
static int | nl80211_parse_ies (unsigned char *const ie, size_t ie_len, scan_results_t *const scan_result) |
static void | save_caps (struct scan_results_t *, struct ap_info_t *, unsigned char *, unsigned int) |
static int | get_family_cb (struct nl_msg *msg, void *arg) |
static int | nl80211_get_family (const char *family_name, const char *group_name) |
static void | handle_netlink_wap_event (unsigned char *sa_data) |
static int | ignore_seq_check (struct nl_msg *msg, void *arg) |
static void | process_cqm_event (struct nlattr *tb[]) |
static int | print_netlink_event_token (struct nl_msg *msg, void *arg) |
static gboolean | event_receive (GIOChannel *chan, GIOCondition cond, gpointer data) |
int | init_nl80211 (void) |
static int | error_handler (struct sockaddr_nl *nla, struct nlmsgerr *err, void *arg) |
static int | finish_handler (struct nl_msg *msg, void *arg) |
static int | ack_handler (struct nl_msg *msg, void *arg) |
int | nl_send_recv_msgs (struct nl_msg *msg, int(*valid_handler)(struct nl_msg *, void *), void *valid_data) |
void | nl80211_cleanup (void) |
static int | nl80211_set_wep_keys (struct connect_params_t *conn, struct nl_msg *msg) |
static guint32 | channel_to_freq (guint32 channel) |
static guint32 | freq_to_channel (guint32 freq) |
int | nl80211_connect (struct scan_results_t *scan_results, struct wlan_status_t *wlan_status) |
int | nl80211_set_op_mode (guint32 ifindex, guint32 mode) |
static int | phy_info_handler (struct nl_msg *msg, void *arg) |
int | nl80211_get_phy_info (guint32 ifindex) |
int | nl80211_set_channel (guint32 ifindex, guint32 channel) |
int | nl80211_leave_adhoc (guint32 ifindex) |
int | nl80211_mlme_command (guchar *addr, guint16 cmd, guint16 reason_code, guint32 ifindex) |
static int | nl80211_signal_power_handler (struct nl_msg *msg, void *arg) |
int | nl80211_get_signal_info (guint8 *power, struct wlan_status_t *wlan_status) |
int | nl80211_set_power_save (gboolean new_state, guint32 ifindex) |
int | nl80211_scan (wlan_status_t *const wlan_status, int ssid_len, char *const ssid) |
int | nl80211_send_get_scan_results (wlan_status_t *const wlan_status, GSList **const scan_results) |
static gboolean | nl80211_is_supported_data_rate (guint8 data_rate) |
int | nl80211_set_cqm (guint32 threshold, guint32 hyst) |
int | nl80211_set_tx_power (int tx_power, guint32 ifindex) |
Variables | |
static struct nl_handle * | nl_handle = NULL |
static struct nl_handle * | nl_event_handle = NULL |
static struct nl_cache * | nl_cache = NULL |
static struct nl_cache * | nl_event_cache = NULL |
static struct genl_family * | nl80211 = NULL |
static struct nl_cb * | nl_cb = NULL |
static unsigned int | nl_family_id |
static wlan_status_t * | scan_wlan_status = NULL |
Copyright (C) 2010 Nokia Corporation. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Definition in file libnl-handler.c.
static guint32 channel_to_freq | ( | guint32 | channel | ) | [static] |
Convert channel to frequency.
channel | Channel. |
Definition at line 776 of file libnl-handler.c.
Referenced by nl80211_connect(), and nl80211_set_channel().
static gboolean event_receive | ( | GIOChannel * | chan, | |
GIOCondition | cond, | |||
gpointer | data | |||
) | [static] |
Callback function for netlink wireless events.
chan | GLIB IO Channel. | |
cond | GLIB IO condition. | |
data | private pointer. |
Definition at line 444 of file libnl-handler.c.
References print_netlink_event_token().
Referenced by init_nl80211().
static guint32 freq_to_channel | ( | guint32 | freq | ) | [static] |
Convert frequency to channel.
freq | Frequency. |
Definition at line 793 of file libnl-handler.c.
Referenced by nl80211_scan_result_handler().
static int get_family_cb | ( | struct nl_msg * | msg, | |
void * | arg | |||
) | [static] |
Read group name and ID returned by the get family command.
msg | nl_msg structure. | |
arg | Updated with received data. |
Definition at line 66 of file libnl-handler.c.
Referenced by nl80211_get_family().
static void handle_netlink_wap_event | ( | unsigned char * | sa_data | ) | [static] |
Handle netlink wireless event.
sa_data | MAC address of the connected AP. |
Definition at line 157 of file libnl-handler.c.
References connected_signal(), decrease_signal_in_roam_cache(), disassociate_eap(), disconnected_signal(), find_connection_and_associate(), get_scan_state(), get_wlan_state(), get_wpa_mode(), is_connected_state(), mlme_command(), netlink_send_linkmode(), nl80211_get_phy_info(), scan(), scan_retries_left(), set_iptables(), set_wlan_state(), wlan_status, and wpa_ie_push().
Referenced by print_netlink_event_token().
int init_nl80211 | ( | void | ) |
initialize the netlink library sockets
Definition at line 494 of file libnl-handler.c.
References event_receive(), nl80211_get_family(), and nl_handle.
Referenced by main().
void nl80211_cleanup | ( | void | ) |
Cleaning the pointers on close down.
Definition at line 690 of file libnl-handler.c.
References nl_handle.
Referenced by main().
int nl80211_connect | ( | struct scan_results_t * | scan_results, | |
struct wlan_status_t * | wlan_status | |||
) |
Connect function to connect to selected access point.
scan_results | Scan results. |
Definition at line 808 of file libnl-handler.c.
References channel_to_freq(), get_mode(), get_wpa_mode(), nl80211_set_wep_keys(), and nl_send_recv_msgs().
Referenced by associate().
static int nl80211_get_family | ( | const char * | family_name, | |
const char * | group_name | |||
) | [static] |
Ask for group name and id using get family command.
family_name | Family to which group belongs. | |
group_name | Group to be extracted. |
Definition at line 112 of file libnl-handler.c.
References get_family_cb(), and nl_send_recv_msgs().
Referenced by init_nl80211().
int nl80211_get_phy_info | ( | guint32 | ifindex | ) |
Helper function for getting the phy information.
ifindex | Interface index. |
Definition at line 1107 of file libnl-handler.c.
References nl_send_recv_msgs(), and phy_info_handler().
Referenced by handle_netlink_wap_event().
int nl80211_get_signal_info | ( | guint8 * | power, | |
struct wlan_status_t * | wlan_status | |||
) |
Ask for station stats.
power | Signal power. | |
wlan_status | Wlan status. |
Definition at line 1327 of file libnl-handler.c.
References nl80211_signal_power_handler(), and nl_send_recv_msgs().
Referenced by status_request().
static gboolean nl80211_is_supported_data_rate | ( | guint8 | data_rate | ) | [static] |
Validates given data rate.
data_rate | Data rate to be validated. |
Definition at line 1600 of file libnl-handler.c.
Referenced by nl80211_parse_ies().
int nl80211_leave_adhoc | ( | guint32 | ifindex | ) |
Leave the adhoc network.
ifindex | Interface index. |
Definition at line 1176 of file libnl-handler.c.
References nl_send_recv_msgs().
Referenced by mlme_command().
int nl80211_mlme_command | ( | guchar * | addr, | |
guint16 | cmd, | |||
guint16 | reason_code, | |||
guint32 | ifindex | |||
) |
MLME nl80211 commands.
addr | Access point MAC address. | |
cmd | Command. | |
reason_code | Reason for leaving. | |
ifindex | Interface index. |
Definition at line 1213 of file libnl-handler.c.
References nl_send_recv_msgs().
Referenced by mlme_command().
static int nl80211_parse_ies | ( | unsigned char *const | ie, | |
size_t | ie_len, | |||
scan_results_t *const | scan_result | |||
) | [static] |
Function to parse WLAN information elements.
ie | Pointer to information element. | |
ie_len | Length of information element. | |
scan_result | Pointer to scan result structure. |
Definition at line 1628 of file libnl-handler.c.
References handle_wps_ie(), nl80211_is_supported_data_rate(), parse_rsn_ie(), parse_wapi_ie(), parse_wpa_ie(), and save_caps().
Referenced by nl80211_scan_result_handler().
int nl80211_scan | ( | wlan_status_t *const | wlan_status, | |
int | ssid_len, | |||
char *const | ssid | |||
) |
Function to send scan trigger command.
wlan_status | Pointer to WLAN status structure. | |
ssid_len | Length of SSID if given. | |
ssid | SSID if given. |
Definition at line 1413 of file libnl-handler.c.
References nl_send_recv_msgs().
Referenced by scan().
static int nl80211_scan_result_handler | ( | struct nl_msg * | msg, | |
void * | arg | |||
) | [static] |
Function to handle scan results.
msg | Netlink message. | |
arg | Pointer to scan result list. |
Definition at line 1506 of file libnl-handler.c.
References freq_to_channel(), and nl80211_parse_ies().
Referenced by nl80211_send_get_scan_results().
int nl80211_send_get_scan_results | ( | wlan_status_t *const | wlan_status, | |
GSList **const | scan_results | |||
) |
Function to send get scan results command.
wlan_status | Pointer to WLAN status structure. | |
scan_results | Pointer to scan result list. |
Definition at line 1468 of file libnl-handler.c.
References nl80211_scan_result_handler(), and nl_send_recv_msgs().
Referenced by ask_scan_results(), and settings_and_connect_request().
int nl80211_set_channel | ( | guint32 | ifindex, | |
guint32 | channel | |||
) |
Helper function for setting the channel.
ifindex | Interface index. | |
channel | Channel. |
Definition at line 1141 of file libnl-handler.c.
References channel_to_freq(), and nl_send_recv_msgs().
Referenced by settings_and_connect_request().
int nl80211_set_cqm | ( | guint32 | threshold, | |
guint32 | hyst | |||
) |
Set the connection quality monitor.
threshold | Threshold value for receiving events. | |
hyst | Hysteresis value. |
Definition at line 1812 of file libnl-handler.c.
References get_mode(), nl_send_recv_msgs(), and wlan_status.
Referenced by set_mode().
int nl80211_set_op_mode | ( | guint32 | ifindex, | |
guint32 | mode | |||
) |
Helper function for setting the operating mode using netlink.
ifindex | Interface index. | |
mode | Operating mode. |
Definition at line 1026 of file libnl-handler.c.
References nl_send_recv_msgs().
Referenced by set_mode().
int nl80211_set_power_save | ( | gboolean | new_state, | |
guint32 | ifindex | |||
) |
Set the power save state.
power_save | Enable/disable. | |
ifindex | Interface index. |
Definition at line 1367 of file libnl-handler.c.
References nl_send_recv_msgs().
Referenced by set_power_state().
int nl80211_set_tx_power | ( | int | tx_power, | |
guint32 | ifindex | |||
) |
Set the transmit power level.
tx_power | value. | |
ifindex | Interface index. |
Definition at line 1982 of file libnl-handler.c.
References nl_send_recv_msgs().
Referenced by set_tx_power().
static int nl80211_set_wep_keys | ( | struct connect_params_t * | conn, | |
struct nl_msg * | msg | |||
) | [static] |
Helper function for setting the WEP keys in netlink way.
conn | Connection parameters. | |
msg | Structure containing the command. |
Definition at line 710 of file libnl-handler.c.
Referenced by nl80211_connect().
static int nl80211_signal_power_handler | ( | struct nl_msg * | msg, | |
void * | arg | |||
) | [static] |
Read data from get station command.
msg | nl_msg structure. | |
arg | will be updated with signal power. |
Definition at line 1280 of file libnl-handler.c.
Referenced by nl80211_get_signal_info().
int nl_send_recv_msgs | ( | struct nl_msg * | msg, | |
int(*)(struct nl_msg *, void *) | valid_handler, | |||
void * | valid_data | |||
) |
Send the netlink command to the kernel.
msg | structure Containing the command. | |
valid_handler | Pointer to call back function. | |
valid_data | Argument for call back function. |
Definition at line 628 of file libnl-handler.c.
References nl_handle.
Referenced by nl80211_connect(), nl80211_get_family(), nl80211_get_phy_info(), nl80211_get_signal_info(), nl80211_leave_adhoc(), nl80211_mlme_command(), nl80211_scan(), nl80211_send_get_scan_results(), nl80211_set_channel(), nl80211_set_cqm(), nl80211_set_op_mode(), nl80211_set_power_save(), and nl80211_set_tx_power().
static int phy_info_handler | ( | struct nl_msg * | msg, | |
void * | arg | |||
) | [static] |
Process phy info callback.
msg | nl_msg structure. | |
arg | arguments for the function. |
Definition at line 1079 of file libnl-handler.c.
References wlan_status.
Referenced by nl80211_get_phy_info().
static int print_netlink_event_token | ( | struct nl_msg * | msg, | |
void * | arg | |||
) | [static] |
Print or process netlink wireless events.
msg | nl_msg structure. | |
arg | arguments for the function. |
Definition at line 332 of file libnl-handler.c.
References get_wlan_state(), handle_mic_failure(), handle_netlink_wap_event(), nl80211_scan_ready(), process_cqm_event(), and wlan_status.
Referenced by event_receive().
static void process_cqm_event | ( | struct nlattr * | tb[] | ) | [static] |
Process connection quality management events.
tb | Received event attributes. |
Definition at line 292 of file libnl-handler.c.
References get_wlan_state(), roam_scanning(), and schedule_scan().
Referenced by print_netlink_event_token().
static void save_caps | ( | struct scan_results_t * | scan_results, | |
struct ap_info_t * | ap_info, | |||
unsigned char * | p, | |||
unsigned int | length | |||
) | [static] |
Save WPA capabilities and print them to log.
scan_results | Pointer to scan results structure. | |
ap_info | Pointer to AP information structure. | |
p | Pointer to event buffer. | |
length | Event buffer length. |
Definition at line 1872 of file libnl-handler.c.
References wlan_status.
Referenced by nl80211_parse_ies().
LIBNL
Definition at line 51 of file libnl-handler.c.
Referenced by init_nl80211(), nl80211_cleanup(), and nl_send_recv_msgs().