Stop a mesh STA from flooding with peer frames.

This problem happens when using ACL policy to filter mesh STA
but two nodes have different policy. Then one of them will try to
peer all the time. This can also help if for any reason one of the
peering mesh STA have problems sending/receiving peer frames.

* Modified struct ieee80211_node to include two new fields:
    + struct callout ni_mlhtimer /* link mesh backoff timer */
    + uint8_t ni_mlhcnt /* link mesh holding counter */
* Added two new sysctl (check sysctl -d for more info):
    + net.wlan.mesh.backofftimeout=5000
    + net.wlan.mesh.maxholding=2;
* When receiving a beacon and we are in IEEE80211_NODE_MESH_IDLE
  check if ni_mlhcnt >= ieee80211_mesh_maxholding, if so do not do anything;
* In mesh_peer_timeout_cb when transitioning from IEEE80211_NODE_MESH_HOLDING
  to IEEE80211_NODE_MESH_IDLE increment ni_mlhcnt, and eventually start
  ieee80211_mesh_backofftimeout;

Approved by:	adrian (mentor)


git-svn-id: svn://svn.freebsd.org/base/head@246497 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Fix mesh path flag.

* A bug occurs while in discovery mode which leaves a path marked with
  both Discover and Valid flag. This happens when receiving/sending
  PREQ and PREP in a particular order. Solution is to assign the Valid bit
  instead of oring it;

Approved by:	adrian (mentor)


git-svn-id: svn://svn.freebsd.org/base/head@246498 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Add mesh debug for interarction between DS & MBSS.

* Add mesh debug information when frames enter or leave the MBSS;
* Set IEEE80211_MSG_OUTPUT bit to enable output;

Approved by:	adrian (mentor)


git-svn-id: svn://svn.freebsd.org/base/head@246499 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
HWMP: Accept a PERR even if path is valid.

* An HWMP PERR should be accepted even if path is valid. Because
  we check if we recevied it from a neighbour that we use as a next hop;

Approved by:	adrian (mentor)


git-svn-id: svn://svn.freebsd.org/base/head@246500 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Update net80211 mesh struct ieee80211_meshgann_ie.

* Change all field prefix from pann_ to gann_;
* Added IEEE80211_MESHGANN_BASE_SZ macro to be used in the length field
  of a GANN frame according to 802.11 standard;
* Changed gann_seq field type to uint32_t;
* Added a Gate Announcement interval field according to
  IEEE802.11 2012 standard;
* Added IEEE80211_MESHRT_FLAGS_GATE as flag bit to ieee80211_mesh_route;
* Added IEEE80211_MESHRT_FLAGS_GATE as flag bit to ieee80211req_mesh_route;

Approved by:	adrian (mentor)


git-svn-id: svn://svn.freebsd.org/base/head@246501 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Update in ieee80211_action.c for mesh code handlers.

* Removed meshlm_send_action and hwmp_send_action. Introduced one common
  for all Mesh Action frames meshaction_send_action. According to 802.11
  standard Link Metric and HWMP are all under Mesh Action category;
* Did similar changes to recv_action part;
* The size of meshaction_*_action is set to 12. This is to make room for
  the rest of Mesh Action category subtypes;

Approved by:	adrian (mentor)


git-svn-id: svn://svn.freebsd.org/base/head@246502 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Mesh: management mesh action frames are to be discarded
 when not peered.

* Modified ieee80211_recv_action to check if neighbour is peered for
  IEEE80211_ACTION_CAT_MESH frames, if not frame is discarded. This is
  according to IEEE802.11 2012 standard;
* Removed duplicate checks in each hwmp_recv_* handlers because HWMP
  is a subtype of mesh action;

Approved by:	adrian (mentor)


git-svn-id: svn://svn.freebsd.org/base/head@246503 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Start accepting IEEE80211_ACTION_MESH_GANN frames;

* Add IEEE80211_ACTION_MESH_GANN Action frame verification in
  ieee80211_parse_action;

Approved by:	adrian (mentor)


git-svn-id: svn://svn.freebsd.org/base/head@246504 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Mark a mesh path to a mesh gate with a 'G'.

Approved by:	adrian (mentor)


git-svn-id: svn://svn.freebsd.org/base/head@246505 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Mesh update: add base Mesh Gate functionality.

A Mesh Gate should transmit a Mesh Action frame containing
ieee80211_meshgann_ie as its only information element periodically
every ieee80211_mesh_gateint ms. Unless the mesh gate is also configure
as a ROOT, then these frames should not be send.
This is according to 802.11 2012 standard;

* Introduce new SYSCTL net.wlan.mesh.gateint, with 10s default;
* Add two new functions mesh_gatemode_setup and mesh_gatemode_cb. This
  is similar to how HWMP setups up a callout;
* Add two new action handlers mesh_recv_action_meshgate and
  mesh_send_action_meshgate;
* Added ieee80211_add_meshgate to ieee80211_mesh.h;
* Modified mesh_send_action to look similar to hwmp_send_action. This is
  because we need to send out broadcast management frames.
* Introduced a new flag for mesh state IEEE80211_MESHFLAGS_ROOT. This flag
  is now set by HWMP code when a mesh STA is configured as a ROOT. This
  is then checked by mesh_gatemode_cb before scheduling a new callout;
* Added to new field to ieee80211_mesh_state:
    + struct callout                  ms_gatetimer
    + ieee80211_mesh_seq              ms_gateseq;

Approved by:	adrian (mentor)


git-svn-id: svn://svn.freebsd.org/base/head@246506 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
sh: Fix a comment.


git-svn-id: svn://svn.freebsd.org/base/head@246507 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Propagate GANN frames, and store know gate info.

* Modified mesh_recv_action_meshgate to do following:
    + if mesh STA already knows the mesh gate of the recevied GANN frame
    + if mesh gate is know, check seq number according to 802.11 standard
    + if mesh gate is not know, add it to the list of known mesh gates
    + if forwarding is enabled and ttl >= 1 then propagate the GANN frame;
* Declare a new malloc type M_80211_MESH_GT_RT;
* Declare a struct to store GANN information, ieee80211_mesh_gate_route. And
  add it as a TAILQ list to ieee80211_mesh_state;

Approved by:	adrian (mentor)


git-svn-id: svn://svn.freebsd.org/base/head@246508 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Mark root mesh as gate when mesh gate flag set.

* Add function ieee80211_mesh_mark_gate in ieee80211_mesh.h;
* When received a proactive PREQ or RANN with corresponding mesh gate
  flag set, create a new entry in the known mesh gate list;

Approved by:	adrian (mentor)


git-svn-id: svn://svn.freebsd.org/base/head@246509 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Send frames to mesh gate if 11s discovery fails.

* Send frames that have no path to a known valid Mesh Gate;
* Added the function ieee80211_mesh_forward_to_gates that sends the frame
  to the first found Mesh Gate in the forwarding information;
* If we try to discover again while we are discovering queue frame,
  the discovery callout will send the frames either to mesh gates
  or discards them silently;
* Queue frame also if we try to discover to frequently;

Approved by:	adrian (mentor)


git-svn-id: svn://svn.freebsd.org/base/head@246510 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Mesh gate code to transmit to all mesh gates.

* Modified mesh_find_txnode to be able to handle proxy marked entries by
  recursively calling itself to find the txnode towards the active mesh gate;
* Mesh Gate: Added a new function that transmits data frames
  similar to ieee80211_start;
* Modified ieee80211_mesh_forward_to_gates so that:
     + Frames are duplicated and sent to each valid Mesh Gate;
     + Route is marked invalid before return of function, this is
       because we dont know yet which Mesh Gate is we will use;

Approved by:	adrian (mentor)


git-svn-id: svn://svn.freebsd.org/base/head@246511 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
HWMP: ic->raw_xmit didn't always point to correct ni.

This is a code re-write. ic->raw_xmit need a pointer to ieee80211_node
for the destination node (da). I have reorganized the code so that
a pointer to the da node is searched for in the end & in one place.

* Make mesh_find_txnode public to be used by HWMP, renamed to
  ieee80211_mesh_finx_txnode;
* changed the argument from ieee80211_node to ieee80211vap for all
  hwmp_send_* functions;
* removed the 'sa' argument from hwmp_send_* functions as all HWMP frames
  have the source address equal to vap->iv_myaddr;
* Modified hwmp_send_action so that if da is MULTCAST ni=vap->iv_bss
  otherwise we called ieee80211_mesh_find_txnode. Also no need to hold
  a reference in this functions if da is not MULTICAST as by finding the
  node it became referenced in ieee80211_find_txnode;

Approved by:	adrian (mentor)


git-svn-id: svn://svn.freebsd.org/base/head@246512 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Mesh HWMP PREQ update: proxy reply only if mesh STA is a meshgate.

* Original PREP frame is transmitted only by the target mesh STA or the
  mesh STA that is the proxy target;
* Fixed so that metric value is not over written incorrectly in
  hwmp_recv_preq for when replying back with a PREP;

Approved by:	adrian (mentor)


git-svn-id: svn://svn.freebsd.org/base/head@246513 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Mesh HWMP: don't send an intermediate PREP for proxy entries.

* The standard is unclear about what should happen in case a mesh STA (not
  marked as a mesh gate) recevies a PREQ for a destination that is marked
  as proxy. Solution for now is not to do intermediate reply at all, and
  let the PREQ reach the mesh gate;

Approved by:	adrian (mentor)


git-svn-id: svn://svn.freebsd.org/base/head@246514 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Mesh HWMP PREQ: fixed conditions for discarding elements.

Approved by:	adrian (mentor)


git-svn-id: svn://svn.freebsd.org/base/head@246515 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Update ddb to print mesh routing table.

* Modified _db_show_vap and _db_show_com to print mesh routing table
  if the 'm' modifier is specified;

Approved by:	adrian (mentor)


git-svn-id: svn://svn.freebsd.org/base/head@246516 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f