-
Notifications
You must be signed in to change notification settings - Fork 911
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
WIP ZONEVERSION (RFC9660) support #14818
base: master
Are you sure you want to change the base?
Changes from all commits
e821cdd
5aaaf40
57eed0d
59e2b52
c8eab61
b38708a
c8d903d
b6cc735
a5c5ad8
496d869
cb0c75f
9e99aa6
edfd25b
e532c0c
742399a
6331f1e
17206b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* This file is part of PowerDNS or dnsdist. | ||
* Copyright -- PowerDNS.COM B.V. and its contributors | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of version 2 of the GNU General Public License as | ||
* published by the Free Software Foundation. | ||
* | ||
* In addition, for the avoidance of any doubt, permission is granted to | ||
* link this program with OpenSSL and to (re)distribute the binaries | ||
* produced as the result of such linking. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
#ifdef HAVE_CONFIG_H | ||
#include "config.h" | ||
#endif | ||
#include "ednszoneversion.hh" | ||
#include "dns.hh" | ||
|
||
namespace | ||
{ | ||
struct EDNSZoneVersionWire | ||
{ | ||
uint8_t labelcount; | ||
uint8_t type; | ||
char version[256]; // FIXME they can be bigger | ||
Check notice Code scanning / CodeQL FIXME comment Note
FIXME comment: they can be bigger
|
||
} GCCPACKATTRIBUTE; // BRRRRR | ||
|
||
} | ||
|
||
bool getEDNSZoneVersionFromString(const string& options, EDNSZoneVersion& zoneversion) | ||
{ | ||
// cerr<<"options.size:"<<options.size()<<endl; | ||
Check notice Code scanning / CodeQL Commented-out code Note
This comment appears to contain commented-out code.
|
||
return getEDNSZoneVersionFromString(options.c_str(), options.length(), zoneversion); | ||
} | ||
|
||
bool getEDNSZoneVersionFromString(const char* options, unsigned int len, EDNSZoneVersion& zoneversion) | ||
{ | ||
EDNSZoneVersionWire zoneversionw{}; | ||
// static_assert(sizeof(zoneversionw) == 4, "sizeof(EDNSSubnetOptsWire) must be 4 bytes"); | ||
Check notice Code scanning / CodeQL Commented-out code Note
This comment appears to contain commented-out code.
|
||
if (len > sizeof(zoneversionw)) { | ||
return false; // FIXME this silently breaks on >256 bytes of version | ||
Check notice Code scanning / CodeQL FIXME comment Note
FIXME comment: this silently breaks on >256 bytes of version
|
||
} | ||
if (len < (1 + 1 + 4)) { | ||
return false; // does not contain labelcount + type + uint32_t version | ||
} | ||
memcpy(&zoneversionw, options, len); | ||
zoneversion.labelcount = zoneversionw.labelcount; | ||
zoneversion.type = zoneversionw.type; | ||
|
||
memcpy(&zoneversion.version, zoneversionw.version, sizeof(zoneversion.version)); | ||
zoneversion.version = ntohl(zoneversion.version); | ||
|
||
return true; | ||
} | ||
|
||
string makeEDNSZoneVersionString(const EDNSZoneVersion& zoneversion) | ||
{ | ||
string ret; | ||
EDNSZoneVersionWire zoneversionw{}; | ||
zoneversionw.labelcount = zoneversion.labelcount; | ||
zoneversionw.type = zoneversion.type; | ||
|
||
uint32_t version = htonl(zoneversion.version); | ||
memcpy(&zoneversionw.version, &version, sizeof(zoneversion.version)); | ||
|
||
ret.assign((const char*)&zoneversionw, 1 + 1 + 4); | ||
|
||
return ret; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* This file is part of PowerDNS or dnsdist. | ||
* Copyright -- PowerDNS.COM B.V. and its contributors | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of version 2 of the GNU General Public License as | ||
* published by the Free Software Foundation. | ||
* | ||
* In addition, for the avoidance of any doubt, permission is granted to | ||
* link this program with OpenSSL and to (re)distribute the binaries | ||
* produced as the result of such linking. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
#pragma once | ||
#include "namespaces.hh" | ||
#include "iputils.hh" | ||
#include "dnsname.hh" | ||
|
||
struct EDNSZoneVersion | ||
{ | ||
static const size_t EDNSZoneVersionOptSize = 1 + 1 + 4; // used for upper bound size calculation in dnspacket, assumes versions are 4 bytes | ||
|
||
uint8_t labelcount; | ||
uint8_t type; | ||
uint32_t version; // this assumes all versions fit in uint32_t. RFC9660 does not promise that. | ||
}; | ||
|
||
bool getEDNSZoneVersionFromString(const string& options, EDNSZoneVersion& zoneversion); | ||
bool getEDNSZoneVersionFromString(const char* options, unsigned int len, EDNSZoneVersion& zoneversion); | ||
string makeEDNSZoneVersionString(const EDNSZoneVersion& zoneversion); |
Check notice
Code scanning / CodeQL
FIXME comment Note