forked from ARMmbed/mbed-os
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added DHCPv6 vendor data generation for DNS queries
New library added for generating the vendor data in DHCPv6 Added support for storage of DNS queries in BBR
- Loading branch information
Mika
committed
Sep 2, 2020
1 parent
639f9db
commit 7fe0423
Showing
5 changed files
with
193 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (c) 2020, Arm Limited and affiliates. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "nsconfig.h" | ||
#include "ns_types.h" | ||
#include "ns_trace.h" | ||
#include <string.h> | ||
#include "common_functions.h" | ||
#include "libDHCPv6.h" | ||
#include "libDHCPv6_vendordata.h" | ||
|
||
|
||
|
||
/* DHCPv6 vendor options to distribute ARM vendor data*/ | ||
|
||
uint16_t net_dns_option_vendor_option_data_dns_query_length(char *domain) | ||
{ | ||
return 4 + 16 + strlen(domain) + 1; | ||
} | ||
|
||
uint8_t *net_dns_option_vendor_option_data_dns_query_write(uint8_t *ptr, uint8_t *address, char *domain) | ||
{ | ||
int domain_len = strlen(domain); | ||
int length = 16 + domain_len + 1; | ||
|
||
ptr = common_write_16_bit(ARM_DHCP_VENDOR_DATA_DNS_QUERY_RESULT, ptr); | ||
ptr = common_write_16_bit(length, ptr); | ||
memcpy(ptr, address, 16); | ||
ptr += 16; | ||
memcpy(ptr, domain, domain_len + 1); | ||
ptr += domain_len + 1; | ||
return ptr; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (c) 2020, Arm Limited and affiliates. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef LIBDHCPV6_VENDOR_DATA_H_ | ||
#define LIBDHCPV6_VENDOR_DATA_H_ | ||
|
||
|
||
/*ARM enterprise number used to identify ARM generated Vendor data options*/ | ||
#define ARM_ENTERPRISE_NUMBER 4128 | ||
|
||
/* ARM Defined vendor data option to distribute DNS query results through DHCP server | ||
* Format | ||
* | ||
* uint8_t address[16] | ||
* domain string nul terminated. | ||
* | ||
* multiple results must be in separated vendor option data fields | ||
* */ | ||
#define ARM_DHCP_VENDOR_DATA_DNS_QUERY_RESULT 297 | ||
|
||
/* DHCPv6 vendor options to distribute ARM vendor data*/ | ||
|
||
uint16_t net_dns_option_vendor_option_data_dns_query_length(char *domain); | ||
uint8_t *net_dns_option_vendor_option_data_dns_query_write(uint8_t *ptr, uint8_t *address, char *domain); | ||
|
||
|
||
|
||
#endif /* LIBDHCPV6_VENDOR_DATA_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters