From ad667102c5100732fece4618f2dc416b83ad40cb Mon Sep 17 00:00:00 2001 From: Christian Giese Date: Mon, 22 Mar 2021 16:49:00 +0100 Subject: [PATCH] Add DSL Type support --- docs/config.md | 2 ++ src/bbl.h | 4 ++++ src/bbl_config.c | 11 +++++++++++ src/bbl_protocols.c | 9 +++++++++ src/bbl_protocols.h | 9 +++++---- src/bbl_session.c | 1 + src/bbl_tx.c | 2 ++ 7 files changed, 34 insertions(+), 4 deletions(-) diff --git a/docs/config.md b/docs/config.md index 88ada980..00ca08ec 100644 --- a/docs/config.md +++ b/docs/config.md @@ -144,6 +144,7 @@ Attribute | Description | Default `agent-remote-id` | Optionally overwrite the agent-remote-id from access-line section per access configuration `rate-up` | Optionally overwrite the rate-up from access-line section per access configuration `rate-down` | Optionally overwrite the rate-down from access-line section per access configuration +`dsl-type` | Optionally overwrite the dsl-type from access-line section per access configuration `ipcp` | Optionally enable/disable PPP IPCP per access configuration `ip6cp` | Optionally enable/disable PPP IP6CP per access configuration `ipv4` | Optionally enable/disable IPoE IPv4 per access configuration @@ -412,6 +413,7 @@ Attribute | Description | Default `agent-remote-id` | Agent-Remote-Id | DEU.RTBRICK.{session-global} `rate-up` | Actual-Data-Rate-Upstream | 0 `rate-down` | Actual-Data-Rate-Downstream | 0 +`dsl-type` | DSL-Type | 0 ## DHCP diff --git a/src/bbl.h b/src/bbl.h index b919ac89..e06af5c8 100644 --- a/src/bbl.h +++ b/src/bbl.h @@ -319,6 +319,7 @@ typedef struct bbl_access_config_ char *agent_circuit_id; uint32_t rate_up; uint32_t rate_down; + uint32_t dsl_type; /* Protocols */ bool ipcp_enable; @@ -470,11 +471,13 @@ typedef struct bbl_ctx_ char *agent_circuit_id; uint32_t rate_up; uint32_t rate_down; + uint32_t dsl_type; /* PPPoE */ uint32_t pppoe_session_time; uint16_t pppoe_discovery_timeout; uint16_t pppoe_discovery_retry; + uint8_t pppoe_vlan_priority; char *pppoe_service_name; bool pppoe_reconnect; bool pppoe_host_uniq; @@ -655,6 +658,7 @@ typedef struct bbl_session_ char *agent_remote_id; uint32_t rate_up; uint32_t rate_down; + uint32_t dsl_type; /* Ethernet */ uint8_t server_mac[ETH_ADDR_LEN]; diff --git a/src/bbl_config.c b/src/bbl_config.c index d4d69f10..2834242c 100644 --- a/src/bbl_config.c +++ b/src/bbl_config.c @@ -163,6 +163,13 @@ json_parse_access_interface (bbl_ctx_s *ctx, json_t *access_interface, bbl_acces access_config->rate_down = ctx->config.rate_down; } + value = json_object_get(access_interface, "dsl-type"); + if (value) { + access_config->dsl_type = json_number_value(value); + } else { + access_config->dsl_type = ctx->config.dsl_type; + } + value = json_object_get(access_interface, "ipcp"); if (json_is_boolean(value)) { access_config->ipcp_enable = json_boolean_value(value); @@ -540,6 +547,10 @@ json_parse_config (json_t *root, bbl_ctx_s *ctx) { if (json_is_number(value)) { ctx->config.rate_down = json_number_value(value); } + value = json_object_get(section, "dsl-type"); + if (json_is_number(value)) { + ctx->config.dsl_type = json_number_value(value); + } } /* Session Traffic Configuration */ diff --git a/src/bbl_protocols.c b/src/bbl_protocols.c index 4c816cc7..c8bd5ea6 100644 --- a/src/bbl_protocols.c +++ b/src/bbl_protocols.c @@ -1066,6 +1066,15 @@ encode_pppoe_discovery(uint8_t *buf, uint16_t *len, BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t)); vendor_len += 6; } + if(pppoe->access_line->down) { + *buf = ACCESS_LINE_DSL_TYPE; + BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t)); + *buf = 4; + BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t)); + *(uint32_t*)buf = htobe32(pppoe->access_line->dsl_type); + BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t)); + vendor_len += 6; + } *vendor_len_field = htobe16(vendor_len); pppoe_len += 4 + vendor_len; } diff --git a/src/bbl_protocols.h b/src/bbl_protocols.h index 5e218978..e934f058 100644 --- a/src/bbl_protocols.h +++ b/src/bbl_protocols.h @@ -332,10 +332,11 @@ typedef enum access_line_codes_ { } access_line_codes; typedef struct access_line_ { - char *aci; // Agent Circuit ID - char *ari; // Agent Remote ID - uint32_t up; // Actual Data Rate Upstream - uint32_t down; // Actual Data Rate Downstream + char *aci; // Agent Circuit ID + char *ari; // Agent Remote ID + uint32_t up; // Actual Data Rate Upstream + uint32_t down; // Actual Data Rate Downstream + uint32_t dsl_type; // DSL Type } access_line_t; /* diff --git a/src/bbl_session.c b/src/bbl_session.c index c659e517..a500adda 100644 --- a/src/bbl_session.c +++ b/src/bbl_session.c @@ -326,6 +326,7 @@ bbl_sessions_init(bbl_ctx_s *ctx) /* Update access rates ... */ session->rate_up = access_config->rate_up; session->rate_down = access_config->rate_down; + session->dsl_type = access_config->dsl_type; /* IGMP */ session->igmp_autostart = access_config->igmp_autostart; diff --git a/src/bbl_tx.c b/src/bbl_tx.c index 76e173a4..d8bb91aa 100644 --- a/src/bbl_tx.c +++ b/src/bbl_tx.c @@ -1018,6 +1018,7 @@ bbl_encode_padi (bbl_session_s *session) access_line.ari = session->agent_remote_id; access_line.up = session->rate_up; access_line.down = session->rate_down; + access_line.dsl_type = session->dsl_type; pppoe.access_line = &access_line; } return encode_ethernet(session->write_buf, &session->write_idx, ð); @@ -1053,6 +1054,7 @@ bbl_encode_padr (bbl_session_s *session) access_line.ari = session->agent_remote_id; access_line.up = session->rate_up; access_line.down = session->rate_down; + access_line.dsl_type = session->dsl_type; pppoe.access_line = &access_line; } return encode_ethernet(session->write_buf, &session->write_idx, ð);