mesh_plink.c (c3896d2ca4dd97be290f000cb1079ed759d28574) mesh_plink.c (902acc7896d7649fb30e4b22bd4e643c7f34b02c)
1/*
2 * Copyright (c) 2008 open80211s Ltd.
3 * Author: Luis Carlos Cobo <luisca@cozybit.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
1/*
2 * Copyright (c) 2008 open80211s Ltd.
3 * Author: Luis Carlos Cobo <luisca@cozybit.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9
9#include <linux/kernel.h>
10#include <linux/random.h>
10#include "ieee80211_i.h"
11#include "ieee80211_rate.h"
12#include "mesh.h"
11#include "ieee80211_i.h"
12#include "ieee80211_rate.h"
13#include "mesh.h"
13#include <linux/random.h>
14
15#ifdef CONFIG_MAC80211_VERBOSE_MPL_DEBUG
16#define mpl_dbg(fmt, args...) printk(KERN_DEBUG fmt, ##args)
17#else
18#define mpl_dbg(fmt, args...) do { (void)(0); } while (0)
19#endif
20
21#define IEEE80211_FC(type, stype) cpu_to_le16(type | stype)

--- 104 unchanged lines hidden (view full) ---

126 rate_control_rate_init(sta, local);
127
128 mesh_accept_plinks_update(dev);
129
130 return sta;
131}
132
133/**
14
15#ifdef CONFIG_MAC80211_VERBOSE_MPL_DEBUG
16#define mpl_dbg(fmt, args...) printk(KERN_DEBUG fmt, ##args)
17#else
18#define mpl_dbg(fmt, args...) do { (void)(0); } while (0)
19#endif
20
21#define IEEE80211_FC(type, stype) cpu_to_le16(type | stype)

--- 104 unchanged lines hidden (view full) ---

126 rate_control_rate_init(sta, local);
127
128 mesh_accept_plinks_update(dev);
129
130 return sta;
131}
132
133/**
134 * mesh_plink_deactivate - deactivate mesh peer link
134 * __mesh_plink_deactivate - deactivate mesh peer link
135 *
136 * @sta: mesh peer link to deactivate
137 *
138 * All mesh paths with this peer as next hop will be flushed
139 *
140 * Locking: the caller must hold sta->plink_lock
141 */
135 *
136 * @sta: mesh peer link to deactivate
137 *
138 * All mesh paths with this peer as next hop will be flushed
139 *
140 * Locking: the caller must hold sta->plink_lock
141 */
142void mesh_plink_deactivate(struct sta_info *sta)
142static void __mesh_plink_deactivate(struct sta_info *sta)
143{
144 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
145 if (sta->plink_state == ESTAB)
146 mesh_plink_dec_estab_count(sdata);
147 sta->plink_state = BLOCKED;
148 mesh_path_flush_by_nexthop(sta);
149}
150
143{
144 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
145 if (sta->plink_state == ESTAB)
146 mesh_plink_dec_estab_count(sdata);
147 sta->plink_state = BLOCKED;
148 mesh_path_flush_by_nexthop(sta);
149}
150
151/**
152 * __mesh_plink_deactivate - deactivate mesh peer link
153 *
154 * @sta: mesh peer link to deactivate
155 *
156 * All mesh paths with this peer as next hop will be flushed
157 */
158void mesh_plink_deactivate(struct sta_info *sta)
159{
160 spin_lock_bh(&sta->plink_lock);
161 __mesh_plink_deactivate(sta);
162 spin_unlock_bh(&sta->plink_lock);
163}
164
151static int mesh_plink_frame_tx(struct net_device *dev,
152 enum plink_frame_type action, u8 *da, __le16 llid, __le16 plid,
153 __le16 reason) {
154 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
155 struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400);
156 struct ieee80211_mgmt *mgmt;
157 bool include_plid = false;
158 u8 *pos;

--- 201 unchanged lines hidden (view full) ---

360
361void mesh_plink_block(struct sta_info *sta)
362{
363#ifdef CONFIG_MAC80211_VERBOSE_MPL_DEBUG
364 DECLARE_MAC_BUF(mac);
365#endif
366
367 spin_lock_bh(&sta->plink_lock);
165static int mesh_plink_frame_tx(struct net_device *dev,
166 enum plink_frame_type action, u8 *da, __le16 llid, __le16 plid,
167 __le16 reason) {
168 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
169 struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400);
170 struct ieee80211_mgmt *mgmt;
171 bool include_plid = false;
172 u8 *pos;

--- 201 unchanged lines hidden (view full) ---

374
375void mesh_plink_block(struct sta_info *sta)
376{
377#ifdef CONFIG_MAC80211_VERBOSE_MPL_DEBUG
378 DECLARE_MAC_BUF(mac);
379#endif
380
381 spin_lock_bh(&sta->plink_lock);
368 mesh_plink_deactivate(sta);
382 __mesh_plink_deactivate(sta);
369 sta->plink_state = BLOCKED;
370 spin_unlock_bh(&sta->plink_lock);
371}
372
373int mesh_plink_close(struct sta_info *sta)
374{
375 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
376 int llid, plid, reason;

--- 8 unchanged lines hidden (view full) ---

385 reason = sta->reason;
386
387 if (sta->plink_state == LISTEN || sta->plink_state == BLOCKED) {
388 mesh_plink_fsm_restart(sta);
389 spin_unlock_bh(&sta->plink_lock);
390 sta_info_put(sta);
391 return 0;
392 } else if (sta->plink_state == ESTAB) {
383 sta->plink_state = BLOCKED;
384 spin_unlock_bh(&sta->plink_lock);
385}
386
387int mesh_plink_close(struct sta_info *sta)
388{
389 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
390 int llid, plid, reason;

--- 8 unchanged lines hidden (view full) ---

399 reason = sta->reason;
400
401 if (sta->plink_state == LISTEN || sta->plink_state == BLOCKED) {
402 mesh_plink_fsm_restart(sta);
403 spin_unlock_bh(&sta->plink_lock);
404 sta_info_put(sta);
405 return 0;
406 } else if (sta->plink_state == ESTAB) {
393 mesh_plink_deactivate(sta);
407 __mesh_plink_deactivate(sta);
394 /* The timer should not be running */
395 if (!mod_plink_timer(sta, dot11MeshHoldingTimeout(sdata)))
396 __sta_info_get(sta);
397 } else if (!mod_plink_timer(sta, dot11MeshHoldingTimeout(sdata)))
398 sta->ignore_plink_timer = true;
399
400 sta->plink_state = HOLDING;
401 llid = sta->llid;

--- 292 unchanged lines hidden (view full) ---

694 }
695 break;
696
697 case ESTAB:
698 switch (event) {
699 case CLS_ACPT:
700 reason = cpu_to_le16(MESH_CLOSE_RCVD);
701 sta->reason = reason;
408 /* The timer should not be running */
409 if (!mod_plink_timer(sta, dot11MeshHoldingTimeout(sdata)))
410 __sta_info_get(sta);
411 } else if (!mod_plink_timer(sta, dot11MeshHoldingTimeout(sdata)))
412 sta->ignore_plink_timer = true;
413
414 sta->plink_state = HOLDING;
415 llid = sta->llid;

--- 292 unchanged lines hidden (view full) ---

708 }
709 break;
710
711 case ESTAB:
712 switch (event) {
713 case CLS_ACPT:
714 reason = cpu_to_le16(MESH_CLOSE_RCVD);
715 sta->reason = reason;
702 mesh_plink_deactivate(sta);
716 __mesh_plink_deactivate(sta);
703 sta->plink_state = HOLDING;
704 llid = sta->llid;
705 if (!mod_plink_timer(sta,
706 dot11MeshHoldingTimeout(sdata)))
707 __sta_info_get(sta);
708 spin_unlock_bh(&sta->plink_lock);
709 mesh_plink_frame_tx(dev, PLINK_CLOSE, sta->addr, llid,
710 plid, reason);

--- 45 unchanged lines hidden ---
717 sta->plink_state = HOLDING;
718 llid = sta->llid;
719 if (!mod_plink_timer(sta,
720 dot11MeshHoldingTimeout(sdata)))
721 __sta_info_get(sta);
722 spin_unlock_bh(&sta->plink_lock);
723 mesh_plink_frame_tx(dev, PLINK_CLOSE, sta->addr, llid,
724 plid, reason);

--- 45 unchanged lines hidden ---