mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-08 08:54:54 +07:00
Merge pull request #3600 from cesanta/tests
Fix some neats, add IPv6 basic testing in LAN
This commit is contained in:
@@ -67,14 +67,15 @@ jobs:
|
||||
env:
|
||||
CC: ${{ matrix.cc }}
|
||||
SSL: ${{ matrix.ssl }}
|
||||
TFLAGS: -DMQTT_HOST -DNO_ABORT # -DMQTT_HOST_NAME=\"server\"
|
||||
IPV6: 1
|
||||
TFLAGS: -DMQTT_HOST -DIPV6_NOROUTING -DNO_ABORT # -DMQTT_HOST_NAME=\"server\"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with: { fetch-depth: 2 }
|
||||
- uses: webfactory/ssh-agent@v0.9.1
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.HEALTH_TESTS_SSH_KEY }}
|
||||
- run: if [ "${{ matrix.target }}" == "mip_tap_test" ]; then source ./test/setup_ga_network.sh ; export IPV6=0; sed -i -e "s/127.0.0.1//" test/mosquitto.conf; cat test/mosquitto.conf; ./test/setup_mqtt_server.sh; else export IPV6=1 ; fi && sudo apt -y update ; sudo apt -y install libmbedtls-dev libwolfssl-dev && make -C test ${{ matrix.target }} > log
|
||||
- run: if [ "${{ matrix.target }}" == "mip_tap_test" ]; then source ./test/setup_ga_network.sh ; sed -i -e "s/127.0.0.1//" test/mosquitto.conf; cat test/mosquitto.conf; ./test/setup_mqtt_server.sh; fi && sudo apt -y update ; sudo apt -y install libmbedtls-dev libwolfssl-dev && make -C test ${{ matrix.target }} > log
|
||||
- if: success() || failure()
|
||||
run: |
|
||||
cat log
|
||||
|
||||
@@ -20,14 +20,14 @@ jobs:
|
||||
env:
|
||||
CC: ${{ matrix.cc }}
|
||||
SSL: ${{ matrix.ssl }}
|
||||
TFLAGS: -DMQTT_HOST -DNO_ABORT # -DMQTT_HOST_NAME=\"server\"
|
||||
TFLAGS: -DMQTT_HOST -DIPV6_NOROUTING -DNO_ABORT # -DMQTT_HOST_NAME=\"server\"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with: { fetch-depth: 2 }
|
||||
- uses: webfactory/ssh-agent@v0.9.1
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.HEALTH_TESTS_SSH_KEY }}
|
||||
- run: if [ "${{ matrix.target }}" == "mip_tap_test" ]; then source ./test/setup_ga_network.sh ; export IPV6=0; sed -i -e "s/127.0.0.1//" test/mosquitto.conf; cat test/mosquitto.conf; ./test/setup_mqtt_server.sh; else export IPV6=1 ; fi && sudo apt -y update ; sudo apt -y install libmbedtls-dev libwolfssl-dev && make -C test ${{ matrix.target }} > log
|
||||
- run: if [ "${{ matrix.target }}" == "mip_tap_test" ]; then source ./test/setup_ga_network.sh ; export IPV6=1; sed -i -e "s/127.0.0.1//" test/mosquitto.conf; cat test/mosquitto.conf; ./test/setup_mqtt_server.sh; else export IPV6=1 ; fi && sudo apt -y update ; sudo apt -y install libmbedtls-dev libwolfssl-dev && make -C test ${{ matrix.target }} > log
|
||||
- if: success() || failure()
|
||||
run: |
|
||||
cat log
|
||||
|
||||
+11
-7
@@ -5097,7 +5097,7 @@ uint8_t *mg_l2_eth_header(struct mg_tcpip_if *ifp, enum mg_l2proto proto,
|
||||
qtag->tpid = mg_htons(0x8100);
|
||||
qtag->tci = mg_htons(d->vlan_id); // PCP = default (best-effort)
|
||||
hlp += sizeof(*qtag);
|
||||
*(uint16_t *) (qtag + 1) = mg_htons(eth_types[(unsigned int) proto]);
|
||||
MG_STORE_BE16(qtag + 1, eth_types[(unsigned int) proto]);
|
||||
}
|
||||
return hlp;
|
||||
}
|
||||
@@ -5131,7 +5131,7 @@ bool mg_l2_eth_rx(struct mg_tcpip_if *ifp, enum mg_l2proto *proto,
|
||||
if (qtag->tpid != mg_htons(0x8100)) return false; // Untagged frame
|
||||
if (mg_ntohs(VLAN_ID(qtag->tci)) != VLAN_ID(d->vlan_id))
|
||||
return false; // Not our VLAN
|
||||
type = mg_ntohs(*(uint16_t *) (qtag + 1));
|
||||
type = MG_LOAD_BE16(qtag + 1);
|
||||
}
|
||||
if (ifp->enable_mac_check &&
|
||||
memcmp(eth->dst, ifp->mac, sizeof(eth->dst)) != 0 &&
|
||||
@@ -8434,7 +8434,7 @@ static void rx_ndp_na(struct mg_tcpip_if *ifp, struct pkt *pkt) {
|
||||
uint8_t len = *opts++; // check valid hwaddr and get it
|
||||
if (!mg_l2_ip6get(ifp->l2type, s->mac, opts, len)) return;
|
||||
MG_DEBUG(("%lu NDP resolved %M -> %M", c->id, mg_print_ip6,
|
||||
&c->rem.addr.ip6, mg_print_mac, ifp->l2type, s->mac));
|
||||
&c->rem.addr.ip6, mg_print_l2addr, ifp->l2type, s->mac));
|
||||
c->is_arplooking = 0;
|
||||
l2addr_resolved(c);
|
||||
}
|
||||
@@ -8569,12 +8569,12 @@ static void rx_ndp_ra(struct mg_tcpip_if *ifp, struct pkt *pkt) {
|
||||
gotl2addr = true;
|
||||
} else if (type == 5 && length >= 8) {
|
||||
// process MTU if available
|
||||
mtu = mg_ntohl(*(uint32_t *) (opts + 4));
|
||||
mtu = MG_LOAD_BE32(opts + 4);
|
||||
} else if (type == 3 && length >= 32) {
|
||||
// process prefix, 4.6.2
|
||||
uint8_t pfx_flags = opts[3]; // L=0x80, A=0x40
|
||||
uint32_t valid = mg_ntohl(*(uint32_t *) (opts + 4));
|
||||
uint32_t pref_lifetime = mg_ntohl(*(uint32_t *) (opts + 8));
|
||||
uint32_t valid = MG_LOAD_BE32(opts + 4);
|
||||
uint32_t pref_lifetime = MG_LOAD_BE32(opts + 8);
|
||||
prefix_len = opts[2];
|
||||
prefix = opts + 16;
|
||||
|
||||
@@ -9705,7 +9705,11 @@ void mg_connect_resolved(struct mg_connection *c) {
|
||||
c->loc.port = mg_htons(ifp->eport++);
|
||||
#if MG_ENABLE_IPV6
|
||||
if (c->rem.is_ip6) {
|
||||
c->loc.addr.ip6[0] = ifp->ip6[0], c->loc.addr.ip6[1] = ifp->ip6[1],
|
||||
if(c->rem.addr.ip6[0] == ifp->ip6ll[0]) { // same local LAN, use ll
|
||||
c->loc.addr.ip6[0] = ifp->ip6ll[0], c->loc.addr.ip6[1] = ifp->ip6ll[1];
|
||||
} else { // use global address
|
||||
c->loc.addr.ip6[0] = ifp->ip6[0], c->loc.addr.ip6[1] = ifp->ip6[1];
|
||||
}
|
||||
c->loc.is_ip6 = true;
|
||||
} else
|
||||
#endif
|
||||
|
||||
+27
-26
@@ -1374,6 +1374,7 @@ size_t mg_xprintf(mg_pfn_t fn, void *arg, const char *fmt, ...);
|
||||
|
||||
|
||||
|
||||
|
||||
// Formats into buf/len. Returns the number of bytes that would be written if
|
||||
// buf were large enough (like snprintf). Call with buf=NULL, len=0 to measure.
|
||||
// NUL-terminates if the result fits (n < len).
|
||||
@@ -1397,7 +1398,7 @@ size_t mg_print_ip4(mg_pfn_t, void *arg, va_list *ap); // expects: uint32_t
|
||||
size_t mg_print_ip6(mg_pfn_t, void *arg, va_list *ap); // expects: uint8_t[16] ipv6
|
||||
size_t mg_print_mac(mg_pfn_t, void *arg, va_list *ap); // expects: uint8_t[6] mac
|
||||
size_t mg_print_ieee64(mg_pfn_t, void *arg, va_list *ap); // expects: uint64_t
|
||||
size_t mg_print_l2addr(mg_pfn_t, void *arg, va_list *ap); // expects: const struct mg_addr *
|
||||
size_t mg_print_l2addr(mg_pfn_t, void *arg, va_list *ap); // expects: uint8_t l2, uint8_t[n] n-byte l2-dependent address
|
||||
|
||||
// Output functions for use as the fn argument to mg_xprintf/mg_vxprintf.
|
||||
void mg_pfn_iobuf(char ch, void *param); // param: struct mg_iobuf * (resizes as needed)
|
||||
@@ -1672,34 +1673,34 @@ void mg_delayms(unsigned int ms);
|
||||
|
||||
// Write a native integer to byte pointer p in big-endian byte order.
|
||||
// Safe on architectures that forbid unaligned access.
|
||||
#define MG_STORE_BE16(p, n) \
|
||||
do { \
|
||||
MG_U8P(p)[0] = ((n) >> 8U) & 255; \
|
||||
MG_U8P(p)[1] = (n) &255; \
|
||||
#define MG_STORE_BE16(p, n) \
|
||||
do { \
|
||||
MG_U8P(p)[0] = (uint8_t) ((n) >> 8U); \
|
||||
MG_U8P(p)[1] = (uint8_t) (n); \
|
||||
} while (0)
|
||||
#define MG_STORE_BE24(p, n) \
|
||||
do { \
|
||||
MG_U8P(p)[0] = ((n) >> 16U) & 255; \
|
||||
MG_U8P(p)[1] = ((n) >> 8U) & 255; \
|
||||
MG_U8P(p)[2] = (n) &255; \
|
||||
#define MG_STORE_BE24(p, n) \
|
||||
do { \
|
||||
MG_U8P(p)[0] = (uint8_t) ((n) >> 16U); \
|
||||
MG_U8P(p)[1] = (uint8_t) ((n) >> 8U); \
|
||||
MG_U8P(p)[2] = (uint8_t) (n); \
|
||||
} while (0)
|
||||
#define MG_STORE_BE32(p, n) \
|
||||
do { \
|
||||
MG_U8P(p)[0] = ((n) >> 24U) & 255; \
|
||||
MG_U8P(p)[1] = ((n) >> 16U) & 255; \
|
||||
MG_U8P(p)[2] = ((n) >> 8U) & 255; \
|
||||
MG_U8P(p)[3] = (n) &255; \
|
||||
#define MG_STORE_BE32(p, n) \
|
||||
do { \
|
||||
MG_U8P(p)[0] = (uint8_t) ((n) >> 24U); \
|
||||
MG_U8P(p)[1] = (uint8_t) ((n) >> 16U); \
|
||||
MG_U8P(p)[2] = (uint8_t) ((n) >> 8U); \
|
||||
MG_U8P(p)[3] = (uint8_t) (n); \
|
||||
} while (0)
|
||||
#define MG_STORE_BE64(p, n) \
|
||||
do { \
|
||||
MG_U8P(p)[0] = ((n) >> 56U) & 255; \
|
||||
MG_U8P(p)[1] = ((n) >> 48U) & 255; \
|
||||
MG_U8P(p)[2] = ((n) >> 40U) & 255; \
|
||||
MG_U8P(p)[3] = ((n) >> 32U) & 255; \
|
||||
MG_U8P(p)[4] = ((n) >> 24U) & 255; \
|
||||
MG_U8P(p)[5] = ((n) >> 16U) & 255; \
|
||||
MG_U8P(p)[6] = ((n) >> 8U) & 255; \
|
||||
MG_U8P(p)[7] = (n) &255; \
|
||||
#define MG_STORE_BE64(p, n) \
|
||||
do { \
|
||||
MG_U8P(p)[0] = (uint8_t) ((n) >> 56U); \
|
||||
MG_U8P(p)[1] = (uint8_t) ((n) >> 48U); \
|
||||
MG_U8P(p)[2] = (uint8_t) ((n) >> 40U); \
|
||||
MG_U8P(p)[3] = (uint8_t) ((n) >> 32U); \
|
||||
MG_U8P(p)[4] = (uint8_t) ((n) >> 24U); \
|
||||
MG_U8P(p)[5] = (uint8_t) ((n) >> 16U); \
|
||||
MG_U8P(p)[6] = (uint8_t) ((n) >> 8U); \
|
||||
MG_U8P(p)[7] = (uint8_t) (n); \
|
||||
} while (0)
|
||||
|
||||
// Network / host byte-order conversion (big-endian <-> native).
|
||||
|
||||
+2
-2
@@ -77,7 +77,7 @@ uint8_t *mg_l2_eth_header(struct mg_tcpip_if *ifp, enum mg_l2proto proto,
|
||||
qtag->tpid = mg_htons(0x8100);
|
||||
qtag->tci = mg_htons(d->vlan_id); // PCP = default (best-effort)
|
||||
hlp += sizeof(*qtag);
|
||||
*(uint16_t *) (qtag + 1) = mg_htons(eth_types[(unsigned int) proto]);
|
||||
MG_STORE_BE16(qtag + 1, eth_types[(unsigned int) proto]);
|
||||
}
|
||||
return hlp;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ bool mg_l2_eth_rx(struct mg_tcpip_if *ifp, enum mg_l2proto *proto,
|
||||
if (qtag->tpid != mg_htons(0x8100)) return false; // Untagged frame
|
||||
if (mg_ntohs(VLAN_ID(qtag->tci)) != VLAN_ID(d->vlan_id))
|
||||
return false; // Not our VLAN
|
||||
type = mg_ntohs(*(uint16_t *) (qtag + 1));
|
||||
type = MG_LOAD_BE16(qtag + 1);
|
||||
}
|
||||
if (ifp->enable_mac_check &&
|
||||
memcmp(eth->dst, ifp->mac, sizeof(eth->dst)) != 0 &&
|
||||
|
||||
+9
-5
@@ -848,7 +848,7 @@ static void rx_ndp_na(struct mg_tcpip_if *ifp, struct pkt *pkt) {
|
||||
uint8_t len = *opts++; // check valid hwaddr and get it
|
||||
if (!mg_l2_ip6get(ifp->l2type, s->mac, opts, len)) return;
|
||||
MG_DEBUG(("%lu NDP resolved %M -> %M", c->id, mg_print_ip6,
|
||||
&c->rem.addr.ip6, mg_print_mac, ifp->l2type, s->mac));
|
||||
&c->rem.addr.ip6, mg_print_l2addr, ifp->l2type, s->mac));
|
||||
c->is_arplooking = 0;
|
||||
l2addr_resolved(c);
|
||||
}
|
||||
@@ -983,12 +983,12 @@ static void rx_ndp_ra(struct mg_tcpip_if *ifp, struct pkt *pkt) {
|
||||
gotl2addr = true;
|
||||
} else if (type == 5 && length >= 8) {
|
||||
// process MTU if available
|
||||
mtu = mg_ntohl(*(uint32_t *) (opts + 4));
|
||||
mtu = MG_LOAD_BE32(opts + 4);
|
||||
} else if (type == 3 && length >= 32) {
|
||||
// process prefix, 4.6.2
|
||||
uint8_t pfx_flags = opts[3]; // L=0x80, A=0x40
|
||||
uint32_t valid = mg_ntohl(*(uint32_t *) (opts + 4));
|
||||
uint32_t pref_lifetime = mg_ntohl(*(uint32_t *) (opts + 8));
|
||||
uint32_t valid = MG_LOAD_BE32(opts + 4);
|
||||
uint32_t pref_lifetime = MG_LOAD_BE32(opts + 8);
|
||||
prefix_len = opts[2];
|
||||
prefix = opts + 16;
|
||||
|
||||
@@ -2119,7 +2119,11 @@ void mg_connect_resolved(struct mg_connection *c) {
|
||||
c->loc.port = mg_htons(ifp->eport++);
|
||||
#if MG_ENABLE_IPV6
|
||||
if (c->rem.is_ip6) {
|
||||
c->loc.addr.ip6[0] = ifp->ip6[0], c->loc.addr.ip6[1] = ifp->ip6[1],
|
||||
if(c->rem.addr.ip6[0] == ifp->ip6ll[0]) { // same local LAN, use ll
|
||||
c->loc.addr.ip6[0] = ifp->ip6ll[0], c->loc.addr.ip6[1] = ifp->ip6ll[1];
|
||||
} else { // use global address
|
||||
c->loc.addr.ip6[0] = ifp->ip6[0], c->loc.addr.ip6[1] = ifp->ip6[1];
|
||||
}
|
||||
c->loc.is_ip6 = true;
|
||||
} else
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ size_t mg_print_ip4(mg_pfn_t, void *arg, va_list *ap); // expects: uint32_t
|
||||
size_t mg_print_ip6(mg_pfn_t, void *arg, va_list *ap); // expects: uint8_t[16] ipv6
|
||||
size_t mg_print_mac(mg_pfn_t, void *arg, va_list *ap); // expects: uint8_t[6] mac
|
||||
size_t mg_print_ieee64(mg_pfn_t, void *arg, va_list *ap); // expects: uint64_t
|
||||
size_t mg_print_l2addr(mg_pfn_t, void *arg, va_list *ap); // expects: const struct mg_addr *
|
||||
size_t mg_print_l2addr(mg_pfn_t, void *arg, va_list *ap); // expects: uint8_t l2, uint8_t[n] n-byte l2-dependent address
|
||||
|
||||
// Output functions for use as the fn argument to mg_xprintf/mg_vxprintf.
|
||||
void mg_pfn_iobuf(char ch, void *param); // param: struct mg_iobuf * (resizes as needed)
|
||||
|
||||
+25
-25
@@ -96,34 +96,34 @@ void mg_delayms(unsigned int ms);
|
||||
|
||||
// Write a native integer to byte pointer p in big-endian byte order.
|
||||
// Safe on architectures that forbid unaligned access.
|
||||
#define MG_STORE_BE16(p, n) \
|
||||
do { \
|
||||
MG_U8P(p)[0] = ((n) >> 8U) & 255; \
|
||||
MG_U8P(p)[1] = (n) &255; \
|
||||
#define MG_STORE_BE16(p, n) \
|
||||
do { \
|
||||
MG_U8P(p)[0] = (uint8_t) ((n) >> 8U); \
|
||||
MG_U8P(p)[1] = (uint8_t) (n); \
|
||||
} while (0)
|
||||
#define MG_STORE_BE24(p, n) \
|
||||
do { \
|
||||
MG_U8P(p)[0] = ((n) >> 16U) & 255; \
|
||||
MG_U8P(p)[1] = ((n) >> 8U) & 255; \
|
||||
MG_U8P(p)[2] = (n) &255; \
|
||||
#define MG_STORE_BE24(p, n) \
|
||||
do { \
|
||||
MG_U8P(p)[0] = (uint8_t) ((n) >> 16U); \
|
||||
MG_U8P(p)[1] = (uint8_t) ((n) >> 8U); \
|
||||
MG_U8P(p)[2] = (uint8_t) (n); \
|
||||
} while (0)
|
||||
#define MG_STORE_BE32(p, n) \
|
||||
do { \
|
||||
MG_U8P(p)[0] = ((n) >> 24U) & 255; \
|
||||
MG_U8P(p)[1] = ((n) >> 16U) & 255; \
|
||||
MG_U8P(p)[2] = ((n) >> 8U) & 255; \
|
||||
MG_U8P(p)[3] = (n) &255; \
|
||||
#define MG_STORE_BE32(p, n) \
|
||||
do { \
|
||||
MG_U8P(p)[0] = (uint8_t) ((n) >> 24U); \
|
||||
MG_U8P(p)[1] = (uint8_t) ((n) >> 16U); \
|
||||
MG_U8P(p)[2] = (uint8_t) ((n) >> 8U); \
|
||||
MG_U8P(p)[3] = (uint8_t) (n); \
|
||||
} while (0)
|
||||
#define MG_STORE_BE64(p, n) \
|
||||
do { \
|
||||
MG_U8P(p)[0] = ((n) >> 56U) & 255; \
|
||||
MG_U8P(p)[1] = ((n) >> 48U) & 255; \
|
||||
MG_U8P(p)[2] = ((n) >> 40U) & 255; \
|
||||
MG_U8P(p)[3] = ((n) >> 32U) & 255; \
|
||||
MG_U8P(p)[4] = ((n) >> 24U) & 255; \
|
||||
MG_U8P(p)[5] = ((n) >> 16U) & 255; \
|
||||
MG_U8P(p)[6] = ((n) >> 8U) & 255; \
|
||||
MG_U8P(p)[7] = (n) &255; \
|
||||
#define MG_STORE_BE64(p, n) \
|
||||
do { \
|
||||
MG_U8P(p)[0] = (uint8_t) ((n) >> 56U); \
|
||||
MG_U8P(p)[1] = (uint8_t) ((n) >> 48U); \
|
||||
MG_U8P(p)[2] = (uint8_t) ((n) >> 40U); \
|
||||
MG_U8P(p)[3] = (uint8_t) ((n) >> 32U); \
|
||||
MG_U8P(p)[4] = (uint8_t) ((n) >> 24U); \
|
||||
MG_U8P(p)[5] = (uint8_t) ((n) >> 16U); \
|
||||
MG_U8P(p)[6] = (uint8_t) ((n) >> 8U); \
|
||||
MG_U8P(p)[7] = (uint8_t) (n); \
|
||||
} while (0)
|
||||
|
||||
// Network / host byte-order conversion (big-endian <-> native).
|
||||
|
||||
+35
-5
@@ -219,7 +219,12 @@ static int fetch(struct mg_mgr *mgr, char *buf, const char *url,
|
||||
static void test_http_client(struct mg_mgr *mgr) {
|
||||
char buf[FETCH_BUF_SIZE];
|
||||
int rc = 0;
|
||||
const bool ipv6 = MG_ENABLE_IPV6;
|
||||
const bool ipv6 =
|
||||
#ifdef IPV6_NOROUTING
|
||||
0; // GitHub does not route IPv6 (as far as I can tell)
|
||||
#else
|
||||
MG_ENABLE_IPV6;
|
||||
#endif
|
||||
#if MG_TLS
|
||||
if (ipv6) {
|
||||
rc = fetch(mgr, buf, "https://ipv6.google.com",
|
||||
@@ -350,6 +355,7 @@ static void test_mqtt_connsubpub(struct mg_mgr *mgr) {
|
||||
data.url = strdup(MQTT_URL);
|
||||
#endif
|
||||
#endif // MG_TLS
|
||||
mg_mgr_poll(mgr, 0); // update interface timing
|
||||
s_conn = mg_mqtt_connect(mgr, data.url, &opts, mqtt_fn, &data);
|
||||
ASSERT(s_conn != NULL);
|
||||
for (int i = 0; i < 1000 && s_conn != NULL && !s_conn->is_closing; i++) {
|
||||
@@ -359,16 +365,40 @@ static void test_mqtt_connsubpub(struct mg_mgr *mgr) {
|
||||
ASSERT(data.passed);
|
||||
mg_mgr_poll(mgr, 0);
|
||||
free(data.url);
|
||||
|
||||
#if 0
|
||||
#if defined(MQTT_HOST) && MG_ENABLE_IPV6
|
||||
#if MG_ENABLE_IPV6 && defined(MQTT_HOST) && MG_TLS != MG_TLS_BUILTIN
|
||||
if (host_ip6 == NULL) {
|
||||
printf("\nMQTT_HOST defined but no HOST_IPV6 provided, skipping MQTT IPV6 tests\n");
|
||||
return;
|
||||
}
|
||||
printf("HOST_IPV6: %s\n", host_ip6);
|
||||
data.url = mg_mprintf("mqtt://[%s]:1883", host_ip6);
|
||||
#if MG_TLS
|
||||
#if MG_TLS != MG_TLS_BUILTIN
|
||||
#if defined(MQTT_HOST)
|
||||
data.url = mg_mprintf("mqtts://[%s]:8883", host_ip6);
|
||||
#else
|
||||
printf("\nMQTT[S] tests over IPv6 require MQTT_HOST, skipping\n");
|
||||
return;
|
||||
//data.url = strdup(MQTTS_URL);
|
||||
#endif
|
||||
#else // MG_TLS != MG_TLS_BUILTIN
|
||||
#if defined(MQTT_HOST)
|
||||
printf("\nAssuming MQTT_HOST is NOT 1.3, ignoring it for MQTTS tests\n");
|
||||
printf("\nMQTT[S] tests over IPv6 require MQTT_HOST, skipping\n");
|
||||
return;
|
||||
#endif
|
||||
printf("\nMQTT[S] tests over IPv6 require MQTT_HOST, skipping\n");
|
||||
return;
|
||||
//data.url = strdup(MQTTS_URL);
|
||||
#endif
|
||||
#else // MG_TLS
|
||||
#ifdef MQTT_HOST
|
||||
data.url = mg_mprintf("mqtt://[%s]:1883", host_ip6);
|
||||
#else
|
||||
printf("\nMQTT[S] tests over IPv6 require MQTT_HOST, skipping\n");
|
||||
return;
|
||||
//data.url = strdup(MQTT_URL);
|
||||
#endif
|
||||
#endif // MG_TLS
|
||||
data.passed = false;
|
||||
s_conn = mg_mqtt_connect(mgr, data.url, &opts, mqtt_fn, &data);
|
||||
ASSERT(s_conn != NULL);
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
interface mg_bridge0
|
||||
{
|
||||
AdvSendAdvert on;
|
||||
AdvRASrcAddress {
|
||||
fe80::01ff:fe02:0301;
|
||||
};
|
||||
prefix 2001:db8:1:0::/64 {
|
||||
AdvOnLink on;
|
||||
AdvAutonomous on;
|
||||
};
|
||||
};
|
||||
+31
-14
@@ -1,10 +1,14 @@
|
||||
#!/bin/sh
|
||||
# Use separate addresses for gateway, DHCP, and host, in order to force using ARP and ND
|
||||
BRIDGE=mg_bridge0
|
||||
BRIDGE_BROADCAST=192.168.32.255
|
||||
BRIDGE_IP=192.168.32.1
|
||||
BRIDGE_IP=192.168.32.2
|
||||
BRIDGE_NETWORK=192.168.32.0/24
|
||||
BRIDGE_MASK=255.255.255.0
|
||||
BRIDGE_IPV6=fe80::01ff:fe02:0301
|
||||
GATEWAY_IP=192.168.32.1 # dhcp.conf serves 192.168.32.1 as gateway
|
||||
HOST_IP=192.168.32.3
|
||||
BRIDGE_IPV6=fe80::01ff:fe02:0301 # radvd.conf uses this address as its own
|
||||
HOST_IPV6=fe80::01ff:fe02:0303
|
||||
# Host outside network interface is 'eth0'
|
||||
TAP=tap0
|
||||
|
||||
@@ -14,20 +18,26 @@ timeout 1s ifconfig
|
||||
timeout 1s sudo route -n # see our gateway
|
||||
timeout 1s bridge link
|
||||
timeout 1s bridge fdb
|
||||
timeout 1s sudo ip -6 route show
|
||||
echo
|
||||
|
||||
# Package installation
|
||||
echo "Package installation"
|
||||
sudo apt-get -y install isc-dhcp-server net-tools
|
||||
# sudo apt-get -y install build-essential sshpassecho "Network configuration script: Bridge"
|
||||
sudo apt-get -y install isc-dhcp-server net-tools radvd
|
||||
sudo systemctl stop radvd # just in case they think it is cool to start it
|
||||
# sudo apt-get -y install build-essential sshpass
|
||||
echo
|
||||
|
||||
echo "Network configuration script: Bridge"
|
||||
sudo ip link add $BRIDGE type bridge # Create brige
|
||||
sudo ifconfig $BRIDGE $BRIDGE_IP netmask $BRIDGE_MASK up
|
||||
sudo ifconfig $BRIDGE:1 $GATEWAY_IP netmask $BRIDGE_MASK up
|
||||
sudo ifconfig $BRIDGE:2 $HOST_IP netmask $BRIDGE_MASK up
|
||||
sudo ip -6 addr add $BRIDGE_IPV6/64 dev $BRIDGE
|
||||
sudo ip -6 addr add $HOST_IPV6/64 dev $BRIDGE:1
|
||||
echo
|
||||
|
||||
echo "Network configuration script: TAP"
|
||||
sudo ip link add $BRIDGE type bridge # Create brige
|
||||
sudo ifconfig $BRIDGE $BRIDGE_IP netmask $BRIDGE_MASK up
|
||||
sudo ip -6 addr add $BRIDGE_IPV6/64 dev $BRIDGE
|
||||
echo
|
||||
|
||||
echo "Create $TAP attached to $BRIDGE"
|
||||
sudo ip tuntap add dev $TAP mode tap # Create tuntap
|
||||
sudo ip link set $TAP master $BRIDGE # Link tap-bridge
|
||||
@@ -51,12 +61,11 @@ echo
|
||||
HOST_IFC=$BRIDGE
|
||||
export HOST_IFC
|
||||
echo "Host inside network interface is $BRIDGE"
|
||||
echo
|
||||
|
||||
# Setup DHCP server
|
||||
echo "Network configuration script: DHCP server"
|
||||
echo "Serving from $BRIDGE_IP"
|
||||
HOST_IP=$BRIDGE_IP
|
||||
export HOST_IP
|
||||
echo "Serving from $BRIDGE_IP, gateway should be $GATEWAY_IP"
|
||||
echo "dhcpd.conf:"
|
||||
cat test/dhcpd.conf
|
||||
echo
|
||||
@@ -64,9 +73,14 @@ sudo cp test/dhcpd.conf /etc/dhcp/dhcpd.conf
|
||||
sudo chmod a+w /var/lib/dhcp/*
|
||||
sudo dhcpd mg_bridge0 &
|
||||
echo
|
||||
HOST_IPV6=$BRIDGE_IPV6
|
||||
echo "radvd listening at $BRIDGE_IPV6"
|
||||
sudo ip link set $BRIDGE up # there's no physical port, so we need to set link up for radvd to work
|
||||
sudo radvd -n -d 5 -C test/radvd.conf &
|
||||
echo
|
||||
echo "Host listening at $HOST_IP and $HOST_IPV6"
|
||||
export HOST_IP
|
||||
export HOST_IPV6
|
||||
echo "Listening at $BRIDGE_IPV6"
|
||||
echo
|
||||
|
||||
# Do we have connectivity ?
|
||||
echo "Check connectivity:"
|
||||
@@ -74,6 +88,8 @@ wget https://cesanta.com/robots.txt
|
||||
echo robots.txt:
|
||||
cat robots.txt
|
||||
rm robots.txt
|
||||
wget https://ipv6.google.com/
|
||||
rm index.html
|
||||
echo
|
||||
|
||||
# Confirm OK
|
||||
@@ -82,3 +98,4 @@ timeout 1s ifconfig
|
||||
timeout 1s sudo route -n
|
||||
timeout 1s bridge fdb
|
||||
timeout 1s bridge link
|
||||
timeout 1s sudo ip -6 route show
|
||||
|
||||
Reference in New Issue
Block a user