diff options
| author | Roy Marples <roy@marples.name> | 2019-12-17 22:23:56 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2019-12-17 22:23:56 +0000 |
| commit | ad9b095053e66fc12284a42a3a643ef145192875 (patch) | |
| tree | 2264d86dfc0deb4657bd6591ede41b15500e5ef1 | |
| parent | 9b8fa49e98cf94e268131e5119a59b406fc34108 (diff) | |
| download | dhcpcd-ad9b095053e66fc12284a42a3a643ef145192875.tar.xz | |
DHCP6: Add disabled code to allow packet replay
I get bored of adding similar code from time to time just to
aid debugging, so let's just add it in.
Someone else might find it useful too.
| -rw-r--r-- | src/dhcp6.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/dhcp6.c b/src/dhcp6.c index ed5fe8d6..8fb5184e 100644 --- a/src/dhcp6.c +++ b/src/dhcp6.c @@ -3635,6 +3635,42 @@ dhcp6_recv(struct dhcpcd_ctx *ctx, struct ipv6_addr *ia) ifp = ifp1; } +#if 0 + /* + * Handy code to inject raw DHCPv6 packets over responses + * from our server. + * This allows me to take a 3rd party wireshark trace and + * replay it in my code. + */ + static int replyn = 0; + char fname[PATH_MAX], tbuf[64 * 1024]; + int fd; + ssize_t tlen; + uint8_t *si1, *si2; + uint16_t si_len1, si_len2; + + snprintf(fname, sizeof(fname), + "/tmp/dhcp6.reply%d.raw", replyn++); + fd = open(fname, O_RDONLY, 0); + if (fd == -1) { + logerr("%s: open `%s'", __func__, fname); + return; + } + tlen = read(fd, tbuf, sizeof(tbuf)); + if (tlen == -1) + logerr("%s: read `%s'", __func__, fname); + close(fd); + + /* Copy across ServerID so we can work with our own server. */ + si1 = dhcp6_findmoption(r, len, D6_OPTION_SERVERID, &si_len1); + si2 = dhcp6_findmoption(tbuf, (size_t)tlen, + D6_OPTION_SERVERID, &si_len2); + if (si1 != NULL && si2 != NULL && si_len1 == si_len2) + memcpy(si2, si1, si_len2); + r = (struct dhcp6_message *)tbuf; + len = (size_t)tlen; +#endif + dhcp6_recvif(ifp, sfrom, r, len); } |
