Starting to add a structure for the packet filters.

master
Pedro Alvarez 6 years ago committed by Andre Puschmann
parent f924a45421
commit a8eaf16881

@ -30,6 +30,7 @@
#include "srslte/interfaces/ue_interfaces.h" #include "srslte/interfaces/ue_interfaces.h"
#include "srslte/common/threads.h" #include "srslte/common/threads.h"
#include "gw_metrics.h" #include "gw_metrics.h"
#include "tft_packet_filter.h"
namespace srsue { namespace srsue {

@ -0,0 +1,82 @@
/*
* Copyright 2013-2019 Software Radio Systems Limited
*
* This file is part of srsLTE.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#ifndef SRSUE_PACKET_FILTER_H
#define SRSUE_PACKET_FILTER_H
#include "srslte/asn1/liblte_mme.h"
namespace srsue {
const uint16_t IPV4_REMOTE_ADDR_FLAG = 1;
const uint16_t IPV4_LOCAL_ADDR_FLAG = 1 << 1;
const uint16_t IPV6_REMOTE_ADDR_FLAG = 1 << 2;
const uint16_t IPV6_REMOTE_ADDR_LENGTH_FLAG = 1 << 3;
const uint16_t IPV6_LOCAL_ADDR_LENGTH_FLAG = 1 << 4;
const uint16_t PROTOCOL_ID_FLAG = 1 << 5;
const uint16_t SINGLE_LOCAL_PORT_FLAG = 1 << 6;
const uint16_t LOCAL_PORT_RANGE_FLAG = 1 << 7;
const uint16_t SINGLE_REMOTE_PORT_FLAG = 1 << 8;
const uint16_t REMOTE_PORT_RANGE_FLAG = 1 << 9;
const uint16_t SECURITY_PARAMETER_INDEX_FLAG = 1 << 10;
const uint16_t TYPE_OF_SERVICE_FLAG = 1 << 11;
const uint16_t FLOW_LABEL_FLAG = 1 << 12;
const uint8_t IPV4_REMOTE_ADDR_TYPE = 0b00010000;
const uint8_t IPV4_LOCAL_ADDR_TYPE = 0b00010001;
const uint8_t IPV6_REMOTE_ADDR_TYPE = 0b00100000;
const uint8_t IPV6_REMOTE_ADDR_LENGTH_TYPE = 0b00100001;
const uint8_t IPV6_LOCAL_ADDR_LENGTH_TYPE = 0b00100011;
const uint8_t PROTOCOL_ID_TYPE = 0b00110000;
const uint8_t SINGLE_LOCAL_PORT_TYPE = 0b01000000;
const uint8_t LOCAL_PORT_RANGE_TYPE = 0b01000001;
const uint8_t SINGLE_REMOTE_PORT_TYPE = 0b01010000;
const uint8_t REMOTE_PORT_RANGE_TYPE = 0b01010001;
const uint8_t SECURITY_PARAMETER_INDEX_TYPE = 0b01100000;
const uint8_t TYPE_OF_SERVICE_TYPE = 0b01110000;
const uint8_t FLOW_LABEL_TYPE = 0b10000000;
// TS 24.008 Table 10.5.162
struct tft_packet_filter_t {
uint8_t id;
uint8_t eval_precedence;
uint16_t active_filters;
uint32_t ipv4_remote_addr;
uint32_t ipv4_local_addr;
uint8_t ipv6_remote_addr[16];
uint8_t ipv6_remote_addr_length;
uint8_t ipv6_local_addr_length;
uint8_t protocol_id;
uint16_t single_local_port;
uint16_t local_port_range[2];
uint16_t single_remote_port;
uint16_t remote_port_range[2];
uint32_t security_parameter_index;
uint32_t type_of_service;
uint32_t flow_label;
tft_packet_filter_t(const LIBLTE_MME_PACKET_FILTER_STRUCT* tft);
};
} // namespace srsue
#endif // SRSUE_GW_METRICS_H

@ -0,0 +1,80 @@
/*
* Copyright 2013-2019 Software Radio Systems Limited
*
* This file is part of srsLTE.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#include "srsue/hdr/stack/upper/tft_packet_filter.h"
namespace srsue {
tft_packet_filter_t::tft_packet_filter_t(const LIBLTE_MME_PACKET_FILTER_STRUCT* tft) :
id(tft->id),
eval_precedence(tft->eval_precedence),
active_filters(0)
{
int idx = 0;
while (idx < tft->filter_size) {
switch (tft->filter[idx] & 0x0F) {
case IPV4_REMOTE_ADDR_TYPE:
active_filters = IPV4_REMOTE_ADDR_FLAG;
memcpy(&ipv4_remote_addr, &tft->filter[idx], 4);
idx += 4;
break;
case IPV4_LOCAL_ADDR_TYPE:
active_filters = IPV4_LOCAL_ADDR_FLAG;
memcpy(&ipv4_local_addr, &tft->filter[idx], 4);
idx += 4;
break;
case IPV6_REMOTE_ADDR_TYPE:
active_filters = IPV6_REMOTE_ADDR_FLAG;
memcpy(&ipv4_local_addr, &tft->filter[idx], 16);
idx += 16;
break;
case IPV6_REMOTE_ADDR_LENGTH_TYPE:
break;
case IPV6_LOCAL_ADDR_LENGTH_TYPE:
break;
case PROTOCOL_ID_TYPE:
break;
case SINGLE_LOCAL_PORT_TYPE:
active_filters = SINGLE_LOCAL_PORT_FLAG;
memcpy(&single_local_port, &tft->filter[idx], 2);
idx += 2;
break;
case LOCAL_PORT_RANGE_TYPE:
break;
case SINGLE_REMOTE_PORT_TYPE:
break;
case REMOTE_PORT_RANGE_TYPE:
break;
case SECURITY_PARAMETER_INDEX_TYPE:
break;
case TYPE_OF_SERVICE_TYPE:
break;
case FLOW_LABEL_TYPE:
break;
default:
return;
}
}
}
tft_packet_filter_t::~tft_packet_filter_t() {}
} // namespace srsue
Loading…
Cancel
Save