changes to switch between draft-lihawi v00 and v04 (#195)

add different pon-access-line-versions (#183) and add unit tests

+ unit test for util functions
+ draft-lihawi v0 and v4 switch
This commit is contained in:
AkshatJain1911
2023-06-30 09:48:37 +02:00
committed by GitHub
parent 03e19ff241
commit 7ab15f7ea1
4 changed files with 89 additions and 9 deletions
+1 -1
View File
@@ -12,7 +12,7 @@
typedef struct bbl_access_line_profile_
{
uint16_t access_line_profile_id;
uint8_t pon_access_line_version;
/* broadband forum tr101 */
uint32_t act_up; /* Actual Data Rate Upstream */
+14 -1
View File
@@ -143,7 +143,7 @@ json_parse_access_line_profile(json_t *config, bbl_access_line_profile_s *profil
json_t *value = NULL;
const char *schema[] = {
"access-line-profile-id", "act-up", "act-down",
"access-line-profile-id", "pon-access-line-version", "act-up", "act-down",
"min-up", "min-down", "att-up", "max-up", "max-down",
"att-down", "min-up-low", "min-down-low",
"max-interl-delay-up", "act-interl-delay-up", "max-interl-delay-down",
@@ -167,6 +167,19 @@ json_parse_access_line_profile(json_t *config, bbl_access_line_profile_s *profil
return false;
}
value = json_object_get(config, "pon-access-line-version");
if(value) {
if(!strcmp(json_string_value(value), "DRAFT-LIHAWI-00")){
profile->pon_access_line_version = DRAFT_LIHAWI_00;
} else if(!strcmp(json_string_value(value), "DRAFT-LIHAWI-04")){
profile->pon_access_line_version = DRAFT_LIHAWI_04;
} else{
fprintf(stderr, "JSON config error: Invalid value for pon-access-line-version\n");
return false;
}
} else{
profile->pon_access_line_version = DRAFT_LIHAWI_04;
}
value = json_object_get(config, "act-up");
if(value) {
profile->act_up = json_number_value(value);
+56 -7
View File
@@ -1776,7 +1776,14 @@ encode_pppoe_discovery(uint8_t *buf, uint16_t *len,
vendor_len += 6;
}
if(access_line_profile->pon_type) {
*buf = ACCESS_LINE_PON_TYPE;
switch(access_line_profile->pon_access_line_version) {
case DRAFT_LIHAWI_00:
*buf = ACCESS_LINE_PON_TYPE_LIHAWI_00;
break;
default:
*buf = ACCESS_LINE_PON_TYPE;
break;
}
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
*buf = 4;
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
@@ -1857,7 +1864,14 @@ encode_pppoe_discovery(uint8_t *buf, uint16_t *len,
vendor_len += 6;
}
if(access_line_profile->ont_onu_avg_down) {
*buf = ACCESS_LINE_ONT_ONU_AVG_DOWN;
switch(access_line_profile->pon_access_line_version) {
case DRAFT_LIHAWI_00:
*buf = ACCESS_LINE_ONT_ONU_AVG_DOWN_LIHAWI_00;
break;
default:
*buf = ACCESS_LINE_ONT_ONU_AVG_DOWN;
break;
}
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
*buf = 4;
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
@@ -1866,7 +1880,14 @@ encode_pppoe_discovery(uint8_t *buf, uint16_t *len,
vendor_len += 6;
}
if(access_line_profile->ont_onu_peak_down) {
*buf = ACCESS_LINE_ONT_ONU_PEAK_DOWN;
switch(access_line_profile->pon_access_line_version) {
case DRAFT_LIHAWI_00:
*buf = ACCESS_LINE_ONT_ONU_PEAK_DOWN_LIHAWI_00;
break;
default:
*buf = ACCESS_LINE_ONT_ONU_PEAK_DOWN;
break;
}
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
*buf = 4;
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
@@ -1875,7 +1896,14 @@ encode_pppoe_discovery(uint8_t *buf, uint16_t *len,
vendor_len += 6;
}
if(access_line_profile->ont_onu_max_up) {
*buf = ACCESS_LINE_ONT_ONU_MAX_UP;
switch(access_line_profile->pon_access_line_version) {
case DRAFT_LIHAWI_00:
*buf = ACCESS_LINE_ONT_ONU_MAX_UP_LIHAWI_00;
break;
default:
*buf = ACCESS_LINE_ONT_ONU_MAX_UP;
break;
}
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
*buf = 4;
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
@@ -1884,7 +1912,14 @@ encode_pppoe_discovery(uint8_t *buf, uint16_t *len,
vendor_len += 6;
}
if(access_line_profile->ont_onu_ass_up) {
*buf = ACCESS_LINE_ONT_ONU_ASS_UP;
switch(access_line_profile->pon_access_line_version) {
case DRAFT_LIHAWI_00:
*buf = ACCESS_LINE_ONT_ONU_ASS_UP_LIHAWI_00;
break;
default:
*buf = ACCESS_LINE_ONT_ONU_ASS_UP;
break;
}
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
*buf = 4;
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
@@ -1893,7 +1928,14 @@ encode_pppoe_discovery(uint8_t *buf, uint16_t *len,
vendor_len += 6;
}
if(access_line_profile->pon_max_up) {
*buf = ACCESS_LINE_PON_MAX_UP;
switch(access_line_profile->pon_access_line_version) {
case DRAFT_LIHAWI_00:
*buf = ACCESS_LINE_PON_MAX_UP_LIHAWI_00;
break;
default:
*buf = ACCESS_LINE_PON_MAX_UP;
break;
}
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
*buf = 4;
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
@@ -1902,7 +1944,14 @@ encode_pppoe_discovery(uint8_t *buf, uint16_t *len,
vendor_len += 6;
}
if(access_line_profile->pon_max_down) {
*buf = ACCESS_LINE_PON_MAX_DOWN;
switch(access_line_profile->pon_access_line_version) {
case DRAFT_LIHAWI_00:
*buf = ACCESS_LINE_PON_MAX_DOWN_LIHAWI_00;
break;
default:
*buf = ACCESS_LINE_PON_MAX_DOWN;
break;
}
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
*buf = 4;
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
+18
View File
@@ -523,6 +523,24 @@ typedef enum access_line_attr_ {
ACCESS_LINE_PON_MAX_DOWN = 0xb5, /* PON-Tree-Maximum-Data-Rate-Downstream */
} access_line_attr_t;
typedef enum access_line_attr_lihawi_00_ {
/* draft-lihawi-ancp-protocol-access-extension-00 */
ACCESS_LINE_PON_TYPE_LIHAWI_00 = 0x92, /* PON-Access-Type */
ACCESS_LINE_ONT_ONU_AVG_DOWN_LIHAWI_00 = 0x93, /* ONT/ONU-Average-Data-Rate-Downstream */
ACCESS_LINE_ONT_ONU_PEAK_DOWN_LIHAWI_00 = 0x94, /* ONT/ONU-Peak-Data-Rate-Downstream */
ACCESS_LINE_ONT_ONU_MAX_UP_LIHAWI_00 = 0x95, /* ONT/ONU-Maximum-Data-Rate-Upstream */
ACCESS_LINE_ONT_ONU_ASS_UP_LIHAWI_00 = 0x96, /* ONT/ONU-Assured-Data-Rate-Upstream */
ACCESS_LINE_PON_MAX_UP_LIHAWI_00 = 0x97, /* PON-Tree-Maximum-Data-Rate-Upstream */
ACCESS_LINE_PON_MAX_DOWN_LIHAWI_00 = 0x98, /* PON-Tree-Maximum-Data-Rate-Downstream */
}access_line_attr_lihawi_00_t;
typedef enum pon_access_line_version{
DRAFT_LIHAWI_00 = 0,
DRAFT_LIHAWI_04 = 4,
} __attribute__ ((__packed__)) pon_access_line_version_t;
typedef struct access_line_ {
char *aci; /* Agent Circuit ID */
char *ari; /* Agent Remote ID */