mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-09-28 23:00:50 +00:00
Compare commits
12 Commits
bd40949c29
...
eaf9c5b3a9
Author | SHA1 | Date | |
---|---|---|---|
|
eaf9c5b3a9 | ||
|
d0efd9ef7b | ||
|
e799c266fa | ||
|
cb511019b0 | ||
|
9004e7bd77 | ||
|
17b1f5d382 | ||
|
10dc9b7eb3 | ||
|
c3d6fe9d72 | ||
|
93821fc437 | ||
|
7c494b3829 | ||
|
e1b8080346 | ||
|
149e52f2c5 |
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
|
#define LWIP_TIMEVAL_PRIVATE 0
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#define LWIP_ERRNO_INCLUDE <errno.h>
|
#define LWIP_ERRNO_INCLUDE <errno.h>
|
||||||
|
|
||||||
#if defined(LWIP_UNIX_LINUX) || defined(LWIP_UNIX_HURD) || defined(LWIP_UNIX_KFREEBSD)
|
#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;
|
typedef unsigned int sys_prot_t;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* LWIP_ARCH_CC_H */
|
#endif /* LWIP_ARCH_CC_H */
|
||||||
|
@ -34,6 +34,10 @@
|
|||||||
|
|
||||||
#include <sys/times.h>
|
#include <sys/times.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PERF
|
#ifdef PERF
|
||||||
#define PERF_START { \
|
#define PERF_START { \
|
||||||
unsigned long __c1l, __c1h, __c2l, __c2h; \
|
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);
|
void perf_init(char *fname);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* LWIP_ARCH_PERF_H */
|
#endif /* LWIP_ARCH_PERF_H */
|
||||||
|
@ -32,6 +32,10 @@
|
|||||||
#ifndef LWIP_ARCH_SYS_ARCH_H
|
#ifndef LWIP_ARCH_SYS_ARCH_H
|
||||||
#define LWIP_ARCH_SYS_ARCH_H
|
#define LWIP_ARCH_SYS_ARCH_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#define SYS_MBOX_NULL NULL
|
#define SYS_MBOX_NULL NULL
|
||||||
#define SYS_SEM_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()
|
#define UNLOCK_TCPIP_CORE() sys_unlock_tcpip_core()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* LWIP_ARCH_SYS_ARCH_H */
|
#endif /* LWIP_ARCH_SYS_ARCH_H */
|
||||||
|
@ -3,6 +3,10 @@
|
|||||||
|
|
||||||
#include "lwip/sys.h"
|
#include "lwip/sys.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
/** How many bytes in fifo */
|
/** How many bytes in fifo */
|
||||||
#define FIFOSIZE 2048
|
#define FIFOSIZE 2048
|
||||||
|
|
||||||
@ -50,5 +54,9 @@ void fifoPut(fifo_t * fifo, int fd);
|
|||||||
*/
|
*/
|
||||||
void fifoInit(fifo_t * fifo);
|
void fifoInit(fifo_t * fifo);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
#ifndef LWIP_LIST_H
|
#ifndef LWIP_LIST_H
|
||||||
#define LWIP_LIST_H
|
#define LWIP_LIST_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
struct elem;
|
struct elem;
|
||||||
|
|
||||||
struct list {
|
struct list {
|
||||||
@ -23,4 +27,8 @@ void list_delete(struct list *list);
|
|||||||
int list_remove(struct list *list, void *elem);
|
int list_remove(struct list *list, void *elem);
|
||||||
void list_map(struct list *list, void (* func)(void *arg));
|
void list_map(struct list *list, void (* func)(void *arg));
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -34,6 +34,14 @@
|
|||||||
|
|
||||||
#include "lwip/netif.h"
|
#include "lwip/netif.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
err_t pcapif_init(struct netif *netif);
|
err_t pcapif_init(struct netif *netif);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* LWIP_PCAPIF_H */
|
#endif /* LWIP_PCAPIF_H */
|
||||||
|
@ -6,6 +6,10 @@
|
|||||||
#include "netif/fifo.h"
|
#include "netif/fifo.h"
|
||||||
/*#include "netif/pppif.h"*/
|
/*#include "netif/pppif.h"*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
struct sio_status_s {
|
struct sio_status_s {
|
||||||
int fd;
|
int fd;
|
||||||
fifo_t myfifo;
|
fifo_t myfifo;
|
||||||
@ -56,5 +60,9 @@ void sio_flush( sio_status_t * siostat );
|
|||||||
*/
|
*/
|
||||||
void sio_change_baud( sioBaudrates baud, sio_status_t * siostat );
|
void sio_change_baud( sioBaudrates baud, sio_status_t * siostat );
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -34,10 +34,18 @@
|
|||||||
|
|
||||||
#include "lwip/netif.h"
|
#include "lwip/netif.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
err_t tapif_init(struct netif *netif);
|
err_t tapif_init(struct netif *netif);
|
||||||
void tapif_poll(struct netif *netif);
|
void tapif_poll(struct netif *netif);
|
||||||
#if NO_SYS
|
#if NO_SYS
|
||||||
int tapif_select(struct netif *netif);
|
int tapif_select(struct netif *netif);
|
||||||
#endif /* NO_SYS */
|
#endif /* NO_SYS */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* LWIP_TAPIF_H */
|
#endif /* LWIP_TAPIF_H */
|
||||||
|
@ -34,10 +34,18 @@
|
|||||||
|
|
||||||
#include "lwip/netif.h"
|
#include "lwip/netif.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
err_t vdeif_init(struct netif *netif);
|
err_t vdeif_init(struct netif *netif);
|
||||||
void vdeif_poll(struct netif *netif);
|
void vdeif_poll(struct netif *netif);
|
||||||
#if NO_SYS
|
#if NO_SYS
|
||||||
int vdeif_select(struct netif *netif);
|
int vdeif_select(struct netif *netif);
|
||||||
#endif /* NO_SYS */
|
#endif /* NO_SYS */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* LWIP_VDEIF_H */
|
#endif /* LWIP_VDEIF_H */
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#if LWIP_DNS && LWIP_SOCKET
|
#if LWIP_DNS && LWIP_SOCKET
|
||||||
|
|
||||||
#include "lwip/err.h"
|
#include "lwip/err.h"
|
||||||
|
#include "lwip/errno.h"
|
||||||
#include "lwip/mem.h"
|
#include "lwip/mem.h"
|
||||||
#include "lwip/memp.h"
|
#include "lwip/memp.h"
|
||||||
#include "lwip/ip_addr.h"
|
#include "lwip/ip_addr.h"
|
||||||
@ -382,7 +383,9 @@ lwip_getaddrinfo(const char *nodename, const char *servname,
|
|||||||
/* set up sockaddr */
|
/* set up sockaddr */
|
||||||
inet6_addr_from_ip6addr(&sa6->sin6_addr, ip_2_ip6(&addr));
|
inet6_addr_from_ip6addr(&sa6->sin6_addr, ip_2_ip6(&addr));
|
||||||
sa6->sin6_family = AF_INET6;
|
sa6->sin6_family = AF_INET6;
|
||||||
|
#if LWIP_SOCKET_HAVE_SA_LEN
|
||||||
sa6->sin6_len = sizeof(struct sockaddr_in6);
|
sa6->sin6_len = sizeof(struct sockaddr_in6);
|
||||||
|
#endif /* LWIP_SOCKET_HAVE_SA_LEN */
|
||||||
sa6->sin6_port = lwip_htons((u16_t)port_nr);
|
sa6->sin6_port = lwip_htons((u16_t)port_nr);
|
||||||
sa6->sin6_scope_id = ip6_addr_zone(ip_2_ip6(&addr));
|
sa6->sin6_scope_id = ip6_addr_zone(ip_2_ip6(&addr));
|
||||||
ai->ai_family = AF_INET6;
|
ai->ai_family = AF_INET6;
|
||||||
@ -393,7 +396,9 @@ lwip_getaddrinfo(const char *nodename, const char *servname,
|
|||||||
/* set up sockaddr */
|
/* set up sockaddr */
|
||||||
inet_addr_from_ip4addr(&sa4->sin_addr, ip_2_ip4(&addr));
|
inet_addr_from_ip4addr(&sa4->sin_addr, ip_2_ip4(&addr));
|
||||||
sa4->sin_family = AF_INET;
|
sa4->sin_family = AF_INET;
|
||||||
|
#if LWIP_SOCKET_HAVE_SA_LEN
|
||||||
sa4->sin_len = sizeof(struct sockaddr_in);
|
sa4->sin_len = sizeof(struct sockaddr_in);
|
||||||
|
#endif /* LWIP_SOCKET_HAVE_SA_LEN */
|
||||||
sa4->sin_port = lwip_htons((u16_t)port_nr);
|
sa4->sin_port = lwip_htons((u16_t)port_nr);
|
||||||
ai->ai_family = AF_INET;
|
ai->ai_family = AF_INET;
|
||||||
#endif /* LWIP_IPV4 */
|
#endif /* LWIP_IPV4 */
|
||||||
|
@ -1215,6 +1215,22 @@ lwip_recvfrom_udp_raw(struct lwip_sock *sock, int flags, struct msghdr *msg, u16
|
|||||||
msg->msg_flags |= MSG_CTRUNC;
|
msg->msg_flags |= MSG_CTRUNC;
|
||||||
}
|
}
|
||||||
#endif /* LWIP_IPV4 */
|
#endif /* LWIP_IPV4 */
|
||||||
|
} else if (IP_IS_V6(&buf->toaddr)) {
|
||||||
|
#if LWIP_IPV6
|
||||||
|
if (msg->msg_controllen >= CMSG_SPACE(sizeof(struct in6_pktinfo))) {
|
||||||
|
struct cmsghdr *chdr = CMSG_FIRSTHDR(msg); /* This will always return a header!! */
|
||||||
|
struct in6_pktinfo *pkti = (struct in6_pktinfo *)CMSG_DATA(chdr);
|
||||||
|
chdr->cmsg_level = IPPROTO_IPV6;
|
||||||
|
chdr->cmsg_type = IPV6_PKTINFO;
|
||||||
|
chdr->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo));
|
||||||
|
pkti->ipi6_ifindex = buf->p->if_idx;
|
||||||
|
inet6_addr_from_ip6addr(&pkti->ipi6_addr, ip_2_ip6(netbuf_destaddr(buf)));
|
||||||
|
msg->msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo));
|
||||||
|
wrote_msg = 1;
|
||||||
|
} else {
|
||||||
|
msg->msg_flags |= MSG_CTRUNC;
|
||||||
|
}
|
||||||
|
#endif /* LWIP_IPV6 */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* LWIP_NETBUF_RECVINFO */
|
#endif /* LWIP_NETBUF_RECVINFO */
|
||||||
@ -3711,6 +3727,16 @@ lwip_setsockopt_impl(int s, int level, int optname, const void *optval, socklen_
|
|||||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IPV6, IPV6_V6ONLY, ..) -> %d\n",
|
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IPV6, IPV6_V6ONLY, ..) -> %d\n",
|
||||||
s, (netconn_get_ipv6only(sock->conn) ? 1 : 0)));
|
s, (netconn_get_ipv6only(sock->conn) ? 1 : 0)));
|
||||||
break;
|
break;
|
||||||
|
#if LWIP_NETBUF_RECVINFO
|
||||||
|
case IPV6_RECVPKTINFO:
|
||||||
|
LWIP_SOCKOPT_CHECK_OPTLEN_CONN_PCB_TYPE(sock, optlen, int, NETCONN_UDP);
|
||||||
|
if (*(const int *)optval) {
|
||||||
|
sock->conn->flags |= NETCONN_FLAG_PKTINFO;
|
||||||
|
} else {
|
||||||
|
sock->conn->flags &= ~NETCONN_FLAG_PKTINFO;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif /* LWIP_NETBUF_RECVINFO */
|
||||||
#if LWIP_IPV6_MLD
|
#if LWIP_IPV6_MLD
|
||||||
case IPV6_JOIN_GROUP:
|
case IPV6_JOIN_GROUP:
|
||||||
case IPV6_LEAVE_GROUP: {
|
case IPV6_LEAVE_GROUP: {
|
||||||
|
@ -68,11 +68,20 @@ sys_mutex_t lock_tcpip_core;
|
|||||||
static void tcpip_thread_handle_msg(struct tcpip_msg *msg);
|
static void tcpip_thread_handle_msg(struct tcpip_msg *msg);
|
||||||
|
|
||||||
#if !LWIP_TIMERS
|
#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 */
|
#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.
|
* Wait (forever) for a message to arrive in an mbox.
|
||||||
* While waiting, timeouts are processed.
|
* 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
|
* @param msg the place to store the message
|
||||||
*/
|
*/
|
||||||
static void
|
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;
|
u32_t sleeptime, res;
|
||||||
|
|
||||||
@ -139,7 +148,7 @@ tcpip_thread(void *arg)
|
|||||||
while (1) { /* MAIN Loop */
|
while (1) { /* MAIN Loop */
|
||||||
LWIP_TCPIP_THREAD_ALIVE();
|
LWIP_TCPIP_THREAD_ALIVE();
|
||||||
/* wait for a message, timeouts are processed while waiting */
|
/* 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) {
|
if (msg == NULL) {
|
||||||
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: invalid message: NULL\n"));
|
LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: invalid message: NULL\n"));
|
||||||
LWIP_ASSERT("tcpip_thread: invalid message", 0);
|
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 "HTTP/1.0 200 OK\r\n");
|
||||||
}
|
}
|
||||||
print(HEADER "Server: lwIP/pre-0.6 (http://www.sics.se/~adam/lwip/)\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");
|
print(HEADER "Content-type: text/html\r\n");
|
||||||
} elsif($file =~ /\.gif$/) {
|
} elsif($file =~ /\.gif$/) {
|
||||||
print(HEADER "Content-type: image/gif\r\n");
|
print(HEADER "Content-type: image/gif\r\n");
|
||||||
|
@ -298,6 +298,8 @@ struct linger {
|
|||||||
*/
|
*/
|
||||||
#define IPV6_CHECKSUM 7 /* RFC3542: calculate and insert the ICMPv6 checksum for raw sockets. */
|
#define IPV6_CHECKSUM 7 /* RFC3542: calculate and insert the ICMPv6 checksum for raw sockets. */
|
||||||
#define IPV6_V6ONLY 27 /* RFC3493: boolean control to restrict AF_INET6 sockets to IPv6 communications only. */
|
#define IPV6_V6ONLY 27 /* RFC3493: boolean control to restrict AF_INET6 sockets to IPv6 communications only. */
|
||||||
|
#define IPV6_RECVPKTINFO 49 /* RFC3542: enables the receiving of ancillary data via setsockopt() */
|
||||||
|
#define IPV6_PKTINFO 50 /* RFC3542: ancillary data in recvmsg() received */
|
||||||
#endif /* LWIP_IPV6 */
|
#endif /* LWIP_IPV6 */
|
||||||
|
|
||||||
#if LWIP_UDP && LWIP_UDPLITE
|
#if LWIP_UDP && LWIP_UDPLITE
|
||||||
@ -338,6 +340,13 @@ struct in_pktinfo {
|
|||||||
};
|
};
|
||||||
#endif /* LWIP_IPV4 */
|
#endif /* LWIP_IPV4 */
|
||||||
|
|
||||||
|
#if LWIP_IPV6
|
||||||
|
struct in6_pktinfo {
|
||||||
|
unsigned int ipi6_ifindex; /* Interface index */
|
||||||
|
struct in6_addr ipi6_addr; /* Destination (from header) address */
|
||||||
|
};
|
||||||
|
#endif /* LWIP_IPV6 */
|
||||||
|
|
||||||
#if LWIP_IPV6_MLD
|
#if LWIP_IPV6_MLD
|
||||||
/*
|
/*
|
||||||
* Options and types related to IPv6 multicast membership
|
* Options and types related to IPv6 multicast membership
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "lwip/priv/tcp_priv.h"
|
#include "lwip/priv/tcp_priv.h"
|
||||||
#include "lwip/api.h"
|
#include "lwip/api.h"
|
||||||
|
|
||||||
|
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
|
||||||
|
|
||||||
static int
|
static int
|
||||||
test_sockets_get_used_count(void)
|
test_sockets_get_used_count(void)
|
||||||
@ -544,7 +545,6 @@ static void test_sockets_msgapi_udp(int domain)
|
|||||||
fail_unless(ret == 0);
|
fail_unless(ret == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LWIP_IPV4
|
|
||||||
static void test_sockets_msgapi_cmsg(int domain)
|
static void test_sockets_msgapi_cmsg(int domain)
|
||||||
{
|
{
|
||||||
int s, ret, enable;
|
int s, ret, enable;
|
||||||
@ -553,10 +553,10 @@ static void test_sockets_msgapi_cmsg(int domain)
|
|||||||
struct iovec iov;
|
struct iovec iov;
|
||||||
struct msghdr msg;
|
struct msghdr msg;
|
||||||
struct cmsghdr *cmsg;
|
struct cmsghdr *cmsg;
|
||||||
struct in_pktinfo *pktinfo;
|
|
||||||
u8_t rcv_buf[4];
|
u8_t rcv_buf[4];
|
||||||
u8_t snd_buf[4] = {0xDE, 0xAD, 0xBE, 0xEF};
|
u8_t snd_buf[4] = {0xDE, 0xAD, 0xBE, 0xEF};
|
||||||
u8_t cmsg_buf[CMSG_SPACE(sizeof(struct in_pktinfo))];
|
u8_t cmsg_buf[CMSG_SPACE(MAX(sizeof(struct in_pktinfo),
|
||||||
|
sizeof(struct in6_pktinfo)))];
|
||||||
|
|
||||||
test_sockets_init_loopback_addr(domain, &addr_storage, &addr_size);
|
test_sockets_init_loopback_addr(domain, &addr_storage, &addr_size);
|
||||||
|
|
||||||
@ -571,7 +571,15 @@ static void test_sockets_msgapi_cmsg(int domain)
|
|||||||
fail_unless(ret == 0);
|
fail_unless(ret == 0);
|
||||||
|
|
||||||
enable = 1;
|
enable = 1;
|
||||||
ret = lwip_setsockopt(s, IPPROTO_IP, IP_PKTINFO, &enable, sizeof(enable));
|
if (domain == AF_INET) {
|
||||||
|
#if LWIP_IPV4
|
||||||
|
ret = lwip_setsockopt(s, IPPROTO_IP, IP_PKTINFO, &enable, sizeof(enable));
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
#if LWIP_IPV6
|
||||||
|
ret = lwip_setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO, &enable, sizeof(enable));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
fail_unless(ret == 0);
|
fail_unless(ret == 0);
|
||||||
|
|
||||||
/* Receive full message, including control message */
|
/* Receive full message, including control message */
|
||||||
@ -599,14 +607,31 @@ static void test_sockets_msgapi_cmsg(int domain)
|
|||||||
cmsg = CMSG_FIRSTHDR(&msg);
|
cmsg = CMSG_FIRSTHDR(&msg);
|
||||||
fail_unless(cmsg != NULL);
|
fail_unless(cmsg != NULL);
|
||||||
fail_unless(cmsg->cmsg_len > 0);
|
fail_unless(cmsg->cmsg_len > 0);
|
||||||
fail_unless(cmsg->cmsg_level == IPPROTO_IP);
|
|
||||||
fail_unless(cmsg->cmsg_type == IP_PKTINFO);
|
|
||||||
|
|
||||||
/* Verify message data */
|
if (domain == AF_INET) {
|
||||||
pktinfo = (struct in_pktinfo*)CMSG_DATA(cmsg);
|
struct in_pktinfo *pktinfo;
|
||||||
/* We only have loopback interface enabled */
|
|
||||||
fail_unless(pktinfo->ipi_ifindex == 1);
|
fail_unless(cmsg->cmsg_level == IPPROTO_IP);
|
||||||
fail_unless(pktinfo->ipi_addr.s_addr == PP_HTONL(INADDR_LOOPBACK));
|
fail_unless(cmsg->cmsg_type == IP_PKTINFO);
|
||||||
|
|
||||||
|
/* Verify message data */
|
||||||
|
pktinfo = (struct in_pktinfo*)CMSG_DATA(cmsg);
|
||||||
|
/* We only have loopback interface enabled */
|
||||||
|
fail_unless(pktinfo->ipi_ifindex == 1);
|
||||||
|
fail_unless(pktinfo->ipi_addr.s_addr == PP_HTONL(INADDR_LOOPBACK));
|
||||||
|
} else {
|
||||||
|
struct in6_pktinfo *pktinfo;
|
||||||
|
struct in6_addr lo6 = IN6ADDR_LOOPBACK_INIT;
|
||||||
|
|
||||||
|
fail_unless(cmsg->cmsg_level == IPPROTO_IPV6);
|
||||||
|
fail_unless(cmsg->cmsg_type == IPV6_PKTINFO);
|
||||||
|
|
||||||
|
/* Verify message data */
|
||||||
|
pktinfo = (struct in6_pktinfo*)CMSG_DATA(cmsg);
|
||||||
|
/* We only have loopback interface enabled */
|
||||||
|
fail_unless(pktinfo->ipi6_ifindex == 1);
|
||||||
|
fail_unless(!memcmp(&pktinfo->ipi6_addr, &lo6, sizeof(pktinfo->ipi6_addr)));
|
||||||
|
}
|
||||||
|
|
||||||
/* Verify there are no additional messages */
|
/* Verify there are no additional messages */
|
||||||
cmsg = CMSG_NXTHDR(&msg, cmsg);
|
cmsg = CMSG_NXTHDR(&msg, cmsg);
|
||||||
@ -632,7 +657,6 @@ static void test_sockets_msgapi_cmsg(int domain)
|
|||||||
ret = lwip_close(s);
|
ret = lwip_close(s);
|
||||||
fail_unless(ret == 0);
|
fail_unless(ret == 0);
|
||||||
}
|
}
|
||||||
#endif /* LWIP_IPV4 */
|
|
||||||
|
|
||||||
START_TEST(test_sockets_msgapis)
|
START_TEST(test_sockets_msgapis)
|
||||||
{
|
{
|
||||||
@ -645,6 +669,7 @@ START_TEST(test_sockets_msgapis)
|
|||||||
#if LWIP_IPV6
|
#if LWIP_IPV6
|
||||||
test_sockets_msgapi_udp(AF_INET6);
|
test_sockets_msgapi_udp(AF_INET6);
|
||||||
test_sockets_msgapi_tcp(AF_INET6);
|
test_sockets_msgapi_tcp(AF_INET6);
|
||||||
|
test_sockets_msgapi_cmsg(AF_INET6);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
Loading…
Reference in New Issue
Block a user