mirror of
https://github.com/rtbrick/bngblaster.git
synced 2024-05-06 15:54:57 +00:00
add A10NSP DHCP server
This commit is contained in:
committed by
Christian Giese
parent
913864b711
commit
68ec24d5ce
@@ -20,6 +20,18 @@ bbl_a10nsp_session_free(bbl_session_s *session)
|
||||
if(session->a10nsp_session->pppoe_ari) {
|
||||
free(session->a10nsp_session->pppoe_ari);
|
||||
}
|
||||
if(session->a10nsp_session->dhcp_aci) {
|
||||
free(session->a10nsp_session->dhcp_aci);
|
||||
}
|
||||
if(session->a10nsp_session->dhcp_ari) {
|
||||
free(session->a10nsp_session->dhcp_ari);
|
||||
}
|
||||
if(session->a10nsp_session->dhcpv6_aci) {
|
||||
free(session->a10nsp_session->dhcpv6_aci);
|
||||
}
|
||||
if(session->a10nsp_session->dhcpv6_ari) {
|
||||
free(session->a10nsp_session->dhcpv6_ari);
|
||||
}
|
||||
free(session->a10nsp_session);
|
||||
session->a10nsp_session = NULL;
|
||||
}
|
||||
@@ -44,7 +56,6 @@ bbl_a10nsp_pppoed_handler(bbl_interface_s *interface,
|
||||
}
|
||||
pppoed->ac_cookie = ac_cookie;
|
||||
pppoed->ac_cookie_len = sizeof(ac_cookie);
|
||||
|
||||
if(pppoed->access_line) {
|
||||
if(pppoed->access_line->aci) {
|
||||
if(a10nsp_session->pppoe_aci) {
|
||||
@@ -161,13 +172,13 @@ bbl_a10nsp_ipcp_handler(bbl_interface_s *interface,
|
||||
ipcp->options = NULL;
|
||||
ipcp->options_len = 0;
|
||||
ipcp->code = PPP_CODE_CONF_NAK;
|
||||
ipcp->address = L2TP_IPCP_IP_REMOTE;
|
||||
ipcp->address = MOCK_IP_REMOTE;
|
||||
ipcp->option_address = true;
|
||||
if(ipcp->option_dns1) {
|
||||
ipcp->dns1 = L2TP_IPCP_DNS1;
|
||||
ipcp->dns1 = MOCK_DNS1;
|
||||
}
|
||||
if(ipcp->option_dns2) {
|
||||
ipcp->dns2 = L2TP_IPCP_DNS2;
|
||||
ipcp->dns2 = MOCK_DNS2;
|
||||
}
|
||||
}
|
||||
if(bbl_send_to_buffer(interface, eth) == BBL_SEND_OK) {
|
||||
@@ -175,7 +186,7 @@ bbl_a10nsp_ipcp_handler(bbl_interface_s *interface,
|
||||
}
|
||||
ipcp_request.code = PPP_CODE_CONF_REQUEST;
|
||||
ipcp_request.identifier = 1;
|
||||
ipcp_request.address = L2TP_IPCP_IP_LOCAL;
|
||||
ipcp_request.address = MOCK_IP_LOCAL;
|
||||
ipcp_request.option_address = true;
|
||||
pppoes->next = &ipcp_request;
|
||||
if(bbl_send_to_buffer(interface, eth) == BBL_SEND_OK) {
|
||||
@@ -231,21 +242,84 @@ bbl_a10nsp_ip6cp_handler(bbl_interface_s *interface,
|
||||
}
|
||||
|
||||
static void
|
||||
bbl_a10nsp_pppoes_handler(bbl_interface_s *interface,
|
||||
bbl_session_s *session,
|
||||
bbl_ethernet_header_t *eth)
|
||||
bbl_a10nsp_ipv4_stream_handler(bbl_interface_s *interface,
|
||||
bbl_session_s *session,
|
||||
bbl_ethernet_header_t *eth,
|
||||
bbl_ipv4_t *ipv4)
|
||||
{
|
||||
bbl_ctx_s *ctx = interface->ctx;
|
||||
bbl_pppoe_session_t *pppoes = (bbl_pppoe_session_t*)eth->next;
|
||||
|
||||
bbl_ipv4_t *ipv4;
|
||||
bbl_udp_t *udp;
|
||||
bbl_bbl_t *bbl;
|
||||
bbl_udp_t *udp = (bbl_udp_t*)ipv4->next;
|
||||
bbl_bbl_t *bbl = (bbl_bbl_t*)udp->next;
|
||||
|
||||
bbl_stream *stream;
|
||||
void **search = NULL;
|
||||
uint64_t loss;
|
||||
|
||||
search = dict_search(ctx->stream_flow_dict, &bbl->flow_id);
|
||||
if(search) {
|
||||
stream = *search;
|
||||
if(stream->rx_first_seq) {
|
||||
/* Stream already verified */
|
||||
if((stream->rx_last_seq +1) < bbl->flow_seq) {
|
||||
loss = bbl->flow_seq - (stream->rx_last_seq +1);
|
||||
stream->loss += loss;
|
||||
interface->stats.stream_loss += loss;
|
||||
LOG(LOSS, "LOSS flow: %lu seq: %lu last: %lu\n",
|
||||
bbl->flow_id, bbl->flow_seq, stream->rx_last_seq);
|
||||
}
|
||||
} else {
|
||||
/* Verify stream ... */
|
||||
stream->rx_len = eth->length;
|
||||
stream->rx_priority = ipv4->tos;
|
||||
stream->rx_outer_vlan_pbit = eth->vlan_outer_priority;
|
||||
stream->rx_inner_vlan_pbit = eth->vlan_inner_priority;
|
||||
stream->rx_first_seq = bbl->flow_seq;
|
||||
ctx->stats.stream_traffic_flows_verified++;
|
||||
if(ctx->stats.stream_traffic_flows_verified == ctx->stats.stream_traffic_flows) {
|
||||
LOG_NOARG(INFO, "ALL STREAM TRAFFIC FLOWS VERIFIED\n");
|
||||
}
|
||||
if(ctx->config.traffic_stop_verified) {
|
||||
stream->stop = true;
|
||||
}
|
||||
}
|
||||
stream->packets_rx++;
|
||||
stream->rx_last_seq = bbl->flow_seq;
|
||||
bbl_stream_delay(stream, ð->timestamp, &bbl->timestamp);
|
||||
} else {
|
||||
if(bbl->flow_id == session->access_ipv4_tx_flow_id) {
|
||||
interface->stats.session_ipv4_rx++;
|
||||
session->stats.network_ipv4_rx++;
|
||||
if(!session->network_ipv4_rx_first_seq) {
|
||||
session->network_ipv4_rx_first_seq = bbl->flow_seq;
|
||||
session->session_traffic_flows_verified++;
|
||||
ctx->stats.session_traffic_flows_verified++;
|
||||
if(ctx->stats.session_traffic_flows_verified == ctx->stats.session_traffic_flows) {
|
||||
LOG_NOARG(INFO, "ALL SESSION TRAFFIC FLOWS VERIFIED\n");
|
||||
}
|
||||
} else {
|
||||
if((session->network_ipv4_rx_last_seq +1) < bbl->flow_seq) {
|
||||
loss = bbl->flow_seq - (session->network_ipv4_rx_last_seq +1);
|
||||
session->stats.network_ipv4_loss += loss;
|
||||
interface->stats.session_ipv4_loss += loss;
|
||||
LOG(LOSS, "LOSS (ID: %u) flow: %lu seq: %lu last: %lu\n",
|
||||
session->session_id, bbl->flow_id, bbl->flow_seq, session->network_ipv4_rx_last_seq);
|
||||
}
|
||||
}
|
||||
session->network_ipv4_rx_last_seq = bbl->flow_seq;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
bbl_a10nsp_pppoes_handler(bbl_interface_s *interface,
|
||||
bbl_session_s *session,
|
||||
bbl_ethernet_header_t *eth)
|
||||
{
|
||||
bbl_pppoe_session_t *pppoes = (bbl_pppoe_session_t*)eth->next;
|
||||
|
||||
bbl_ipv4_t *ipv4;
|
||||
bbl_udp_t *udp;
|
||||
|
||||
switch(pppoes->protocol) {
|
||||
case PROTOCOL_LCP:
|
||||
bbl_a10nsp_lcp_handler(interface, session, eth);
|
||||
@@ -264,60 +338,7 @@ bbl_a10nsp_pppoes_handler(bbl_interface_s *interface,
|
||||
if(ipv4->protocol == PROTOCOL_IPV4_UDP) {
|
||||
udp = (bbl_udp_t*)ipv4->next;
|
||||
if(udp->protocol == UDP_PROTOCOL_BBL) {
|
||||
bbl = (bbl_bbl_t*)udp->next;
|
||||
search = dict_search(ctx->stream_flow_dict, &bbl->flow_id);
|
||||
if(search) {
|
||||
stream = *search;
|
||||
if(stream->rx_first_seq) {
|
||||
/* Stream already verified */
|
||||
if((stream->rx_last_seq +1) < bbl->flow_seq) {
|
||||
loss = bbl->flow_seq - (stream->rx_last_seq +1);
|
||||
stream->loss += loss;
|
||||
interface->stats.stream_loss += loss;
|
||||
LOG(LOSS, "LOSS flow: %lu seq: %lu last: %lu\n",
|
||||
bbl->flow_id, bbl->flow_seq, stream->rx_last_seq);
|
||||
}
|
||||
} else {
|
||||
/* Verify stream ... */
|
||||
stream->rx_len = eth->length;
|
||||
stream->rx_priority = ipv4->tos;
|
||||
stream->rx_outer_vlan_pbit = eth->vlan_outer_priority;
|
||||
stream->rx_inner_vlan_pbit = eth->vlan_inner_priority;
|
||||
stream->rx_first_seq = bbl->flow_seq;
|
||||
ctx->stats.stream_traffic_flows_verified++;
|
||||
if(ctx->stats.stream_traffic_flows_verified == ctx->stats.stream_traffic_flows) {
|
||||
LOG_NOARG(INFO, "ALL STREAM TRAFFIC FLOWS VERIFIED\n");
|
||||
}
|
||||
if(ctx->config.traffic_stop_verified) {
|
||||
stream->stop = true;
|
||||
}
|
||||
}
|
||||
stream->packets_rx++;
|
||||
stream->rx_last_seq = bbl->flow_seq;
|
||||
bbl_stream_delay(stream, ð->timestamp, &bbl->timestamp);
|
||||
} else {
|
||||
if(bbl->flow_id == session->access_ipv4_tx_flow_id) {
|
||||
interface->stats.session_ipv4_rx++;
|
||||
session->stats.network_ipv4_rx++;
|
||||
if(!session->network_ipv4_rx_first_seq) {
|
||||
session->network_ipv4_rx_first_seq = bbl->flow_seq;
|
||||
session->session_traffic_flows_verified++;
|
||||
ctx->stats.session_traffic_flows_verified++;
|
||||
if(ctx->stats.session_traffic_flows_verified == ctx->stats.session_traffic_flows) {
|
||||
LOG_NOARG(INFO, "ALL SESSION TRAFFIC FLOWS VERIFIED\n");
|
||||
}
|
||||
} else {
|
||||
if((session->network_ipv4_rx_last_seq +1) < bbl->flow_seq) {
|
||||
loss = bbl->flow_seq - (session->network_ipv4_rx_last_seq +1);
|
||||
session->stats.network_ipv4_loss += loss;
|
||||
interface->stats.session_ipv4_loss += loss;
|
||||
LOG(LOSS, "LOSS (ID: %u) flow: %lu seq: %lu last: %lu\n",
|
||||
session->session_id, bbl->flow_id, bbl->flow_seq, session->network_ipv4_rx_last_seq);
|
||||
}
|
||||
}
|
||||
session->network_ipv4_rx_last_seq = bbl->flow_seq;
|
||||
}
|
||||
}
|
||||
bbl_a10nsp_ipv4_stream_handler(interface, session, eth, ipv4);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -326,6 +347,110 @@ bbl_a10nsp_pppoes_handler(bbl_interface_s *interface,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
bbl_a10nsp_arp_handler(bbl_interface_s *interface,
|
||||
bbl_session_s *session,
|
||||
bbl_ethernet_header_t *eth)
|
||||
{
|
||||
bbl_arp_t *arp = (bbl_arp_t*)eth->next;
|
||||
uint32_t target_ip = arp->target_ip;
|
||||
|
||||
if(arp->code == ARP_REQUEST) {
|
||||
arp->code = ARP_REPLY;
|
||||
arp->target = arp->sender;
|
||||
arp->target_ip = arp->sender_ip;
|
||||
arp->sender = interface->mac;
|
||||
arp->sender_ip = target_ip;
|
||||
if(bbl_send_to_buffer(interface, eth) == BBL_SEND_OK) {
|
||||
session->a10nsp_session->stats.packets_tx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
bbl_a10nsp_dhcp_handler(bbl_interface_s *interface,
|
||||
bbl_session_s *session,
|
||||
bbl_ethernet_header_t *eth)
|
||||
{
|
||||
bbl_a10nsp_session_t *a10nsp_session = session->a10nsp_session;
|
||||
bbl_ipv4_t *ipv4 = (bbl_ipv4_t*)eth->next;
|
||||
bbl_udp_t *udp = (bbl_udp_t*)ipv4->next;
|
||||
bbl_dhcp_t *dhcp = (bbl_dhcp_t*)udp->next;
|
||||
switch(dhcp->type) {
|
||||
case DHCP_MESSAGE_DISCOVER:
|
||||
dhcp->type = DHCP_MESSAGE_OFFER;
|
||||
if(dhcp->access_line) {
|
||||
if(dhcp->access_line->aci) {
|
||||
if(a10nsp_session->dhcp_aci) {
|
||||
free(a10nsp_session->dhcp_aci);
|
||||
}
|
||||
a10nsp_session->dhcp_aci = strdup(dhcp->access_line->aci);
|
||||
}
|
||||
if(dhcp->access_line->ari) {
|
||||
if(a10nsp_session->dhcp_ari) {
|
||||
free(a10nsp_session->dhcp_ari);
|
||||
}
|
||||
a10nsp_session->dhcp_ari = strdup(dhcp->access_line->ari);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DHCP_MESSAGE_REQUEST:
|
||||
case DHCP_MESSAGE_RELEASE:
|
||||
dhcp->type = DHCP_MESSAGE_ACK;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
ipv4->src = MOCK_IP_LOCAL;
|
||||
ipv4->dst = IPV4_BROADCAST;
|
||||
udp->src = DHCP_UDP_SERVER;
|
||||
udp->dst = DHCP_UDP_CLIENT;
|
||||
dhcp->header->op = BOOTREPLY;
|
||||
dhcp->header->secs = 0;
|
||||
dhcp->header->hops = 0;
|
||||
dhcp->header->yiaddr = MOCK_IP_REMOTE;
|
||||
dhcp->header->siaddr = MOCK_IP_LOCAL;
|
||||
dhcp->parameter_request_list = false;
|
||||
dhcp->client_identifier = NULL;
|
||||
dhcp->access_line = NULL;
|
||||
dhcp->option_server_identifier = true;
|
||||
dhcp->server_identifier = MOCK_IP_LOCAL;
|
||||
dhcp->option_address = true;
|
||||
dhcp->address = MOCK_IP_REMOTE;
|
||||
dhcp->option_router = true;
|
||||
dhcp->router = MOCK_IP_LOCAL;
|
||||
dhcp->option_lease_time = true;
|
||||
dhcp->lease_time = 120;
|
||||
if(bbl_send_to_buffer(interface, eth) == BBL_SEND_OK) {
|
||||
a10nsp_session->stats.packets_tx++;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
bbl_a10nsp_ipv4_handler(bbl_interface_s *interface,
|
||||
bbl_session_s *session,
|
||||
bbl_ethernet_header_t *eth)
|
||||
{
|
||||
bbl_ipv4_t *ipv4 = (bbl_ipv4_t*)eth->next;
|
||||
bbl_udp_t *udp;
|
||||
|
||||
if(ipv4->offset & ~IPV4_DF) {
|
||||
/* Reassembling of fragmented IPv4 packets is currently not supported. */
|
||||
return;
|
||||
}
|
||||
|
||||
switch(ipv4->protocol) {
|
||||
case PROTOCOL_IPV4_UDP:
|
||||
udp = (bbl_udp_t*)ipv4->next;
|
||||
if (udp->protocol == UDP_PROTOCOL_DHCP) {
|
||||
bbl_a10nsp_dhcp_handler(interface, session, eth);
|
||||
} else if(udp->protocol == UDP_PROTOCOL_BBL) {
|
||||
bbl_a10nsp_ipv4_stream_handler(interface, session, eth, ipv4);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* bbl_a10nsp_rx
|
||||
*
|
||||
@@ -365,6 +490,12 @@ bbl_a10nsp_rx(bbl_interface_s *interface,
|
||||
case ETH_TYPE_PPPOE_SESSION:
|
||||
bbl_a10nsp_pppoes_handler(interface, session, eth);
|
||||
break;
|
||||
case ETH_TYPE_ARP:
|
||||
bbl_a10nsp_arp_handler(interface, session, eth);
|
||||
break;
|
||||
case ETH_TYPE_IPV4:
|
||||
bbl_a10nsp_ipv4_handler(interface, session, eth);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,10 @@ typedef struct bbl_a10nsp_session_
|
||||
|
||||
char *pppoe_ari;
|
||||
char *pppoe_aci;
|
||||
char *dhcp_ari;
|
||||
char *dhcp_aci;
|
||||
char *dhcpv6_ari;
|
||||
char *dhcpv6_aci;
|
||||
|
||||
struct {
|
||||
uint64_t packets_tx;
|
||||
|
||||
@@ -63,6 +63,12 @@
|
||||
#define BBL_LI_HASHTABLE_SIZE 32771 /* is a prime number */
|
||||
#define BBL_STREAM_FLOW_HASHTABLE_SIZE 128993 /* is a prime number */
|
||||
|
||||
/* Mock Addresses */
|
||||
#define MOCK_IP_LOCAL 168495882
|
||||
#define MOCK_IP_REMOTE 168430090
|
||||
#define MOCK_DNS1 168561674
|
||||
#define MOCK_DNS2 168627466
|
||||
|
||||
/* Access Interface Send Mask */
|
||||
#define BBL_SEND_DISCOVERY 0x00000001
|
||||
#define BBL_SEND_LCP_RESPONSE 0x00000002
|
||||
|
||||
@@ -955,7 +955,7 @@ bbl_l2tp_data_rx(bbl_ethernet_header_t *eth, bbl_l2tp_t *l2tp, bbl_interface_s *
|
||||
ipcp_rx = (bbl_ipcp_t*)l2tp->next;
|
||||
memset(&ipcp_tx, 0x0, sizeof(bbl_ipcp_t));
|
||||
if(ipcp_rx->code == PPP_CODE_CONF_REQUEST) {
|
||||
if(ipcp_rx->address == L2TP_IPCP_IP_REMOTE) {
|
||||
if(ipcp_rx->address == MOCK_IP_REMOTE) {
|
||||
ipcp_rx->code = PPP_CODE_CONF_ACK;
|
||||
if(l2tp_session->ipcp_state == BBL_PPP_LOCAL_ACK) {
|
||||
l2tp_session->ipcp_state = BBL_PPP_OPENED;
|
||||
@@ -963,7 +963,7 @@ bbl_l2tp_data_rx(bbl_ethernet_header_t *eth, bbl_l2tp_t *l2tp, bbl_interface_s *
|
||||
l2tp_session->ipcp_state = BBL_PPP_PEER_ACK;
|
||||
ipcp_tx.code = PPP_CODE_CONF_REQUEST;
|
||||
ipcp_tx.identifier = 1;
|
||||
ipcp_tx.address = L2TP_IPCP_IP_LOCAL;
|
||||
ipcp_tx.address = MOCK_IP_LOCAL;
|
||||
ipcp_tx.option_address = true;
|
||||
bbl_l2tp_send_data(l2tp_session, PROTOCOL_IPCP, &ipcp_tx);
|
||||
}
|
||||
@@ -971,13 +971,13 @@ bbl_l2tp_data_rx(bbl_ethernet_header_t *eth, bbl_l2tp_t *l2tp, bbl_interface_s *
|
||||
ipcp_rx->options = NULL;
|
||||
ipcp_rx->options_len = 0;
|
||||
ipcp_rx->code = PPP_CODE_CONF_NAK;
|
||||
ipcp_rx->address = L2TP_IPCP_IP_REMOTE;
|
||||
ipcp_rx->address = MOCK_IP_REMOTE;
|
||||
ipcp_rx->option_address = true;
|
||||
if(ipcp_rx->option_dns1) {
|
||||
ipcp_rx->dns1 = L2TP_IPCP_DNS1;
|
||||
ipcp_rx->dns1 = MOCK_DNS1;
|
||||
}
|
||||
if(ipcp_rx->option_dns2) {
|
||||
ipcp_rx->dns2 = L2TP_IPCP_DNS2;
|
||||
ipcp_rx->dns2 = MOCK_DNS2;
|
||||
}
|
||||
}
|
||||
bbl_l2tp_send_data(l2tp_session, PROTOCOL_IPCP, ipcp_rx);
|
||||
@@ -988,7 +988,7 @@ bbl_l2tp_data_rx(bbl_ethernet_header_t *eth, bbl_l2tp_t *l2tp, bbl_interface_s *
|
||||
l2tp_session->ipcp_state = BBL_PPP_LOCAL_ACK;
|
||||
ipcp_tx.code = PPP_CODE_CONF_REQUEST;
|
||||
ipcp_tx.identifier = 1;
|
||||
ipcp_tx.address = L2TP_IPCP_IP_LOCAL;
|
||||
ipcp_tx.address = MOCK_IP_LOCAL;
|
||||
ipcp_tx.option_address = true;
|
||||
bbl_l2tp_send_data(l2tp_session, PROTOCOL_IPCP, &ipcp_tx);
|
||||
}
|
||||
|
||||
@@ -14,11 +14,6 @@
|
||||
#define L2TP_MAX_PACKET_SIZE 1500
|
||||
#define L2TP_MAX_AVP_SIZE 1024
|
||||
|
||||
#define L2TP_IPCP_IP_LOCAL 168495882
|
||||
#define L2TP_IPCP_IP_REMOTE 168430090
|
||||
#define L2TP_IPCP_DNS1 168561674
|
||||
#define L2TP_IPCP_DNS2 168627466
|
||||
|
||||
#define L2TP_TX_WAIT_MS 10
|
||||
|
||||
#define L2TP_PROXY_AUTH_TYPE_PAP 3
|
||||
|
||||
@@ -313,7 +313,6 @@ encode_dhcp_access_line(uint8_t *buf, access_line_t *access_line) {
|
||||
*(uint32_t*)buf = htobe32(access_line->dsl_type);
|
||||
BUMP_WRITE_BUFFER(buf, &len, sizeof(uint32_t));
|
||||
}
|
||||
|
||||
if(len > 7) {
|
||||
*option_len = len-2;
|
||||
*data_len = len-7;
|
||||
@@ -401,7 +400,22 @@ encode_dhcp(uint8_t *buf, uint16_t *len,
|
||||
*(uint32_t*)buf = dhcp->address;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
}
|
||||
|
||||
if(dhcp->option_router) {
|
||||
*buf = DHCP_OPTION_ROUTER;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = dhcp->router;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
}
|
||||
if(dhcp->option_lease_time) {
|
||||
*buf = DHCP_OPTION_IP_ADDRESS_LEASE_TIME;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(dhcp->lease_time);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
}
|
||||
if(dhcp->access_line) {
|
||||
/* RFC3046 Relay Agent Information Option (82) */
|
||||
*buf = DHCP_OPTION_RELAY_AGENT_INFORMATION;
|
||||
@@ -1303,8 +1317,6 @@ encode_pppoe_discovery(uint8_t *buf, uint16_t *len,
|
||||
pppoe_len += pppoe->ac_cookie_len;
|
||||
}
|
||||
if(pppoe->access_line) {
|
||||
access_line_profile = pppoe->access_line->profile;
|
||||
|
||||
*(uint16_t*)buf = htobe16(PPPOE_TAG_VENDOR);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint16_t));
|
||||
vendor_len_field = (uint16_t*)buf;
|
||||
@@ -1332,306 +1344,297 @@ encode_pppoe_discovery(uint8_t *buf, uint16_t *len,
|
||||
BUMP_WRITE_BUFFER(buf, len, str_len);
|
||||
vendor_len += 2 + str_len;
|
||||
}
|
||||
if(pppoe->access_line->up || (access_line_profile && access_line_profile->act_up)) {
|
||||
if(pppoe->access_line->up) {
|
||||
*buf = ACCESS_LINE_ACT_UP;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
if(pppoe->access_line->up) {
|
||||
*(uint32_t*)buf = htobe32(pppoe->access_line->up);
|
||||
} else {
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->act_up);
|
||||
}
|
||||
*(uint32_t*)buf = htobe32(pppoe->access_line->up);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(pppoe->access_line->down || (access_line_profile && access_line_profile->act_down)) {
|
||||
if(pppoe->access_line->down) {
|
||||
*buf = ACCESS_LINE_ACT_DOWN;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
if(pppoe->access_line->down) {
|
||||
*(uint32_t*)buf = htobe32(pppoe->access_line->down);
|
||||
} else {
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->act_down);
|
||||
}
|
||||
*(uint32_t*)buf = htobe32(pppoe->access_line->down);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(pppoe->access_line->dsl_type || (access_line_profile && access_line_profile->dsl_type)) {
|
||||
if(pppoe->access_line->dsl_type) {
|
||||
*buf = ACCESS_LINE_DSL_TYPE;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
if(pppoe->access_line->dsl_type) {
|
||||
*(uint32_t*)buf = htobe32(pppoe->access_line->dsl_type);
|
||||
} else {
|
||||
*(uint32_t*)buf = htobe32(pppoe->access_line->dsl_type);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
access_line_profile = pppoe->access_line->profile;
|
||||
if(access_line_profile) {
|
||||
if(access_line_profile->min_up) {
|
||||
*buf = ACCESS_LINE_MIN_UP;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->min_up);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile->min_down) {
|
||||
*buf = ACCESS_LINE_MIN_DOWN;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->min_down);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile->att_up) {
|
||||
*buf = ACCESS_LINE_ATT_UP;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->att_up);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile->att_down) {
|
||||
*buf = ACCESS_LINE_ATT_DOWN;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->att_down);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile->max_up) {
|
||||
*buf = ACCESS_LINE_MAX_UP;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->max_up);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile->max_down) {
|
||||
*buf = ACCESS_LINE_MAX_DOWN;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->max_down);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile->min_up_low) {
|
||||
*buf = ACCESS_LINE_MIN_UP_LOW;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->min_up_low);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile->min_down_low) {
|
||||
*buf = ACCESS_LINE_MIN_DOWN_LOW;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->min_down_low);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile->max_interl_delay_up) {
|
||||
*buf = ACCESS_LINE_MAX_INTERL_DELAY_UP;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->max_interl_delay_up);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile->act_interl_delay_up) {
|
||||
*buf = ACCESS_LINE_ACT_INTERL_DELAY_UP;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->act_interl_delay_up);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile->max_interl_delay_down) {
|
||||
*buf = ACCESS_LINE_MAX_INTERL_DELAY_DOWN;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->max_interl_delay_down);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile->act_interl_delay_down) {
|
||||
*buf = ACCESS_LINE_ACT_INTERL_DELAY_DOWN;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->act_interl_delay_down);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile->data_link_encaps) {
|
||||
*buf = ACCESS_LINE_DATA_LINK_ENCAPS;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
/* (1)byte + (1)byte + (1)byte
|
||||
* data link encaps 1 encaps 2 */
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->data_link_encaps);
|
||||
*buf = 3;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 5;
|
||||
}
|
||||
if(access_line_profile->dsl_type) {
|
||||
*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(access_line_profile->dsl_type);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile->pon_type) {
|
||||
*buf = ACCESS_LINE_PON_TYPE;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->pon_type);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile->etr_up) {
|
||||
*buf = ACCESS_LINE_ETR_UP;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->etr_up);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile->etr_down) {
|
||||
*buf = ACCESS_LINE_ETR_DOWN;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->etr_down);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile->attetr_up) {
|
||||
*buf = ACCESS_LINE_ATTETR_UP;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->attetr_up);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile->attetr_down) {
|
||||
*buf = ACCESS_LINE_ATTETR_DOWN;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->attetr_down);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile->gdr_up) {
|
||||
*buf = ACCESS_LINE_GDR_UP;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->gdr_up);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile->gdr_down) {
|
||||
*buf = ACCESS_LINE_GDR_DOWN;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->gdr_down);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile->attgdr_up) {
|
||||
*buf = ACCESS_LINE_ATTGDR_UP;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->attgdr_up);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile->attgdr_down) {
|
||||
*buf = ACCESS_LINE_ATTGDR_DOWN;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->attgdr_down);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile->ont_onu_avg_down) {
|
||||
*buf = ACCESS_LINE_ONT_ONU_AVG_DOWN;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->ont_onu_avg_down);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile->ont_onu_peak_down) {
|
||||
*buf = ACCESS_LINE_ONT_ONU_PEAK_DOWN;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->ont_onu_peak_down);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile->ont_onu_max_up) {
|
||||
*buf = ACCESS_LINE_ONT_ONU_MAX_UP;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->ont_onu_max_up);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile->ont_onu_ass_up) {
|
||||
*buf = ACCESS_LINE_ONT_ONU_ASS_UP;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->ont_onu_ass_up);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile->pon_max_up) {
|
||||
*buf = ACCESS_LINE_PON_MAX_UP;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->pon_max_up);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile->pon_max_down) {
|
||||
*buf = ACCESS_LINE_PON_MAX_DOWN;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->pon_max_down);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->min_up) {
|
||||
*buf = ACCESS_LINE_MIN_UP;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->min_up);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->min_down) {
|
||||
*buf = ACCESS_LINE_MIN_DOWN;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->min_down);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->att_up) {
|
||||
*buf = ACCESS_LINE_ATT_UP;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->att_up);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->att_down) {
|
||||
*buf = ACCESS_LINE_ATT_DOWN;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->att_down);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->max_up) {
|
||||
*buf = ACCESS_LINE_MAX_UP;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->max_up);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->max_down) {
|
||||
*buf = ACCESS_LINE_MAX_DOWN;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->max_down);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->min_up_low) {
|
||||
*buf = ACCESS_LINE_MIN_UP_LOW;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->min_up_low);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->min_down_low) {
|
||||
*buf = ACCESS_LINE_MIN_DOWN_LOW;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->min_down_low);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->max_interl_delay_up) {
|
||||
*buf = ACCESS_LINE_MAX_INTERL_DELAY_UP;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->max_interl_delay_up);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->act_interl_delay_up) {
|
||||
*buf = ACCESS_LINE_ACT_INTERL_DELAY_UP;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->act_interl_delay_up);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->max_interl_delay_down) {
|
||||
*buf = ACCESS_LINE_MAX_INTERL_DELAY_DOWN;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->max_interl_delay_down);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->act_interl_delay_down) {
|
||||
*buf = ACCESS_LINE_ACT_INTERL_DELAY_DOWN;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->act_interl_delay_down);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->data_link_encaps) {
|
||||
*buf = ACCESS_LINE_DATA_LINK_ENCAPS;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
/* (1)byte + (1)byte + (1)byte
|
||||
* data link encaps 1 encaps 2 */
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->data_link_encaps);
|
||||
*buf = 3;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 5;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->dsl_type) {
|
||||
*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(access_line_profile->dsl_type);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->pon_type) {
|
||||
*buf = ACCESS_LINE_PON_TYPE;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->pon_type);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->etr_up) {
|
||||
*buf = ACCESS_LINE_ETR_UP;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->etr_up);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->etr_down) {
|
||||
*buf = ACCESS_LINE_ETR_DOWN;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->etr_down);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->attetr_up) {
|
||||
*buf = ACCESS_LINE_ATTETR_UP;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->attetr_up);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->attetr_down) {
|
||||
*buf = ACCESS_LINE_ATTETR_DOWN;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->attetr_down);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->gdr_up) {
|
||||
*buf = ACCESS_LINE_GDR_UP;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->gdr_up);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->gdr_down) {
|
||||
*buf = ACCESS_LINE_GDR_DOWN;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->gdr_down);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->attgdr_up) {
|
||||
*buf = ACCESS_LINE_ATTGDR_UP;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->attgdr_up);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->attgdr_down) {
|
||||
*buf = ACCESS_LINE_ATTGDR_DOWN;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->attgdr_down);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->ont_onu_avg_down) {
|
||||
*buf = ACCESS_LINE_ONT_ONU_AVG_DOWN;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->ont_onu_avg_down);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->ont_onu_peak_down) {
|
||||
*buf = ACCESS_LINE_ONT_ONU_PEAK_DOWN;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->ont_onu_peak_down);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->ont_onu_max_up) {
|
||||
*buf = ACCESS_LINE_ONT_ONU_MAX_UP;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->ont_onu_max_up);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->ont_onu_ass_up) {
|
||||
*buf = ACCESS_LINE_ONT_ONU_ASS_UP;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->ont_onu_ass_up);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->pon_max_up) {
|
||||
*buf = ACCESS_LINE_PON_MAX_UP;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->pon_max_up);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
if(access_line_profile && access_line_profile->pon_max_down) {
|
||||
*buf = ACCESS_LINE_PON_MAX_DOWN;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*buf = 4;
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint8_t));
|
||||
*(uint32_t*)buf = htobe32(access_line_profile->pon_max_down);
|
||||
BUMP_WRITE_BUFFER(buf, len, sizeof(uint32_t));
|
||||
vendor_len += 6;
|
||||
}
|
||||
*vendor_len_field = htobe16(vendor_len);
|
||||
pppoe_len += 4 + vendor_len;
|
||||
@@ -2284,6 +2287,59 @@ decode_dhcpv6(uint8_t *buf, uint16_t len,
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
static protocol_error_t
|
||||
decode_dhcp_agent(uint8_t *buf, uint16_t len,
|
||||
uint8_t *sp, uint16_t sp_len,
|
||||
bbl_dhcp_t *dhcp) {
|
||||
|
||||
access_line_t *access_line;
|
||||
|
||||
uint8_t tlv_type;
|
||||
uint8_t tlv_length;
|
||||
|
||||
if(dhcp->access_line) {
|
||||
access_line = dhcp->access_line;
|
||||
} else {
|
||||
access_line = (access_line_t*)sp;
|
||||
BUMP_BUFFER(sp, sp_len, sizeof(access_line_t));
|
||||
memset(access_line, 0x0, sizeof(access_line_t));
|
||||
dhcp->access_line = access_line;
|
||||
}
|
||||
|
||||
while(len > 2) {
|
||||
tlv_type = *buf;
|
||||
BUMP_BUFFER(buf, len, sizeof(uint8_t));
|
||||
tlv_length = *buf;
|
||||
BUMP_BUFFER(buf, len, sizeof(uint8_t));
|
||||
switch (tlv_type) {
|
||||
case ACCESS_LINE_ACI:
|
||||
if(sp_len > tlv_length) {
|
||||
access_line->aci = (void*)sp;
|
||||
memcpy(sp, buf, tlv_length);
|
||||
/* zero terminate string */
|
||||
sp += tlv_length; *sp = 0; sp++;
|
||||
} else {
|
||||
return DECODE_ERROR;
|
||||
}
|
||||
break;
|
||||
case ACCESS_LINE_ARI:
|
||||
if(sp_len > tlv_length) {
|
||||
access_line->ari = (void*)sp;
|
||||
memcpy(sp, buf, tlv_length);
|
||||
/* zero terminate string */
|
||||
sp += tlv_length; *sp = 0; sp++;
|
||||
} else {
|
||||
return DECODE_ERROR;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
BUMP_BUFFER(buf, len, tlv_length);
|
||||
}
|
||||
return PROTOCOL_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* decode_dhcp
|
||||
*/
|
||||
@@ -2392,6 +2448,11 @@ decode_dhcp(uint8_t *buf, uint16_t len,
|
||||
dhcp->mtu = be16toh(*(uint16_t*)buf);
|
||||
dhcp->option_mtu = true;
|
||||
break;
|
||||
case DHCP_OPTION_RELAY_AGENT_INFORMATION:
|
||||
if(decode_dhcp_agent(buf, option_len, sp, sp_len, dhcp) != PROTOCOL_SUCCESS) {
|
||||
return DECODE_ERROR;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -2537,6 +2598,7 @@ decode_udp(uint8_t *buf, uint16_t len,
|
||||
ret_val = decode_l2tp(buf, len, sp, sp_len, (bbl_l2tp_t**)&udp->next);
|
||||
break;
|
||||
case DHCP_UDP_CLIENT:
|
||||
case DHCP_UDP_SERVER:
|
||||
udp->protocol = UDP_PROTOCOL_DHCP;
|
||||
ret_val = decode_dhcp(buf, len, sp, sp_len, (bbl_dhcp_t**)&udp->next);
|
||||
break;
|
||||
@@ -3374,7 +3436,8 @@ decode_pppoe_vendor(uint8_t *buf, uint16_t len,
|
||||
return DECODE_ERROR;
|
||||
}
|
||||
|
||||
access_line = (access_line_t*)sp; BUMP_BUFFER(sp, sp_len, sizeof(access_line_t));
|
||||
access_line = (access_line_t*)sp;
|
||||
BUMP_BUFFER(sp, sp_len, sizeof(access_line_t));
|
||||
memset(access_line, 0x0, sizeof(access_line_t));
|
||||
pppoe->access_line = access_line;
|
||||
while(len > 2) {
|
||||
|
||||
@@ -713,6 +713,25 @@ bbl_sessions_init(bbl_ctx_s *ctx)
|
||||
session->rate_up = access_config->rate_up;
|
||||
session->rate_down = access_config->rate_down;
|
||||
session->dsl_type = access_config->dsl_type;
|
||||
if(access_config->access_line_profile_id) {
|
||||
access_line_profile = ctx->config.access_line_profile;
|
||||
while(access_line_profile) {
|
||||
if(access_line_profile->access_line_profile_id == access_config->access_line_profile_id) {
|
||||
session->access_line_profile = access_line_profile;
|
||||
if(session->rate_up == 0) {
|
||||
session->rate_up = access_line_profile->act_up;
|
||||
}
|
||||
if(session->rate_down == 0) {
|
||||
session->rate_down = access_line_profile->act_down;
|
||||
}
|
||||
if(session->dsl_type == 0) {
|
||||
session->dsl_type = access_line_profile->dsl_type;
|
||||
}
|
||||
break;
|
||||
}
|
||||
access_line_profile = access_line_profile->next;
|
||||
}
|
||||
}
|
||||
|
||||
/* IGMP */
|
||||
session->igmp_autostart = access_config->igmp_autostart;
|
||||
@@ -773,17 +792,6 @@ bbl_sessions_init(bbl_ctx_s *ctx)
|
||||
timer_add_periodic(&ctx->timer_root, &session->timer_rate, "Rate Computation", 1, 0, session, &bbl_session_rate_job);
|
||||
}
|
||||
|
||||
if(access_config->access_line_profile_id) {
|
||||
access_line_profile = ctx->config.access_line_profile;
|
||||
while(access_line_profile) {
|
||||
if(access_line_profile->access_line_profile_id == access_config->access_line_profile_id) {
|
||||
session->access_line_profile = access_line_profile;
|
||||
break;
|
||||
}
|
||||
access_line_profile = access_line_profile->next;
|
||||
}
|
||||
}
|
||||
|
||||
LOG(DEBUG, "Session %u created (%s.%u:%u)\n", i, access_config->interface, access_config->access_outer_vlan, access_config->access_inner_vlan);
|
||||
i++;
|
||||
NEXT:
|
||||
@@ -901,13 +909,17 @@ bbl_session_json(bbl_session_s *session)
|
||||
}
|
||||
|
||||
if(session->a10nsp_session) {
|
||||
a10nsp_session = json_pack("{ss si sb sb ss* ss* si si}",
|
||||
a10nsp_session = json_pack("{ss si sb sb ss* ss* ss* ss* ss* ss* si si}",
|
||||
"interface", session->a10nsp_session->a10nsp_if->name,
|
||||
"s-vlan", session->a10nsp_session->s_vlan,
|
||||
"qinq-send", session->a10nsp_session->a10nsp_if->qinq,
|
||||
"qinq-received", session->a10nsp_session->qinq_received,
|
||||
"pppoe-aci", session->a10nsp_session->pppoe_aci,
|
||||
"pppoe-ari", session->a10nsp_session->pppoe_ari,
|
||||
"dhcp-aci", session->a10nsp_session->dhcp_aci,
|
||||
"dhcp-ari", session->a10nsp_session->dhcp_ari,
|
||||
"dhcpv6-aci", session->a10nsp_session->dhcpv6_aci,
|
||||
"dhcpv6-ari", session->a10nsp_session->dhcpv6_ari,
|
||||
"tx-packets", session->a10nsp_session->stats.packets_tx,
|
||||
"rx-packets", session->a10nsp_session->stats.packets_rx);
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ bbl_session_traffic_add_ipv4(bbl_ctx_s *ctx, bbl_session_s *session)
|
||||
eth.next = &ip;
|
||||
}
|
||||
if(session->l2tp_session) {
|
||||
ip.dst = L2TP_IPCP_IP_LOCAL;
|
||||
ip.dst = MOCK_IP_LOCAL;
|
||||
} else if (session->a10nsp_session) {
|
||||
ip.dst = A10NSP_IP_LOCAL;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user