Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial UTD baseline commit #3

Open
wants to merge 1 commit into
base: release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ wfan0 => [
```
Note: `associated` in TI WI-SUN FAN Contest implies that the TI Wi-SUN FAN Border Router has started.

### Using an external DHCPv6 Server ###

The embedded border router project can be configured to route DHCP traffic up through wfantund.
To actually handle this traffic, an example server is provided via Docker under the `external-servers` folder.
Refer to the readme there to see how to configure and start the containers.

### Checking if tun Interface is up. ###
When the stack is up, the TUN interface will be enabled. It can be verified by checking

Expand Down
17 changes: 17 additions & 0 deletions external-servers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Requirements
1. Docker Engine
2. Docker Compose

# How to Run DNSMasq as a DHCPv6 Server
0. Navigate to this folder
1. Build the docker image with `docker compose build`
2. Make sure wfantund is running and the interface and stack are up.
3. Start the container with `docker compose run --rm dnsmasq`
- This will start the server with a sane default configuration; it will listen on interface wfan0 and give addresses out between 2020:abcd::1,2020:abcd::ffff.
4. If you want to run with a non-standard configuration, pass your command line options in as desired. This will overwrite the default interface and address range.
- Start the container with `docker compose run --rm dnsmasq -i wfan1 --dhcp-range 2020:abcd::1,2020:abcd::10,64,336h` to only give out 10 different addresses on interface wfan1, for example
- Refer to https://thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html for more options related to dhcp-range if needed


# How to figure out which device has a given IPv6 lease
1. Since IPv6 addresses given out by Dnsmasq are not based on MAC address, it can be hard to tell just by looking at the IPv6 address which device it refers to. To do so, simply take a look at `/var/lib/misc/dnsmasq.leases` on the DHCPv6 Server to view the leases given to a given DUID. Find the IP address you're curious about, and then refer to the DUID. The DUID is based on the link local address, so the last 48 bits (check this caden) refer to the last 48 bits of the devices MAC address! https://datatracker.ietf.org/doc/html/rfc8415#section-11.4
10 changes: 10 additions & 0 deletions external-servers/dnsmasq/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This could be a lighter image, but for development use ubuntu 22.04
FROM ubuntu:22.04
Copy link
Author

@zub74 zub74 Oct 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that I haven't tested this specific image as we can't use Docker Hub images directly at TI, but this should work.

# Install some utilities
RUN sudo apt update && sudo apt install -y nano iproute2 curl systemctl
# Install dnsmasq
RUN sudo apt update && sudo apt install -y dnsmasq=2.86-1.1
# Start dnsmasq and don't use dns, only DHCP
ENTRYPOINT ["dnsmasq", "-d", "-C", "/dev/null", "-p", "0"]
# By default assume interface is wfan0 and assign any address from subnet::1 to subnet::ffff
CMD ["-i", "wfan0", "--dhcp-range", "2020:abcd::1,2020:abcd::ffff,64,336h"]
9 changes: 9 additions & 0 deletions external-servers/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
dnsmasq:
build: ./dnsmasq
privileged: true
environment:
- TERM=xterm-256color
volumes:
- ./test_packets:/test_packets
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This volume isn't required, but if you want to pass persistent data back and forth between dnsmasq for debugging you can

network_mode: host
16 changes: 1 addition & 15 deletions src/ncp-spinel/SpinelNCPInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6844,21 +6844,7 @@ SpinelNCPInstance::handle_ncp_spinel_value_is(spinel_prop_key_t key, const uint8
void
SpinelNCPInstance::handle_ncp_spinel_value_inserted(spinel_prop_key_t key, const uint8_t* value_data_ptr, spinel_size_t value_data_len)
{
if (key == SPINEL_PROP_IPV6_ADDRESS_TABLE) {
struct in6_addr *addr = NULL;
uint8_t prefix_len = 0;
uint32_t valid_lifetime = 0xFFFFFFFF;
uint32_t preferred_lifetime = 0xFFFFFFFF;

spinel_datatype_unpack(value_data_ptr, value_data_len, "6CLL", &addr, &prefix_len, &valid_lifetime, &preferred_lifetime);

if (addr != NULL) {
if (!should_filter_address(*addr, prefix_len)) {
unicast_address_was_added(kOriginThreadNCP, *addr, prefix_len, valid_lifetime, preferred_lifetime);
}
}

} else if (key == SPINEL_PROP_MAC_MAC_FILTER_LIST) {
if (key == SPINEL_PROP_MAC_MAC_FILTER_LIST) {
unsigned int *entry_ptr = NULL;
spinel_size_t entry_len = 0;
spinel_ssize_t len = 0;
Expand Down
11 changes: 10 additions & 1 deletion src/util/TunnelIPv6Interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,11 +600,20 @@ TunnelIPv6Interface::set_running(bool isRunning)
return ret;
}

in6_addr test_addr = {0};

int
TunnelIPv6Interface::set_online(bool online)
{
return set_running(online);
int status = set_running(online);
if (status == 0)
{
// kWPANTUNDProperty_IPv6WfantundGlobalAddress;
syslog(LOG_INFO, "Trying to add default Global IP address to %s. . .", mInterfaceName.c_str());
test_addr = {0x20,0x20,0xAB,0xCD, 0,0,0,0, 0,0,0,0, 0,0,0,0};
add_address(&test_addr, 64);
}
return status;
}

void
Expand Down
Loading