File tree 1 file changed +13
-1
lines changed
ydb/library/yql/udfs/common/ip_base/lib
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -335,6 +335,17 @@ namespace {
335
335
return valueBuilder->NewString (SerializeAddress (beg));
336
336
}
337
337
338
+ SIMPLE_UDF (TGetSubnetByMask, char *(TAutoMapString, TAutoMapString)) {
339
+ const auto refBase = args[0 ].AsStringRef ();
340
+ const auto refMask = args[1 ].AsStringRef ();
341
+ TIpv6Address addrBase = DeserializeAddress (refBase);
342
+ TIpv6Address addrMask = DeserializeAddress (refMask);
343
+ if (addrBase.Type () != addrMask.Type ()) {
344
+ ythrow yexception () << " Base and mask differ in length" ;
345
+ }
346
+ return valueBuilder->NewString (SerializeAddress (TIpv6Address (ui128 (addrBase) & ui128 (addrMask), addrBase.Type ())));
347
+ }
348
+
338
349
#define EXPORTED_IP_BASE_UDF \
339
350
TFromString, \
340
351
TSubnetFromString, \
@@ -345,5 +356,6 @@ namespace {
345
356
TIsEmbeddedIPv4, \
346
357
TConvertToIPv6, \
347
358
TGetSubnet, \
348
- TSubnetMatch
359
+ TSubnetMatch, \
360
+ TGetSubnetByMask
349
361
}
You can’t perform that action at this time.
0 commit comments