mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-09-28 23:00:50 +00:00
Compare commits
17 Commits
9ce7634fb7
...
877996a985
Author | SHA1 | Date | |
---|---|---|---|
|
877996a985 | ||
|
d0efd9ef7b | ||
|
e799c266fa | ||
|
cb511019b0 | ||
|
9004e7bd77 | ||
|
17b1f5d382 | ||
|
10dc9b7eb3 | ||
|
c3d6fe9d72 | ||
|
93821fc437 | ||
|
7c494b3829 | ||
|
e1b8080346 | ||
|
655c6b1e37 | ||
|
8ab9287b02 | ||
|
7f69504bd3 | ||
|
b633639621 | ||
|
5571762829 | ||
|
3de157e211 |
2
.github/workflows/ci-linux.yml
vendored
2
.github/workflows/ci-linux.yml
vendored
@ -3,6 +3,8 @@ name: CI
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
branches: [master]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
6
.github/workflows/codeql-buildscript.sh
vendored
Normal file
6
.github/workflows/codeql-buildscript.sh
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
sudo apt-get install check ninja-build doxygen
|
||||
cp contrib/examples/example_app/lwipcfg.h.ci contrib/examples/example_app/lwipcfg.h
|
||||
make -C contrib/ports/unix/check
|
||||
mkdir build && cd build && cmake .. -G Ninja && cmake --build .
|
126
.github/workflows/codeql.yml
vendored
Normal file
126
.github/workflows/codeql.yml
vendored
Normal file
@ -0,0 +1,126 @@
|
||||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
# push:
|
||||
# branches: [ "main", "master" ]
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
pull_request:
|
||||
branches: '*'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
# Runner size impacts CodeQL analysis time. To learn more, please see:
|
||||
# - https://gh.io/recommended-hardware-resources-for-running-codeql
|
||||
# - https://gh.io/supported-runners-and-hardware-resources
|
||||
# - https://gh.io/using-larger-runners
|
||||
# Consider using larger runners for possible analysis time improvements.
|
||||
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-20.04' }}
|
||||
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'cpp' ]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
|
||||
# Use only 'java' to analyze code written in Java, Kotlin or both
|
||||
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
|
||||
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
|
||||
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
|
||||
# queries: security-extended,security-and-quality
|
||||
queries: security-and-quality
|
||||
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
#- name: Autobuild
|
||||
# uses: github/codeql-action/autobuild@v2
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
||||
|
||||
# If the Autobuild fails above, remove it and uncomment the following three lines.
|
||||
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
|
||||
|
||||
- run: |
|
||||
./.github/workflows/codeql-buildscript.sh
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
with:
|
||||
category: "/language:${{matrix.language}}"
|
||||
upload: false
|
||||
id: step1
|
||||
|
||||
# Filter out rules with low severity or high false positve rate
|
||||
# Also filter out warnings in third-party code
|
||||
- name: Filter out unwanted errors and warnings
|
||||
uses: advanced-security/filter-sarif@v1
|
||||
with:
|
||||
patterns: |
|
||||
-**:cpp/path-injection
|
||||
-**:cpp/world-writable-file-creation
|
||||
-**:cpp/poorly-documented-function
|
||||
-**:cpp/potentially-dangerous-function
|
||||
-**:cpp/use-of-goto
|
||||
-**:cpp/integer-multiplication-cast-to-long
|
||||
-**:cpp/comparison-with-wider-type
|
||||
-**:cpp/leap-year/*
|
||||
-**:cpp/ambiguously-signed-bit-field
|
||||
-**:cpp/suspicious-pointer-scaling
|
||||
-**:cpp/suspicious-pointer-scaling-void
|
||||
-**:cpp/unsigned-comparison-zero
|
||||
-**/cmake*/Modules/**
|
||||
input: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
|
||||
output: ${{ steps.step1.outputs.sarif-output }}/cpp.sarif
|
||||
|
||||
- name: Upload CodeQL results to code scanning
|
||||
uses: github/codeql-action/upload-sarif@v2
|
||||
with:
|
||||
sarif_file: ${{ steps.step1.outputs.sarif-output }}
|
||||
category: "/language:${{matrix.language}}"
|
||||
|
||||
- name: Upload CodeQL results as an artifact
|
||||
if: success() || failure()
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: codeql-results
|
||||
path: ${{ steps.step1.outputs.sarif-output }}
|
||||
retention-days: 5
|
||||
|
||||
- name: Fail if an error is found
|
||||
run: |
|
||||
./.github/workflows/fail_on_error.py \
|
||||
${{ steps.step1.outputs.sarif-output }}/cpp.sarif
|
34
.github/workflows/fail_on_error.py
vendored
Executable file
34
.github/workflows/fail_on_error.py
vendored
Executable file
@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import json
|
||||
import sys
|
||||
|
||||
# Return whether SARIF file contains error-level results
|
||||
def codeql_sarif_contain_error(filename):
|
||||
with open(filename, 'r') as f:
|
||||
s = json.load(f)
|
||||
|
||||
for run in s.get('runs', []):
|
||||
rules_metadata = run['tool']['driver']['rules']
|
||||
if not rules_metadata:
|
||||
rules_metadata = run['tool']['extensions'][0]['rules']
|
||||
|
||||
for res in run.get('results', []):
|
||||
if 'ruleIndex' in res:
|
||||
rule_index = res['ruleIndex']
|
||||
elif 'rule' in res and 'index' in res['rule']:
|
||||
rule_index = res['rule']['index']
|
||||
else:
|
||||
continue
|
||||
try:
|
||||
rule_level = rules_metadata[rule_index]['defaultConfiguration']['level']
|
||||
except IndexError as e:
|
||||
print(e, rule_index, len(rules_metadata))
|
||||
else:
|
||||
if rule_level == 'error':
|
||||
return True
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
if codeql_sarif_contain_error(sys.argv[1]):
|
||||
sys.exit(1)
|
@ -52,6 +52,10 @@
|
||||
#define LWIP_TIMEVAL_PRIVATE 0
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define LWIP_ERRNO_INCLUDE <errno.h>
|
||||
|
||||
#if defined(LWIP_UNIX_LINUX) || defined(LWIP_UNIX_HURD) || defined(LWIP_UNIX_KFREEBSD)
|
||||
@ -86,4 +90,8 @@ typedef struct sio_status_s sio_status_t;
|
||||
|
||||
typedef unsigned int sys_prot_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_ARCH_CC_H */
|
||||
|
@ -34,6 +34,10 @@
|
||||
|
||||
#include <sys/times.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef PERF
|
||||
#define PERF_START { \
|
||||
unsigned long __c1l, __c1h, __c2l, __c2h; \
|
||||
@ -60,4 +64,8 @@ void perf_print_times(struct tms *start, struct tms *end, char *key);
|
||||
|
||||
void perf_init(char *fname);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_ARCH_PERF_H */
|
||||
|
@ -32,6 +32,10 @@
|
||||
#ifndef LWIP_ARCH_SYS_ARCH_H
|
||||
#define LWIP_ARCH_SYS_ARCH_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SYS_MBOX_NULL NULL
|
||||
#define SYS_SEM_NULL NULL
|
||||
|
||||
@ -87,4 +91,8 @@ void sys_unlock_tcpip_core(void);
|
||||
#define UNLOCK_TCPIP_CORE() sys_unlock_tcpip_core()
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_ARCH_SYS_ARCH_H */
|
||||
|
@ -3,6 +3,10 @@
|
||||
|
||||
#include "lwip/sys.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** How many bytes in fifo */
|
||||
#define FIFOSIZE 2048
|
||||
|
||||
@ -50,5 +54,9 @@ void fifoPut(fifo_t * fifo, int fd);
|
||||
*/
|
||||
void fifoInit(fifo_t * fifo);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -2,6 +2,10 @@
|
||||
#ifndef LWIP_LIST_H
|
||||
#define LWIP_LIST_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct elem;
|
||||
|
||||
struct list {
|
||||
@ -23,4 +27,8 @@ void list_delete(struct list *list);
|
||||
int list_remove(struct list *list, void *elem);
|
||||
void list_map(struct list *list, void (* func)(void *arg));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -34,6 +34,14 @@
|
||||
|
||||
#include "lwip/netif.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
err_t pcapif_init(struct netif *netif);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_PCAPIF_H */
|
||||
|
@ -6,6 +6,10 @@
|
||||
#include "netif/fifo.h"
|
||||
/*#include "netif/pppif.h"*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct sio_status_s {
|
||||
int fd;
|
||||
fifo_t myfifo;
|
||||
@ -56,5 +60,9 @@ void sio_flush( sio_status_t * siostat );
|
||||
*/
|
||||
void sio_change_baud( sioBaudrates baud, sio_status_t * siostat );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -34,10 +34,18 @@
|
||||
|
||||
#include "lwip/netif.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
err_t tapif_init(struct netif *netif);
|
||||
void tapif_poll(struct netif *netif);
|
||||
#if NO_SYS
|
||||
int tapif_select(struct netif *netif);
|
||||
#endif /* NO_SYS */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_TAPIF_H */
|
||||
|
@ -34,10 +34,18 @@
|
||||
|
||||
#include "lwip/netif.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
err_t vdeif_init(struct netif *netif);
|
||||
void vdeif_poll(struct netif *netif);
|
||||
#if NO_SYS
|
||||
int vdeif_select(struct netif *netif);
|
||||
#endif /* NO_SYS */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_VDEIF_H */
|
||||
|
@ -40,6 +40,7 @@
|
||||
#if LWIP_DNS && LWIP_SOCKET
|
||||
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/errno.h"
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/memp.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
@ -382,7 +383,9 @@ lwip_getaddrinfo(const char *nodename, const char *servname,
|
||||
/* set up sockaddr */
|
||||
inet6_addr_from_ip6addr(&sa6->sin6_addr, ip_2_ip6(&addr));
|
||||
sa6->sin6_family = AF_INET6;
|
||||
#if LWIP_SOCKET_HAVE_SA_LEN
|
||||
sa6->sin6_len = sizeof(struct sockaddr_in6);
|
||||
#endif /* LWIP_SOCKET_HAVE_SA_LEN */
|
||||
sa6->sin6_port = lwip_htons((u16_t)port_nr);
|
||||
sa6->sin6_scope_id = ip6_addr_zone(ip_2_ip6(&addr));
|
||||
ai->ai_family = AF_INET6;
|
||||
@ -393,7 +396,9 @@ lwip_getaddrinfo(const char *nodename, const char *servname,
|
||||
/* set up sockaddr */
|
||||
inet_addr_from_ip4addr(&sa4->sin_addr, ip_2_ip4(&addr));
|
||||
sa4->sin_family = AF_INET;
|
||||
#if LWIP_SOCKET_HAVE_SA_LEN
|
||||
sa4->sin_len = sizeof(struct sockaddr_in);
|
||||
#endif /* LWIP_SOCKET_HAVE_SA_LEN */
|
||||
sa4->sin_port = lwip_htons((u16_t)port_nr);
|
||||
ai->ai_family = AF_INET;
|
||||
#endif /* LWIP_IPV4 */
|
||||
|
@ -68,11 +68,20 @@ sys_mutex_t lock_tcpip_core;
|
||||
static void tcpip_thread_handle_msg(struct tcpip_msg *msg);
|
||||
|
||||
#if !LWIP_TIMERS
|
||||
/* wait for a message with timers disabled (e.g. pass a timer-check trigger into tcpip_thread) */
|
||||
#define TCPIP_MBOX_FETCH(mbox, msg) sys_mbox_fetch(mbox, msg)
|
||||
|
||||
/** Wait for a message with timers disabled (e.g. pass a timer-check trigger into tcpip_thread) */
|
||||
static void
|
||||
tcpip_mbox_fetch(sys_mbox_t* mbox, void** msg)
|
||||
{
|
||||
LWIP_ASSERT_CORE_LOCKED();
|
||||
|
||||
UNLOCK_TCPIP_CORE();
|
||||
sys_mbox_fetch(mbox, msg);
|
||||
LOCK_TCPIP_CORE();
|
||||
}
|
||||
|
||||
#else /* !LWIP_TIMERS */
|
||||
/* wait for a message, timeouts are processed while waiting */
|
||||
#define TCPIP_MBOX_FETCH(mbox, msg) tcpip_timeouts_mbox_fetch(mbox, msg)
|
||||
|
||||
/**
|
||||
* Wait (forever) for a message to arrive in an mbox.
|
||||
* While waiting, timeouts are processed.
|
||||
@ -81,7 +90,7 @@ static void tcpip_thread_handle_msg(struct tcpip_msg *msg);
|
||||
* @param msg the place to store the message
|
||||
*/
|
||||
static void
|
||||
tcpip_timeouts_mbox_fetch(sys_mbox_t *mbox, void **msg)
|
||||
tcpip_mbox_fetch(sys_mbox_t *mbox, void **msg)
|
||||
{
|
||||
u32_t sleeptime, res;
|
||||
|
||||
@ -139,7 +148,7 @@ tcpip_thread(void *arg)
|
||||
while (1) { /* MAIN Loop */
|
||||
LWIP_TCPIP_THREAD_ALIVE();
|
||||
/* wait for a message, timeouts are processed while waiting */
|
||||
TCPIP_MBOX_FETCH(&tcpip_mbox, (void **)&msg);
|
||||
tcpip_mbox_fetch(&tcpip_mbox, (void **)&msg);
|
||||
if (msg == NULL) {
|
||||
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: invalid message: NULL\n"));
|
||||
LWIP_ASSERT("tcpip_thread: invalid message", 0);
|
||||
|
@ -21,7 +21,7 @@ while($file = <FILES>) {
|
||||
print(HEADER "HTTP/1.0 200 OK\r\n");
|
||||
}
|
||||
print(HEADER "Server: lwIP/pre-0.6 (http://www.sics.se/~adam/lwip/)\r\n");
|
||||
if($file =~ /\.html$/) {
|
||||
if($file =~ /\.s?html?$/) {
|
||||
print(HEADER "Content-type: text/html\r\n");
|
||||
} elsif($file =~ /\.gif$/) {
|
||||
print(HEADER "Content-type: image/gif\r\n");
|
||||
|
@ -265,6 +265,9 @@ static u16_t dhcp_option_long(u16_t options_out_len, u8_t *options, u32_t value)
|
||||
#if LWIP_NETIF_HOSTNAME
|
||||
static u16_t dhcp_option_hostname(u16_t options_out_len, u8_t *options, struct netif *netif);
|
||||
#endif /* LWIP_NETIF_HOSTNAME */
|
||||
#if LWIP_DHCP_MUD_URL
|
||||
static u16_t dhcp_option_mud_url(u16_t options_out_len, u8_t *options, char *mud_url);
|
||||
#endif /* LWIP_DHCP_MUD_URL */
|
||||
/* always add the DHCP options trailer to end and pad */
|
||||
static void dhcp_option_trailer(u16_t options_out_len, u8_t *options, struct pbuf *p_out);
|
||||
|
||||
@ -482,6 +485,11 @@ dhcp_select(struct netif *netif)
|
||||
options_out_len = dhcp_option_hostname(options_out_len, msg_out->options, netif);
|
||||
#endif /* LWIP_NETIF_HOSTNAME */
|
||||
|
||||
|
||||
#if LWIP_DHCP_MUD_URL
|
||||
options_out_len = dhcp_option_mud_url(options_out_len, msg_out->options, LWIP_MUD_URL_STRING);
|
||||
#endif /* LWIP_DHCP_MUD_URL */
|
||||
|
||||
LWIP_HOOK_DHCP_APPEND_OPTIONS(netif, dhcp, DHCP_STATE_REQUESTING, msg_out, DHCP_REQUEST, &options_out_len);
|
||||
dhcp_option_trailer(options_out_len, msg_out->options, p_out);
|
||||
|
||||
@ -1499,6 +1507,31 @@ dhcp_option_hostname(u16_t options_out_len, u8_t *options, struct netif *netif)
|
||||
}
|
||||
#endif /* LWIP_NETIF_HOSTNAME */
|
||||
|
||||
#if LWIP_DHCP_MUD_URL
|
||||
static u16_t
|
||||
dhcp_option_mud_url(u16_t options_out_len, u8_t *options, char *mud_url)
|
||||
{
|
||||
size_t mud_url_len = strlen(mud_url);
|
||||
LWIP_ASSERT("DHCP: MUD URLs must start with https://",
|
||||
strncmp(mud_url, "https://", 8) == 0);
|
||||
|
||||
size_t option_header_len = sizeof(u8_t) * 2;
|
||||
size_t len;
|
||||
const char *p = mud_url;
|
||||
size_t available = DHCP_OPTIONS_LEN - options_out_len - option_header_len;
|
||||
LWIP_ASSERT("DHCP: MUD URL is too long!", mud_url_len <= available);
|
||||
len = LWIP_MIN(mud_url_len, available);
|
||||
LWIP_ASSERT("DHCP: MUD URL is too long!", len < 0xFF - option_header_len);
|
||||
options_out_len = dhcp_option(options_out_len, options, DHCP_OPTION_MUD_URL_V4, (u8_t)len);
|
||||
|
||||
while (len--) {
|
||||
options_out_len = dhcp_option_byte(options_out_len, options, *p++);
|
||||
}
|
||||
|
||||
return options_out_len;
|
||||
}
|
||||
#endif /* LWIP_DHCP_MUD_URL */
|
||||
|
||||
/**
|
||||
* Extract the DHCP message and the DHCP options.
|
||||
*
|
||||
|
@ -134,6 +134,11 @@ static u8_t dhcp6_pcb_refcount;
|
||||
/* receive, unfold, parse and free incoming messages */
|
||||
static void dhcp6_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port);
|
||||
|
||||
#if LWIP_DHCP6_MUD_URL
|
||||
static u16_t dhcp6_option_mud_url(u16_t options_out_len, u8_t *options, char *mud_url, u16_t max_len);
|
||||
#endif /* LWIP_DHCP6_MUD_URL */
|
||||
|
||||
|
||||
/** Ensure DHCP PCB is allocated and bound */
|
||||
static err_t
|
||||
dhcp6_inc_pcb_refcount(void)
|
||||
@ -411,6 +416,13 @@ dhcp6_create_msg(struct netif *netif, struct dhcp6 *dhcp6, u8_t message_type,
|
||||
return p_out;
|
||||
}
|
||||
|
||||
static u16_t
|
||||
dhcp6_option_byte(u16_t options_out_len, u8_t *options, u16_t value)
|
||||
{
|
||||
options[options_out_len++] = value;
|
||||
return options_out_len;
|
||||
}
|
||||
|
||||
static u16_t
|
||||
dhcp6_option_short(u16_t options_out_len, u8_t *options, u16_t value)
|
||||
{
|
||||
@ -438,6 +450,33 @@ dhcp6_option_optionrequest(u16_t options_out_len, u8_t *options, const u16_t *re
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if LWIP_DHCP6_MUD_URL
|
||||
static u16_t
|
||||
dhcp6_option_mud_url(u16_t options_out_len, u8_t *options, char *mud_url, u16_t max_len)
|
||||
{
|
||||
size_t i;
|
||||
u16_t ret;
|
||||
size_t option_header_len = sizeof(u16_t) * 2;
|
||||
size_t mud_url_len = strlen(mud_url);
|
||||
const char *p = mud_url;
|
||||
|
||||
LWIP_ASSERT("dhcp6_option_mud_url: options_out_len + sizeof(struct dhcp6_msg) + mud_url_len <= max_len",
|
||||
sizeof(struct dhcp6_msg) + options_out_len + option_header_len + mud_url_len <= max_len);
|
||||
LWIP_ASSERT("DHCP: MUD URLs must start with https://",
|
||||
strncmp(mud_url, "https://", 8) == 0);
|
||||
LWIP_UNUSED_ARG(max_len);
|
||||
|
||||
ret = dhcp6_option_short(options_out_len, options, DHCP6_OPTION_MUD_URL_V6);
|
||||
ret = dhcp6_option_short(ret, options, mud_url_len);
|
||||
|
||||
while (mud_url_len--) {
|
||||
ret = dhcp6_option_byte(ret, options, *p++);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* LWIP_DHCP6_MUD_URL */
|
||||
|
||||
/* All options are added, shrink the pbuf to the required size */
|
||||
static void
|
||||
dhcp6_msg_finalize(u16_t options_out_len, struct pbuf *p_out)
|
||||
@ -475,6 +514,11 @@ dhcp6_information_request(struct netif *netif, struct dhcp6 *dhcp6)
|
||||
|
||||
options_out_len = dhcp6_option_optionrequest(options_out_len, options, requested_options,
|
||||
LWIP_ARRAYSIZE(requested_options), p_out->len);
|
||||
|
||||
#if LWIP_DHCP6_MUD_URL
|
||||
options_out_len = dhcp6_option_mud_url(options_out_len, options, LWIP_MUD_URL_STRING, p_out->len);
|
||||
#endif /* LWIP_DHCP6_MUD_URL */
|
||||
|
||||
LWIP_HOOK_DHCP6_APPEND_OPTIONS(netif, dhcp6, DHCP6_STATE_REQUESTING_CONFIG, msg_out,
|
||||
DHCP6_INFOREQUEST, options_out_len, p_out->len);
|
||||
dhcp6_msg_finalize(options_out_len, p_out);
|
||||
|
@ -994,6 +994,26 @@
|
||||
#if !defined LWIP_DHCP_DISCOVER_ADD_HOSTNAME || defined __DOXYGEN__
|
||||
#define LWIP_DHCP_DISCOVER_ADD_HOSTNAME 1
|
||||
#endif /* LWIP_DHCP_DISCOVER_ADD_HOSTNAME */
|
||||
|
||||
/**
|
||||
* LWIP_DHCP_MUD_URL == 1: Emit Manufacturer Usage Description (MUD) URL (RFC 8520) via DHCP.
|
||||
*/
|
||||
#if !defined LWIP_DHCP_MUD_URL || defined __DOXYGEN__
|
||||
#define LWIP_DHCP_MUD_URL 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LWIP_MUD_URL_STRING: Specifies a URL that points to a Manufacturer Usage Description (MUD)
|
||||
* file describing this device.
|
||||
* This URL will only be emitted via DHCP or DHCPv6 if LWIP_DHCP_MUD_URL or LWIP_DHCP6_MUD_URL are set
|
||||
* to 1, respectively.
|
||||
* The URL MUST start with https://.
|
||||
*
|
||||
* See RFC 8520 for more information.
|
||||
*/
|
||||
#ifdef __DOXYGEN__
|
||||
#define LWIP_MUD_URL_STRING "https://example.org/mud-file"
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@ -2814,6 +2834,13 @@
|
||||
#if !defined LWIP_DHCP6_MAX_DNS_SERVERS || defined __DOXYGEN__
|
||||
#define LWIP_DHCP6_MAX_DNS_SERVERS DNS_MAX_SERVERS
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LWIP_DHCP6_MUD_URL == 1: Emit Manufacturer Usage Description (MUD) URL (RFC 8520) via DHCPv6.
|
||||
*/
|
||||
#if !defined LWIP_DHCP6_MUD_URL || defined __DOXYGEN__
|
||||
#define LWIP_DHCP6_MUD_URL 0
|
||||
#endif
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
@ -164,6 +164,8 @@ typedef enum {
|
||||
#define DHCP_OPTION_TFTP_SERVERNAME 66
|
||||
#define DHCP_OPTION_BOOTFILE 67
|
||||
|
||||
#define DHCP_OPTION_MUD_URL_V4 116 /* RFC 8520 10., MUD URL Option */
|
||||
|
||||
/* possible combinations of overloading the file and sname fields with options */
|
||||
#define DHCP_OVERLOAD_NONE 0
|
||||
#define DHCP_OVERLOAD_FILE 1
|
||||
|
@ -129,6 +129,7 @@ typedef enum {
|
||||
#define DHCP6_OPTION_DNS_SERVERS 23 /* RFC 3646 */
|
||||
#define DHCP6_OPTION_DOMAIN_LIST 24 /* RFC 3646 */
|
||||
#define DHCP6_OPTION_SNTP_SERVERS 31 /* RFC 4075 */
|
||||
#define DHCP6_OPTION_MUD_URL_V6 112 /* RFC 8520 */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
Loading…
Reference in New Issue
Block a user