Date: Tue, 26 May 2009 17:56:43 +0000 (UTC) From: Rui Paulo <rpaulo@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r192824 - projects/mesh11s/sys/net80211 Message-ID: <200905261756.n4QHuhbH067528@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: rpaulo Date: Tue May 26 17:56:43 2009 New Revision: 192824 URL: http://svn.freebsd.org/changeset/base/192824 Log: * checkpoint HWMP preq processing * rename link metric function/variables to something more meaningful. Sponsored by: The FreeBSD Foundation Modified: projects/mesh11s/sys/net80211/ieee80211_hwmp.c projects/mesh11s/sys/net80211/ieee80211_input.c projects/mesh11s/sys/net80211/ieee80211_mesh.c projects/mesh11s/sys/net80211/ieee80211_mesh.h projects/mesh11s/sys/net80211/ieee80211_node.h Modified: projects/mesh11s/sys/net80211/ieee80211_hwmp.c ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_hwmp.c Tue May 26 17:54:55 2009 (r192823) +++ projects/mesh11s/sys/net80211/ieee80211_hwmp.c Tue May 26 17:56:43 2009 (r192824) @@ -64,6 +64,27 @@ __FBSDID("$FreeBSD$"); #include <net80211/ieee80211_input.h> +/* + * HWMP Forwarding Information table. + */ +struct ieee80211_hwmp_forwardinfo { + TAILQ_ENTRY(ieee80211_hwmp_path) hp_list; + uint8_t hp_target[IEEE80211_ADDR_LEN]; + ieee80211_seq hp_seq; /* HWMP sequence number */ + uint8_t hp_mnxthop[IEEE80211_ADDR_LEN]; + uint32_t hp_metric; /* Path Metric */ + uint32_t hp_nhops; /* Number of Hops */ + /* XXX percursor list */ + uint32_t hp_lifetime; +}; + +static void hwmp_recv_preq(struct ieee80211vap *, struct ieee80211_node *, + const struct ieee80211_meshpreq_ie *); +static void hwmp_recv_prep(struct ieee80211vap *, struct ieee80211_node *, + const struct ieee80211_meshprep_ie *); +static void hwmp_recv_perr(struct ieee80211vap *, struct ieee80211_node *, + const struct ieee80211_meshperr_ie *); + static int ieee80211_hwmp_maxhops = 31; #ifdef notyet static int ieee80211_hwmp_maxhopstime = 500; @@ -76,29 +97,36 @@ static int ieee80211_hwmp_rootmode = 0; static int ieee80211_hwmp_pathtoroottimeout = 5000; static int ieee80211_hmwp_rootint = 2000; static int ieee80211_hwmp_rannint = 1000; +#endif static int ieee80211_hwmp_targetonly = 1;/* reply to PREQs automatically */ static int ieee80211_hwmp_replyforward = 1; /* propagate PREQs */ +#ifdef notyet static int ieee80211_hwmp_pathmaintenance = 2000; static int ieee80211_hwmp_confirmint = 2000; #endif -extern int ieee80211_mesh_ttl; +/* + * Target Address set in a Proactive PREQ. + */ +static const uint8_t proactiveaddr[IEEE80211_ADDR_LEN] = + { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; SYSCTL_NODE(_net_wlan, OID_AUTO, hwmp, CTLFLAG_RD, 0, "IEEE 802.11s HWMP parameters"); SYSCTL_INT(_net_wlan_hwmp, OID_AUTO, maxhops, CTLTYPE_INT | CTLFLAG_RW, &ieee80211_hwmp_maxhops, 0, "Maximum number of hops for paths"); +SYSCTL_INT(_net_wlan_hwmp, OID_AUTO, targetonly, CTLTYPE_INT | CTLFLAG_RW, + &ieee80211_hwmp_targetonly, 0, "TBD"); +SYSCTL_INT(_net_wlan_hwmp, OID_AUTO, replyforward, CTLTYPE_INT | CTLFLAG_RW, + &ieee80211_hwmp_replyforward, 0, "TBD"); #ifdef notyet SYSCTL_INT(_net_wlan_hwmp, OID_AUTO, rootmode, CTLTYPE_INT | CTLFLAG_RW, &ieee80211_hwmp_rootmode, 0, "Root Mesh Point Node"); #endif -static void hwmp_recv_preq(struct ieee80211vap *, - const struct ieee80211_meshpreq_ie *); -static void hwmp_recv_prep(struct ieee80211vap *, - const struct ieee80211_meshprep_ie *); -static void hwmp_recv_perr(struct ieee80211vap *, - const struct ieee80211_meshperr_ie *); +extern int ieee80211_mesh_ttl; +extern int ieee80211_mesh_forwarding; + void ieee80211_hwmp_recv_action(struct ieee80211vap *vap, struct ieee80211_node *ni, @@ -110,7 +138,6 @@ ieee80211_hwmp_recv_action(struct ieee80 struct ieee80211_meshpreq_ie *meshpreq = NULL; struct ieee80211_meshprep_ie *meshprep = NULL; struct ieee80211_meshperr_ie *meshperr = NULL; - union ieee80211_send_action_args vargs; wh = mtod(m0, struct ieee80211_frame *); ia = (struct ieee80211_action *) &wh[1]; @@ -156,43 +183,31 @@ ieee80211_hwmp_recv_action(struct ieee80 if (meshpreq == NULL) { IEEE80211_DISCARD(vap, IEEE80211_MSG_ACTION | IEEE80211_MSG_MESH, - wh, NULL, "%s", "preq without IE"); + wh, NULL, "%s", "PREQ without IE"); vap->iv_stats.is_rx_mgtdiscard++; return; } - hwmp_recv_preq(vap, meshpreq); - /* - * Is the peer trying to find us? - */ - if (IEEE80211_ADDR_EQ(vap->iv_myaddr, - meshpreq->preq_targets[0].target_addr)) { - struct ieee80211_meshprep_ie prep; - /* - * Build and send a path reply frame. - */ - prep.prep_flags = 0; - prep.prep_hopcount = 0; - prep.prep_ttl = ieee80211_mesh_ttl; - IEEE80211_ADDR_COPY(prep.prep_targetaddr, - meshpreq->preq_targets[0].target_addr); - prep.prep_targetseq = meshpreq->preq_origseq; - prep.prep_lifetime = 5000; - prep.prep_metric = 0; - IEEE80211_ADDR_COPY(prep.prep_origaddr, - vap->iv_myaddr); - prep.prep_origseq = 1; - vargs.ptrarg = &prep; - ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHPATH, - IEEE80211_ACTION_MESHPATH_REP, - vargs); - } + hwmp_recv_preq(vap, ni, meshpreq); break; case IEEE80211_ACTION_MESHPATH_REP: - hwmp_recv_prep(vap, meshprep); + if (meshprep == NULL) { + IEEE80211_DISCARD(vap, + IEEE80211_MSG_ACTION | IEEE80211_MSG_MESH, + wh, NULL, "%s", "PREP without IE"); + vap->iv_stats.is_rx_mgtdiscard++; + return; + } + hwmp_recv_prep(vap, ni, meshprep); break; case IEEE80211_ACTION_MESHPATH_ERR: - hwmp_recv_perr(vap, meshperr); + if (meshperr == NULL) { + IEEE80211_DISCARD(vap, + IEEE80211_MSG_ACTION | IEEE80211_MSG_MESH, + wh, NULL, "%s", "PERR without IE"); + vap->iv_stats.is_rx_mgtdiscard++; + return; + } + hwmp_recv_perr(vap, ni, meshperr); break; default: IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_MESH, @@ -214,7 +229,7 @@ ieee80211_hwmp_recv_action(struct ieee80 * Add a Mesh Path Reply IE to a frame. */ uint8_t * -ieee80211_add_meshprep(uint8_t *frm, const struct ieee80211_meshprep_ie *prep) +ieee80211_add_meshprep(uint8_t *frm, struct ieee80211_meshprep_ie *prep) { *frm++ = IEEE80211_ELEMID_MESHPREP; @@ -234,21 +249,140 @@ ieee80211_add_meshprep(uint8_t *frm, con return frm; } +#define PREQ_TFLAGS(n) preq->preq_targets[n].target_flags +#define PREQ_TADDR(n) preq->preq_targets[n].target_addr +#define PREQ_TSEQ(n) preq->preq_targets[n].target_seq static void -hwmp_recv_preq(struct ieee80211vap *vap, +hwmp_recv_preq(struct ieee80211vap *vap, struct ieee80211_node *ni, const struct ieee80211_meshpreq_ie *preq) { + union ieee80211_send_action_args vargs; + + /* + * Acceptance criteria: if the PREQ is not for us and + * forwarding is disabled, discard this PREQ. + */ + if (!IEEE80211_ADDR_EQ(vap->iv_myaddr, PREQ_TADDR(0)) && + !ieee80211_mesh_forwarding) + return; + + /* + * Step 1. Record the PREQ ID and the originator MAC address. + */ + + /* + * Step 2. + */ + + /* + * Step 3. Check if the PREQ is addressed to us. + * XXX: check if this is part of a proxy address. + */ + if (IEEE80211_ADDR_EQ(vap->iv_myaddr, PREQ_TADDR(0))) { + struct ieee80211_meshprep_ie prep; + /* + * Build and send a PREP frame. + */ + prep.prep_flags = 0; + prep.prep_hopcount = 0; + prep.prep_ttl = ieee80211_mesh_ttl; + IEEE80211_ADDR_COPY(prep.prep_targetaddr, + preq->preq_targets[0].target_addr); + prep.prep_targetseq = preq->preq_origseq; + prep.prep_lifetime = preq->preq_lifetime; + prep.prep_metric = IEEE80211_MESHLMETRIC_INITIALVAL; + IEEE80211_ADDR_COPY(prep.prep_origaddr, vap->iv_myaddr); + /* XXX */ + prep.prep_origseq = 1; + vargs.ptrarg = &prep; + ieee80211_send_action(ni, + IEEE80211_ACTION_CAT_MESHPATH, + IEEE80211_ACTION_MESHPATH_REP, + vargs); + return; + } + + /* XXX: Step 4. Check for AE bit and update proxy information */ + + /* + * Step 5. Intermediate reply: check if we have this path on our + * table and the TO bit is unset. + */ + if (!(PREQ_TFLAGS(0) & IEEE80211_MESHPREQ_TFLAGS_TO)) { + + /* + * XXX: Step 6. Update the percursor table + */ + } + + /* + * XXX: Step 8. Proactive PREQ: reply with a proactive PREP to the + * root STA if requested. + */ + if (IEEE80211_ADDR_EQ(PREQ_TADDR(0), proactiveaddr) && + (PREQ_TFLAGS(0) & + ((IEEE80211_MESHPREQ_TFLAGS_TO|IEEE80211_MESHPREQ_TFLAGS_RF) == + (IEEE80211_MESHPREQ_TFLAGS_TO|IEEE80211_MESHPREQ_TFLAGS_RF)))) { + /* + * Does the root want a proactive PREP ? + */ + if (preq->preq_flags & IEEE80211_MESHPREQ_FLAGS_PP) { + + } + } } +#undef PREQ_TFLAGS +#undef PREQ_TADDR +#undef PREQ_TSEQ static void -hwmp_recv_prep(struct ieee80211vap *vap, +hwmp_recv_prep(struct ieee80211vap *vap, struct ieee80211_node *ni, const struct ieee80211_meshprep_ie *prep) { } + static void -hwmp_recv_perr(struct ieee80211vap *vap, - const struct ieee80211_meshprep_ie *perr) +hwmp_recv_perr(struct ieee80211vap *vap, struct ieee80211_node *ni, + const struct ieee80211_meshperr_ie *perr) { } + +static int +hwmp_ioctl_get80211(struct ieee80211vap *vap, struct ieee80211req *ireq) +{ + int error; + + error = 0; + switch (ireq->i_type) { +#ifdef notyet + case IEEE80211_IOC_HWMPFI: + if (vap->iv_opmode != IEEE80211_M_MBSS) + return EINVAL; +#endif + default: + return ENOSYS; + } + + return error; +} +IEEE80211_IOCTL_GET(hwmp, hwmp_ioctl_get80211); + +static int +hwmp_ioctl_set80211(struct ieee80211vap *vap, struct ieee80211req *ireq) +{ + int error; + + error = 0; + switch (ireq->i_type) { +#ifdef notyet + case IEEE80211_IOC_HWMPFI: +#endif + default: + return ENOSYS; + } + + return error; +} +IEEE80211_IOCTL_SET(hwmp, hwmp_ioctl_set80211); Modified: projects/mesh11s/sys/net80211/ieee80211_input.c ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_input.c Tue May 26 17:54:55 2009 (r192823) +++ projects/mesh11s/sys/net80211/ieee80211_input.c Tue May 26 17:56:43 2009 (r192824) @@ -807,9 +807,9 @@ ieee80211_recv_action(struct ieee80211_n } break; case IEEE80211_ACTION_CAT_MESHPEERING: - case IEEE80211_ACTION_CAT_MESHLINK: + case IEEE80211_ACTION_CAT_MESHLMETRIC: case IEEE80211_ACTION_CAT_MESHPATH: - /* handled by ieee80211_mesh.c */ + /* handled by ieee80211_mesh.c and ieee80211_hwmp.c */ break; default: IEEE80211_NOTE(vap, Modified: projects/mesh11s/sys/net80211/ieee80211_mesh.c ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_mesh.c Tue May 26 17:54:55 2009 (r192823) +++ projects/mesh11s/sys/net80211/ieee80211_mesh.c Tue May 26 17:56:43 2009 (r192824) @@ -848,29 +848,31 @@ mesh_recv_action(struct ieee80211_node * ieee80211_hwmp_recv_action(vap, ni, m0); break; /* - * Airtime link metric handling. + * Link Metric handling. */ - case IEEE80211_ACTION_CAT_MESHLINK: + case IEEE80211_ACTION_CAT_MESHLMETRIC: switch (ia->ia_action) { - case IEEE80211_ACTION_MESHLINK_REQ: + case IEEE80211_ACTION_MESHLMETRIC_REQ: { uint32_t metric; + /* XXX: check if we are using airtime or + aother algorithm */ metric = ieee80211_airtime_calc(vap, ni); vargs.ptrarg = &metric; ieee80211_send_action(ni, - IEEE80211_ACTION_CAT_MESHLINK, - IEEE80211_ACTION_MESHLINK_REP, + IEEE80211_ACTION_CAT_MESHLMETRIC, + IEEE80211_ACTION_MESHLMETRIC_REP, vargs); } break; - case IEEE80211_ACTION_MESHLINK_REP: + case IEEE80211_ACTION_MESHLMETRIC_REP: break; default: IEEE80211_DISCARD(vap, IEEE80211_MSG_ACTION | IEEE80211_MSG_MESH, - wh, NULL, "mesh link using reserved action %d", - ia->ia_action); + wh, NULL, "mesh link metric using reserved " + "action %d", ia->ia_action); vap->iv_stats.is_rx_mgtdiscard++; } break; @@ -1137,7 +1139,7 @@ ieee80211_airtime_calc(struct ieee80211v * Add a Mesh Link Metric report IE to a frame. */ uint8_t * -ieee80211_add_meshlink(uint8_t *frm, uint32_t metric) +ieee80211_add_meshlmetric(uint8_t *frm, uint32_t metric) { *frm++ = IEEE80211_ELEMID_MESHLINK; Modified: projects/mesh11s/sys/net80211/ieee80211_mesh.h ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_mesh.h Tue May 26 17:54:55 2009 (r192823) +++ projects/mesh11s/sys/net80211/ieee80211_mesh.h Tue May 26 17:56:43 2009 (r192824) @@ -86,10 +86,11 @@ struct ieee80211_meshid_ie { #define IEEE80211_MESHID_LEN IEEE80211_NWID_LEN /* Link Metric Report */ -struct ieee80211_meshlink_ie { - uint8_t link_ie; /* IEEE80211_ELEMID_MESHLINK */ - uint8_t link_len; - /* XXXRP: missing variable metric */ +struct ieee80211_meshlmetric_ie { + uint8_t lm_ie; /* IEEE80211_ELEMID_MESHLINK */ + uint8_t lm_len; + uint32_t lm_metric; +#define IEEE80211_MESHLMETRIC_INITIALVAL 0 } __packed; /* Congestion Notification */ @@ -216,6 +217,9 @@ struct ieee80211_meshpreq_ie { uint8_t preq_ie; /* IEEE80211_ELEMID_MESHPREQ */ uint8_t preq_len; uint8_t preq_flags; +#define IEEE80211_MESHPREQ_FLAGS_PR 0x01 /* Portal Role */ +#define IEEE80211_MESHPREQ_FLAGS_AE 0x02 /* Address Extension */ +#define IEEE80211_MESHPREQ_FLAGS_PP 0x04 /* Proactive PREP */ uint8_t preq_hopcount; uint8_t preq_ttl; uint32_t preq_id; @@ -227,6 +231,9 @@ struct ieee80211_meshpreq_ie { uint8_t preq_tcount; /* target count */ struct { uint8_t target_flags; +#define IEEE80211_MESHPREQ_TFLAGS_TO 0x01 /* Target Only */ +#define IEEE80211_MESHPREQ_TFLAGS_RF 0x02 /* Reply and Forward */ +#define IEEE80211_MESHPREQ_TFLAGS_USN 0x04 /* Unknown HWMP seq number */ uint8_t target_addr[IEEE80211_ADDR_LEN]; uint32_t target_seq; /* HWMP Sequence Number */ } preq_targets[1] __packed; /* NB: variable size */ @@ -282,7 +289,7 @@ struct ieee80211_meshpuc_ie { * 802.11s Action Frames */ #define IEEE80211_ACTION_CAT_MESHPEERING 30 /* XXX Linux */ -#define IEEE80211_ACTION_CAT_MESHLINK 13 +#define IEEE80211_ACTION_CAT_MESHLMETRIC 13 #define IEEE80211_ACTION_CAT_MESHPATH 32 /* XXX Linux */ #define IEEE80211_ACTION_CAT_INTERWORK 15 #define IEEE80211_ACTION_CAT_RESOURCE 16 @@ -312,8 +319,8 @@ enum { * Mesh Link Metric Action codes. */ enum { - IEEE80211_ACTION_MESHLINK_REQ = 0, /* Link Metric Request */ - IEEE80211_ACTION_MESHLINK_REP = 1, /* Link Metric Report */ + IEEE80211_ACTION_MESHLMETRIC_REQ = 0, /* Link Metric Request */ + IEEE80211_ACTION_MESHLMETRIC_REP = 1, /* Link Metric Report */ /* 2-255 reserved */ }; @@ -334,7 +341,7 @@ uint8_t * ieee80211_add_meshpeer(uint8_t uint16_t); uint32_t ieee80211_airtime_calc(struct ieee80211vap *, struct ieee80211_node *); -uint8_t * ieee80211_add_meshlink(uint8_t *, uint32_t); +uint8_t * ieee80211_add_meshlmetric(uint8_t *, uint32_t); void ieee80211_create_mbss(struct ieee80211vap *, struct ieee80211_channel *); uint32_t ieee80211_mesh_getseq(void); Modified: projects/mesh11s/sys/net80211/ieee80211_node.h ============================================================================== --- projects/mesh11s/sys/net80211/ieee80211_node.h Tue May 26 17:54:55 2009 (r192823) +++ projects/mesh11s/sys/net80211/ieee80211_node.h Tue May 26 17:56:43 2009 (r192824) @@ -88,7 +88,7 @@ struct ieee80211_ies { int len; /* data size in bytes */ }; -enum ieee80211_mesh_state { +enum ieee80211_mesh_mlstate { IEEE80211_NODE_MESH_IDLE = 0, IEEE80211_NODE_MESH_OPENSNT = 1, /* open frame received */ IEEE80211_NODE_MESH_OPENRCV = 2, /* open frame sent */ @@ -184,15 +184,12 @@ struct ieee80211_node { uint8_t ni_dtim_count; /* DTIM count for last bcn */ /* 11s state */ - enum ieee80211_mesh_state ni_mlstate; /* peering management state */ + enum ieee80211_mesh_mlstate ni_mlstate; /* peering management state */ uint16_t ni_mllid; /* link local ID */ uint16_t ni_mlpid; /* link peer ID */ struct callout ni_mltimer; /* link mesh timer */ uint8_t ni_mlrcnt; /* link mesh retry counter */ uint8_t ni_mltval; /* link mesh timer value */ - uint8_t ni_mnxthop[IEEE80211_ADDR_LEN]; - uint32_t ni_mpmetric; /* path metric */ - ieee80211_seq ni_mhwmpseq; /* HWMP path seq number */ /* 11n state */ uint16_t ni_htcap; /* HT capabilities */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905261756.n4QHuhbH067528>