forked from acouzens/open5gs
IPv6 DNS is added
This commit is contained in:
parent
94c2c6ca7d
commit
634de8c788
|
@ -243,10 +243,12 @@ CORE_DECLARE(c_int16_t) apn_parse(c_int8_t *dst, c_int8_t *src, c_int16_t len);
|
|||
* RFC 1661 [102] */
|
||||
#define PCO_PPP_FOR_USE_WITH_IP_PDP_TYPE_OR_IP_PDN_TYPE 0
|
||||
|
||||
#define PCO_ID_INTERNET_PROTOCOL_CONTROL_PROTOCOL 0x8021
|
||||
#define PCO_ID_CHALLENGE_HANDSHAKE_AUTHENTICATION_PROTOCOL 0xc223
|
||||
#define PCO_ID_DNS_SERVER_IPV4_ADDRESS_REQUEST 0x000d
|
||||
#define PCO_ID_IP_ADDRESS_ALLOCATION_VIA_NAS_SIGNALLING 0x000a
|
||||
#define PCO_ID_INTERNET_PROTOCOL_CONTROL_PROTOCOL 0x8021
|
||||
#define PCO_ID_CHALLENGE_HANDSHAKE_AUTHENTICATION_PROTOCOL 0xc223
|
||||
#define PCO_ID_DNS_SERVER_IPV6_ADDRESS_REQUEST 0x0003
|
||||
#define PCO_ID_DNS_SERVER_IPV4_ADDRESS_REQUEST 0x000d
|
||||
#define PCO_ID_IP_ADDRESS_ALLOCATION_VIA_NAS_SIGNALLING 0x000a
|
||||
#define PCO_ID_IPV4_LINK_MTU_REQUEST 0x0010
|
||||
typedef struct _pco_ipcp_options_t {
|
||||
c_uint8_t type;
|
||||
c_uint8_t len;
|
||||
|
|
|
@ -159,7 +159,7 @@ static status_t pgw_context_validation()
|
|||
context_self()->config.path);
|
||||
return CORE_ERROR;
|
||||
}
|
||||
if (self.dns.primary == 0)
|
||||
if (self.dns[0] == NULL && self.dns6[0] == NULL)
|
||||
{
|
||||
d_error("No pgw.dns in '%s'",
|
||||
context_self()->config.path);
|
||||
|
@ -592,16 +592,26 @@ status_t pgw_context_parse_config()
|
|||
v = yaml_iter_value(&dns_iter);
|
||||
if (v)
|
||||
{
|
||||
if (count == 0)
|
||||
ipsubnet_t ipsub;
|
||||
rv = core_ipsubnet(&ipsub, v, NULL);
|
||||
d_assert(rv == CORE_OK, return CORE_ERROR,);
|
||||
|
||||
if (ipsub.family == AF_INET)
|
||||
{
|
||||
self.dns.primary = inet_addr(v);
|
||||
if (self.dns[0] && self.dns[1])
|
||||
d_warn("Ignore DNS : %s", v);
|
||||
else if (self.dns[0]) self.dns[1] = v;
|
||||
else self.dns[0] = v;
|
||||
}
|
||||
else if (count == 1)
|
||||
else if (ipsub.family == AF_INET6)
|
||||
{
|
||||
self.dns.secondary = inet_addr(v);
|
||||
if (self.dns6[0] && self.dns6[1])
|
||||
d_warn("Ignore DNS : %s", v);
|
||||
else if (self.dns6[0]) self.dns6[1] = v;
|
||||
else self.dns6[0] = v;
|
||||
}
|
||||
else
|
||||
d_warn("Ignored %d DNS(%s)", count, v);
|
||||
d_warn("Ignore DNS : %s", v);
|
||||
}
|
||||
|
||||
count++;
|
||||
|
@ -609,43 +619,6 @@ status_t pgw_context_parse_config()
|
|||
yaml_iter_type(&dns_iter) ==
|
||||
YAML_SEQUENCE_NODE);
|
||||
}
|
||||
else if (!strcmp(pgw_key, "dns6"))
|
||||
{
|
||||
int count = 0;
|
||||
yaml_iter_t dns6_iter;
|
||||
yaml_iter_recurse(&pgw_iter, &dns6_iter);
|
||||
d_assert(yaml_iter_type(&dns6_iter) !=
|
||||
YAML_MAPPING_NODE, return CORE_ERROR,);
|
||||
|
||||
do
|
||||
{
|
||||
const char *v = NULL;
|
||||
|
||||
if (yaml_iter_type(&dns6_iter) ==
|
||||
YAML_SEQUENCE_NODE)
|
||||
{
|
||||
if (!yaml_iter_next(&dns6_iter))
|
||||
break;
|
||||
}
|
||||
|
||||
v = yaml_iter_value(&dns6_iter);
|
||||
if (v)
|
||||
{
|
||||
if (count == 0)
|
||||
{
|
||||
}
|
||||
else if (count == 1)
|
||||
{
|
||||
}
|
||||
else
|
||||
d_warn("Ignored %d DNS(%s)", count, v);
|
||||
}
|
||||
|
||||
count++;
|
||||
} while(
|
||||
yaml_iter_type(&dns6_iter) ==
|
||||
YAML_SEQUENCE_NODE);
|
||||
}
|
||||
else
|
||||
d_warn("unknown key `%s`", pgw_key);
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
#include "gtp_types.h"
|
||||
#include "gtp_message.h"
|
||||
|
||||
#define MAX_NUM_OF_UE_POOL 16
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
@ -41,6 +39,7 @@ typedef struct _pgw_context_t {
|
|||
|
||||
sock_id tun_sock; /* PGW Tun Interace for UE */
|
||||
const char *tun_ifname; /* default : pgwtun */
|
||||
#define MAX_NUM_OF_UE_POOL 16
|
||||
struct {
|
||||
const char *ipstr; /* IP : "172.16.0.1", "cafe::1", ... */
|
||||
const char *mask_or_numbits; /* MASK : "16, 64, ... */
|
||||
|
@ -52,7 +51,11 @@ typedef struct _pgw_context_t {
|
|||
struct {
|
||||
c_uint32_t primary;
|
||||
c_uint32_t secondary;
|
||||
} dns;
|
||||
} old_dns;
|
||||
|
||||
#define MAX_NUM_OF_DNS 2
|
||||
const char *dns[2]; /* Primary/Secondanry */
|
||||
const char *dns6[2]; /* Primary/Secondanry */
|
||||
|
||||
list_t sgw_s5c_list; /* SGW GTPC Node List */
|
||||
list_t sgw_s5u_list; /* SGW GTPU Node List */
|
||||
|
|
|
@ -325,8 +325,10 @@ status_t pgw_s5c_build_create_bearer_request(
|
|||
|
||||
static c_int16_t pgw_pco_build(c_uint8_t *pco_buf, tlv_pco_t *tlv_pco)
|
||||
{
|
||||
status_t rv;
|
||||
pco_t ue, pgw;
|
||||
pco_ipcp_t pco_ipcp;
|
||||
ipsubnet_t dns_primary, dns_secondary, dns6_primary, dns6_secondary;
|
||||
c_int8_t size = 0;
|
||||
int i = 0;
|
||||
|
||||
|
@ -368,14 +370,26 @@ static c_int16_t pgw_pco_build(c_uint8_t *pco_buf, tlv_pco_t *tlv_pco)
|
|||
pco_ipcp.len = htons(len);
|
||||
|
||||
/* Primary DNS Server IP Address */
|
||||
pco_ipcp.options[0].type = 129;
|
||||
pco_ipcp.options[0].len = 6;
|
||||
pco_ipcp.options[0].addr = pgw_self()->dns.primary;
|
||||
if (pgw_self()->dns[0])
|
||||
{
|
||||
rv = core_ipsubnet(
|
||||
&dns_primary, pgw_self()->dns[0], NULL);
|
||||
d_assert(rv == CORE_OK, return CORE_ERROR,);
|
||||
pco_ipcp.options[0].type = 129;
|
||||
pco_ipcp.options[0].len = 6;
|
||||
pco_ipcp.options[0].addr = dns_primary.sub[0];
|
||||
}
|
||||
|
||||
/* Secondary DNS Server IP Address */
|
||||
pco_ipcp.options[1].type = 131;
|
||||
pco_ipcp.options[1].len = 6;
|
||||
pco_ipcp.options[1].addr = pgw_self()->dns.secondary;
|
||||
if (pgw_self()->dns[1])
|
||||
{
|
||||
rv = core_ipsubnet(
|
||||
&dns_secondary, pgw_self()->dns[1], NULL);
|
||||
d_assert(rv == CORE_OK, return CORE_ERROR,);
|
||||
pco_ipcp.options[1].type = 131;
|
||||
pco_ipcp.options[1].len = 6;
|
||||
pco_ipcp.options[1].addr = dns_secondary.sub[0];
|
||||
}
|
||||
|
||||
pgw.ids[pgw.num_of_id].id = ue.ids[i].id;
|
||||
pgw.ids[pgw.num_of_id].len = len;
|
||||
|
@ -387,19 +401,59 @@ static c_int16_t pgw_pco_build(c_uint8_t *pco_buf, tlv_pco_t *tlv_pco)
|
|||
}
|
||||
case PCO_ID_DNS_SERVER_IPV4_ADDRESS_REQUEST:
|
||||
{
|
||||
pgw.ids[pgw.num_of_id].id = ue.ids[i].id;
|
||||
pgw.ids[pgw.num_of_id].len = 4;
|
||||
pgw.ids[pgw.num_of_id].data = &pgw_self()->dns.primary;
|
||||
pgw.num_of_id++;
|
||||
if (pgw_self()->dns[0])
|
||||
{
|
||||
rv = core_ipsubnet(
|
||||
&dns_primary, pgw_self()->dns[0], NULL);
|
||||
d_assert(rv == CORE_OK, return CORE_ERROR,);
|
||||
pgw.ids[pgw.num_of_id].id = ue.ids[i].id;
|
||||
pgw.ids[pgw.num_of_id].len = IPV4_LEN;
|
||||
pgw.ids[pgw.num_of_id].data = dns_primary.sub;
|
||||
pgw.num_of_id++;
|
||||
}
|
||||
|
||||
pgw.ids[pgw.num_of_id].id = ue.ids[i].id;
|
||||
pgw.ids[pgw.num_of_id].len = 4;
|
||||
pgw.ids[pgw.num_of_id].data = &pgw_self()->dns.secondary;
|
||||
if (pgw_self()->dns[1])
|
||||
{
|
||||
rv = core_ipsubnet(
|
||||
&dns_secondary, pgw_self()->dns[1], NULL);
|
||||
d_assert(rv == CORE_OK, return CORE_ERROR,);
|
||||
pgw.ids[pgw.num_of_id].id = ue.ids[i].id;
|
||||
pgw.ids[pgw.num_of_id].len = IPV4_LEN;
|
||||
pgw.ids[pgw.num_of_id].data = dns_secondary.sub;
|
||||
pgw.num_of_id++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PCO_ID_DNS_SERVER_IPV6_ADDRESS_REQUEST:
|
||||
{
|
||||
if (pgw_self()->dns6[0])
|
||||
{
|
||||
rv = core_ipsubnet(
|
||||
&dns6_primary, pgw_self()->dns6[0], NULL);
|
||||
d_assert(rv == CORE_OK, return CORE_ERROR,);
|
||||
pgw.ids[pgw.num_of_id].id = ue.ids[i].id;
|
||||
pgw.ids[pgw.num_of_id].len = IPV6_LEN;
|
||||
pgw.ids[pgw.num_of_id].data = dns6_primary.sub;
|
||||
pgw.num_of_id++;
|
||||
}
|
||||
|
||||
pgw.num_of_id++;
|
||||
if (pgw_self()->dns6[1])
|
||||
{
|
||||
rv = core_ipsubnet(
|
||||
&dns6_secondary, pgw_self()->dns6[1], NULL);
|
||||
d_assert(rv == CORE_OK, return CORE_ERROR,);
|
||||
pgw.ids[pgw.num_of_id].id = ue.ids[i].id;
|
||||
pgw.ids[pgw.num_of_id].len = IPV6_LEN;
|
||||
pgw.ids[pgw.num_of_id].data = dns6_secondary.sub;
|
||||
pgw.num_of_id++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PCO_ID_IP_ADDRESS_ALLOCATION_VIA_NAS_SIGNALLING:
|
||||
/* TODO */
|
||||
break;
|
||||
case PCO_ID_IPV4_LINK_MTU_REQUEST:
|
||||
/* TODO */
|
||||
break;
|
||||
default:
|
||||
d_warn("Unknown PCO ID:(0x%x)", ue.ids[i].id);
|
||||
|
|
|
@ -332,7 +332,6 @@ pgw:
|
|||
dns:
|
||||
- 8.8.8.8
|
||||
- 8.8.4.4
|
||||
dns6:
|
||||
- 2001:4860:4860::8888
|
||||
- 2001:4860:4860::8844
|
||||
|
||||
|
|
Loading…
Reference in New Issue