diff --git a/src/cntlr_qos.c b/src/cntlr_qos.c index f87f37ce4bbe3f1fc5e8877882a4a54a380f7795..4d75ccf0e3f53540ea2e75d20a5812d8e11281f4 100644 --- a/src/cntlr_qos.c +++ b/src/cntlr_qos.c @@ -70,164 +70,164 @@ static int cntlr_qos_send_sp_req(struct controller *c, uint8_t *origin, struct qos_rule *rule) { - struct cmdu_buff *buf; - uint16_t mid = 0x1111; - int ret; - - /* - * FIXME: - * the Multi-AP Controller should ensure that the Service Prioritization - * Rule TLV is compatible with the Multi-AP Agent’s capabilities as - * identified in the most recent AP Capability Report message received from - * that Multi-AP Agent. - */ - - buf = cmdu_alloc_simple(CMDU_SERVICE_PRIORITIZATION_REQUEST, - &mid); - if (!buf) { - fprintf(stderr, "%s: -ENOMEM\n", __func__); - return -1; - } - - /* - * FIXME: Basing priority on rule number is not a proper way. - */ - ret = cntlr_gen_spr_tlv(c, buf, - rule->rule_num, - true, - 255 - rule->rule_num, - rule->output, - rule->always_match); - if (ret != 0) { - fprintf(stderr, "Failed to build SPR TLV\n"); - return -1; - } - - switch (rule->type) - { - case QOS_RULE_TYPE_DSCP_PCP: - { - /* - * If triggered, a Multi-AP Controller shall send a - * Service Prioritization Request message with a DSCP Mapping Table - * TLV (see section 17.2.71). - */ - ret = cntlr_gen_dscp_mapping_table_tlv(c, buf, - rule->dscp_pcp.dscp_pcp); - - break; - } - /* - * If triggered, a Multi-AP Controller shall send a Service - * Prioritization Request message with a QoS Management Descriptor TLV - * (see section 17.2.93). - */ - /* - * If the Descriptor Element field within a QoS Management Descriptor - * TLV is an MSCS or SCS Descriptor element, the validity lifetime of - * the QMID is either until the Controller receives a Profile-2 Error - * Code TLV indicating the Multi-AP Agent is unable to configure the - * Descriptor or (if the Descriptor is accepted) until the Multi-AP - * Controller sends a QoS Mangagment Descriptor TLV removing the - * Descriptor. - */ - case QOS_RULE_TYPE_MSCS: - case QOS_RULE_TYPE_SCS: - case QOS_RULE_TYPE_MGMT: - { - uint8_t *desc = NULL; - uint32_t desc_len = 0; - - switch (rule->type) - { - case QOS_RULE_TYPE_SCS: - { - desc = cntlr_gen_qos_scs_desc(c, - IEEE1905_SCS_DESC_REQUEST_TYPE_ADD, - &rule->mgmt.scs, - &desc_len); - break; - } - case QOS_RULE_TYPE_MSCS: - { - desc = cntlr_gen_qos_mscs_desc(c, - IEEE1905_SCS_DESC_REQUEST_TYPE_ADD, - &rule->mgmt.mscs, - &desc_len); - break; - } - case QOS_RULE_TYPE_MGMT: - { - desc = cntlr_gen_qos_mgmt_elem_desc(c, - 0 /* not defined yet */, - &rule->mgmt.qm, - &desc_len); - break; - } - default: - { - break; - } - } - - /* - * If the Descriptor Element field within a QoS Management - * Descriptor TLV is a QoS Management element containing a DSCP - * Policy attibute, the QMID is used in a Profile-2 Error Code TLV - * to indicate the Multi-AP Agent is unable to configure the rule. - * - * If the Descriptor Element field within a QoS Management - * Descriptor TLV is a QoS Management element containing a DSCP - * Policy attribute, the Policy ID in the Descriptor Element field - * is chosen by the Multi-AP Controller, and (per [25]) has scope - * across the ESS (i.e., policy survives a roam after, after STA - * roams to another BSSID). - * - * If triggered, a Multi-AP Controller may modify or remove a DSCP - * Policy by sending an updated QoS Mangement element containing a - * DSCP Policy attribute with the same Policy ID within a QoS - * Management Descriptor TLV in a Service Prioritization Request - * message to a Multi-AP Agent. - */ - ret = cntlr_gen_qos_management_desc_tlv(c, buf, - rule->mgmt.qmid, rule->mgmt.bssid, rule->mgmt.sta, - desc, desc_len); - break; - } - default: - { - ret = -1; - break; - } - } - - memcpy(buf->origin, origin, 6); - cmdu_put_eom(buf); - if (ret == 0) { - send_cmdu(c, buf); - } - cmdu_free(buf); - - return 0; + struct cmdu_buff *buf; + uint16_t mid = 0x1111; + int ret; + + /* + * FIXME: + * the Multi-AP Controller should ensure that the Service Prioritization + * Rule TLV is compatible with the Multi-AP Agent’s capabilities as + * identified in the most recent AP Capability Report message received from + * that Multi-AP Agent. + */ + + buf = cmdu_alloc_simple(CMDU_SERVICE_PRIORITIZATION_REQUEST, + &mid); + if (!buf) { + fprintf(stderr, "%s: -ENOMEM\n", __func__); + return -1; + } + + /* + * FIXME: Basing priority on rule number is not a proper way. + */ + ret = cntlr_gen_spr_tlv(c, buf, + rule->rule_num, + true, + 255 - rule->rule_num, + rule->output, + rule->always_match); + if (ret != 0) { + fprintf(stderr, "Failed to build SPR TLV\n"); + return -1; + } + + switch (rule->type) + { + case QOS_RULE_TYPE_DSCP_PCP: + { + /* + * If triggered, a Multi-AP Controller shall send a + * Service Prioritization Request message with a DSCP Mapping Table + * TLV (see section 17.2.71). + */ + ret = cntlr_gen_dscp_mapping_table_tlv(c, buf, + rule->dscp_pcp.dscp_pcp); + + break; + } + /* + * If triggered, a Multi-AP Controller shall send a Service + * Prioritization Request message with a QoS Management Descriptor TLV + * (see section 17.2.93). + */ + /* + * If the Descriptor Element field within a QoS Management Descriptor + * TLV is an MSCS or SCS Descriptor element, the validity lifetime of + * the QMID is either until the Controller receives a Profile-2 Error + * Code TLV indicating the Multi-AP Agent is unable to configure the + * Descriptor or (if the Descriptor is accepted) until the Multi-AP + * Controller sends a QoS Mangagment Descriptor TLV removing the + * Descriptor. + */ + case QOS_RULE_TYPE_MSCS: + case QOS_RULE_TYPE_SCS: + case QOS_RULE_TYPE_MGMT: + { + uint8_t *desc = NULL; + uint32_t desc_len = 0; + + switch (rule->type) + { + case QOS_RULE_TYPE_SCS: + { + desc = cntlr_gen_qos_scs_desc(c, + IEEE1905_SCS_DESC_REQUEST_TYPE_ADD, + &rule->mgmt.scs, + &desc_len); + break; + } + case QOS_RULE_TYPE_MSCS: + { + desc = cntlr_gen_qos_mscs_desc(c, + IEEE1905_SCS_DESC_REQUEST_TYPE_ADD, + &rule->mgmt.mscs, + &desc_len); + break; + } + case QOS_RULE_TYPE_MGMT: + { + desc = cntlr_gen_qos_mgmt_elem_desc(c, + 0 /* not defined yet */, + &rule->mgmt.qm, + &desc_len); + break; + } + default: + { + break; + } + } + + /* + * If the Descriptor Element field within a QoS Management + * Descriptor TLV is a QoS Management element containing a DSCP + * Policy attibute, the QMID is used in a Profile-2 Error Code TLV + * to indicate the Multi-AP Agent is unable to configure the rule. + * + * If the Descriptor Element field within a QoS Management + * Descriptor TLV is a QoS Management element containing a DSCP + * Policy attribute, the Policy ID in the Descriptor Element field + * is chosen by the Multi-AP Controller, and (per [25]) has scope + * across the ESS (i.e., policy survives a roam after, after STA + * roams to another BSSID). + * + * If triggered, a Multi-AP Controller may modify or remove a DSCP + * Policy by sending an updated QoS Mangement element containing a + * DSCP Policy attribute with the same Policy ID within a QoS + * Management Descriptor TLV in a Service Prioritization Request + * message to a Multi-AP Agent. + */ + ret = cntlr_gen_qos_management_desc_tlv(c, buf, + rule->mgmt.qmid, rule->mgmt.bssid, rule->mgmt.sta, + desc, desc_len); + break; + } + default: + { + ret = -1; + break; + } + } + + memcpy(buf->origin, origin, 6); + cmdu_put_eom(buf); + if (ret == 0) { + send_cmdu(c, buf); + } + cmdu_free(buf); + + return 0; } void cntlr_qos_sync_node(struct controller *c, uint8_t *origin) { - struct controller_config *cc = &c->cfg; - struct qos_rule *rule = NULL; - - dbg("%s: syncing QoS in nodes\n", __func__); - - /* - * If triggered, a Multi-AP Controller shall send a Service Prioritization - * Request message with a Service Prioritization Rule TLV - * (see section 17.1.47). - */ - list_for_each_entry(rule, &cc->qos.rule, list) { - dbg("%s: syncing QoS in node, sending SPR\n", __func__); - cntlr_qos_send_sp_req(c, origin, rule); - } + struct controller_config *cc = &c->cfg; + struct qos_rule *rule = NULL; + + dbg("%s: syncing QoS in nodes\n", __func__); + + /* + * If triggered, a Multi-AP Controller shall send a Service Prioritization + * Request message with a Service Prioritization Rule TLV + * (see section 17.1.47). + */ + list_for_each_entry(rule, &cc->qos.rule, list) { + dbg("%s: syncing QoS in node, sending SPR\n", __func__); + cntlr_qos_send_sp_req(c, origin, rule); + } } #endif