Functions | Variables

libnl-handler.c File Reference

#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"
Include dependency graph for libnl-handler.c:

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_handlenl_handle = NULL
static struct nl_handlenl_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_tscan_wlan_status = NULL

Detailed Description

Copyright (C) 2010 Nokia Corporation. All rights reserved.

Author:
Usman Rahim <usman.rahim@nokia.com>

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.


Function Documentation

static guint32 channel_to_freq ( guint32  channel  )  [static]

Convert channel to frequency.

Parameters:
channel Channel.
Returns:
frequency.

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.

Parameters:
chan GLIB IO Channel.
cond GLIB IO condition.
data private pointer.
Returns:
status.

Definition at line 444 of file libnl-handler.c.

References print_netlink_event_token().

Referenced by init_nl80211().

Here is the call graph for this function:

static guint32 freq_to_channel ( guint32  freq  )  [static]

Convert frequency to channel.

Parameters:
freq Frequency.
Returns:
channel.

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.

Parameters:
msg nl_msg structure.
arg Updated with received data.
Returns:
status.

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]
int init_nl80211 ( void   ) 

initialize the netlink library sockets

Returns:
status.

Definition at line 494 of file libnl-handler.c.

References event_receive(), nl80211_get_family(), and nl_handle.

Referenced by main().

Here is the call graph for this function:

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.

Parameters:
scan_results Scan results.
Returns:
status.

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().

Here is the call graph for this function:

static int nl80211_get_family ( const char *  family_name,
const char *  group_name 
) [static]

Ask for group name and id using get family command.

Parameters:
family_name Family to which group belongs.
group_name Group to be extracted.
Returns:
status.

Definition at line 112 of file libnl-handler.c.

References get_family_cb(), and nl_send_recv_msgs().

Referenced by init_nl80211().

Here is the call graph for this function:

int nl80211_get_phy_info ( guint32  ifindex  ) 

Helper function for getting the phy information.

Parameters:
ifindex Interface index.
Returns:
status.

Definition at line 1107 of file libnl-handler.c.

References nl_send_recv_msgs(), and phy_info_handler().

Referenced by handle_netlink_wap_event().

Here is the call graph for this function:

int nl80211_get_signal_info ( guint8 *  power,
struct wlan_status_t wlan_status 
)

Ask for station stats.

Parameters:
power Signal power.
wlan_status Wlan status.
Returns:
status.

Definition at line 1327 of file libnl-handler.c.

References nl80211_signal_power_handler(), and nl_send_recv_msgs().

Referenced by status_request().

Here is the call graph for this function:

static gboolean nl80211_is_supported_data_rate ( guint8  data_rate  )  [static]

Validates given data rate.

Parameters:
data_rate Data rate to be validated.
Returns:
True if given data rate is supported by the device.

Definition at line 1600 of file libnl-handler.c.

Referenced by nl80211_parse_ies().

int nl80211_leave_adhoc ( guint32  ifindex  ) 

Leave the adhoc network.

Parameters:
ifindex Interface index.
Returns:
status.

Definition at line 1176 of file libnl-handler.c.

References nl_send_recv_msgs().

Referenced by mlme_command().

Here is the call graph for this function:

int nl80211_mlme_command ( guchar *  addr,
guint16  cmd,
guint16  reason_code,
guint32  ifindex 
)

MLME nl80211 commands.

Parameters:
addr Access point MAC address.
cmd Command.
reason_code Reason for leaving.
ifindex Interface index.
Returns:
status.

Definition at line 1213 of file libnl-handler.c.

References nl_send_recv_msgs().

Referenced by mlme_command().

Here is the call graph for this function:

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.

Parameters:
ie Pointer to information element.
ie_len Length of information element.
scan_result Pointer to scan result structure.
Returns:
status.

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().

Here is the call graph for this function:

int nl80211_scan ( wlan_status_t *const   wlan_status,
int  ssid_len,
char *const   ssid 
)

Function to send scan trigger command.

Parameters:
wlan_status Pointer to WLAN status structure.
ssid_len Length of SSID if given.
ssid SSID if given.
Returns:
status.

Definition at line 1413 of file libnl-handler.c.

References nl_send_recv_msgs().

Referenced by scan().

Here is the call graph for this function:

static int nl80211_scan_result_handler ( struct nl_msg *  msg,
void *  arg 
) [static]

Function to handle scan results.

Parameters:
msg Netlink message.
arg Pointer to scan result list.
Returns:
status.

Definition at line 1506 of file libnl-handler.c.

References freq_to_channel(), and nl80211_parse_ies().

Referenced by nl80211_send_get_scan_results().

Here is the call graph for this function:

int nl80211_send_get_scan_results ( wlan_status_t *const   wlan_status,
GSList **const   scan_results 
)

Function to send get scan results command.

Parameters:
wlan_status Pointer to WLAN status structure.
scan_results Pointer to scan result list.
Returns:
status.

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().

Here is the call graph for this function:

int nl80211_set_channel ( guint32  ifindex,
guint32  channel 
)

Helper function for setting the channel.

Parameters:
ifindex Interface index.
channel Channel.
Returns:
status.

Definition at line 1141 of file libnl-handler.c.

References channel_to_freq(), and nl_send_recv_msgs().

Referenced by settings_and_connect_request().

Here is the call graph for this function:

int nl80211_set_cqm ( guint32  threshold,
guint32  hyst 
)

Set the connection quality monitor.

Parameters:
threshold Threshold value for receiving events.
hyst Hysteresis value.
Returns:
status.

Definition at line 1812 of file libnl-handler.c.

References get_mode(), nl_send_recv_msgs(), and wlan_status.

Referenced by set_mode().

Here is the call graph for this function:

int nl80211_set_op_mode ( guint32  ifindex,
guint32  mode 
)

Helper function for setting the operating mode using netlink.

Parameters:
ifindex Interface index.
mode Operating mode.
Returns:
status.

Definition at line 1026 of file libnl-handler.c.

References nl_send_recv_msgs().

Referenced by set_mode().

Here is the call graph for this function:

int nl80211_set_power_save ( gboolean  new_state,
guint32  ifindex 
)

Set the power save state.

Parameters:
power_save Enable/disable.
ifindex Interface index.
Returns:
status.

Definition at line 1367 of file libnl-handler.c.

References nl_send_recv_msgs().

Referenced by set_power_state().

Here is the call graph for this function:

int nl80211_set_tx_power ( int  tx_power,
guint32  ifindex 
)

Set the transmit power level.

Parameters:
tx_power value.
ifindex Interface index.
Returns:
status.

Definition at line 1982 of file libnl-handler.c.

References nl_send_recv_msgs().

Referenced by set_tx_power().

Here is the call graph for this function:

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.

Parameters:
conn Connection parameters.
msg Structure containing the command.
Returns:
status.

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.

Parameters:
msg nl_msg structure.
arg will be updated with signal power.
Returns:
status.

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.

Parameters:
msg structure Containing the command.
valid_handler Pointer to call back function.
valid_data Argument for call back function.
Returns:
status.

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.

Parameters:
msg nl_msg structure.
arg arguments for the function.
Returns:
status.

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.

Parameters:
msg nl_msg structure.
arg arguments for the function.
Returns:
status.

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().

Here is the call graph for this function:

static void process_cqm_event ( struct nlattr *  tb[]  )  [static]

Process connection quality management events.

Parameters:
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().

Here is the call graph for this function:

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.

Parameters:
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().


Variable Documentation

struct nl_handle* nl_handle = NULL [static]

LIBNL

Definition at line 51 of file libnl-handler.c.

Referenced by init_nl80211(), nl80211_cleanup(), and nl_send_recv_msgs().