# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0.  If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Copyright 1997 - July 2008 CWI, August 2008 - 2016 MonetDB B.V.

atom inet:lng;

command null()
address INETnull;
command cmp()
address INETcompare;
command fromstr()
address INETfromString
comment "Convert a string to an inet";
command tostr()
address INETtoString
comment "Convert inet to string equivalent";
command new(s:str):inet
address INETnew
comment "Create an inet from a string literal";
command isnil(v:inet):bit
address INET_isnil
comment "Nil test for inet value";
command =(v:inet,w:inet):bit
address INET_comp_EQ
comment "Equality of two inets";
command !=(v:inet,w:inet):bit
address INET_comp_NEQ
comment "Inequality of two inets";
command <(v:inet,w:inet):bit
address INET_comp_LT
comment "Whether v is less than w";
command >(v:inet,w:inet):bit
address INET_comp_GT
comment "Whether v is greater than w";
command <=(v:inet,w:inet):bit
address INET_comp_LE
comment "Whether v is less than or equal to w";
command >=(v:inet,w:inet):bit
address INET_comp_GE
comment "Whether v is equal to or greater than w";
command <<(v:inet,w:inet):bit
address INET_comp_CW
comment "Whether v is contained within w";
command <<=(v:inet,w:inet):bit
address INET_comp_CWE
comment "Whether v is contained within or is equal to w";
command >>(v:inet,w:inet):bit
address INET_comp_CS
comment "Whether v contains w";
command >>=(v:inet,w:inet):bit
address INET_comp_CSE
comment "Whether v contains or is equal to w";
command broadcast(:inet):inet
address INETbroadcast
comment "Returns the broadcast address for network";
command host(:inet):str
address INEThost
comment "Extract IP address as text";
command masklen(:inet):int
address INETmasklen
comment "Extract netmask length";
command setmasklen(:inet,:int):inet
address INETsetmasklen
comment "Set netmask length for inet value";
command netmask(:inet):inet
address INETnetmask
comment "Construct netmask for network";
command hostmask(:inet):inet
address INEThostmask
comment "Construct host mask for network";
command network(:inet):inet
address INETnetwork
comment "Extract network part of address";
command text(:inet):str
address INETtext
comment "Extract IP address and netmask length as text";
command abbrev(:inet):str
address INETabbrev
comment "Abbreviated display format as text";

module calc;

command inet(s:inet):inet
address INET_inet
comment "Convert a inet to an inet";

command inet(s:str):inet
address INET_fromstr
comment "Convert a string to an inet";

command ==(v:inet,w:inet):bit
address INET_comp_EQ
comment "Equality of two inets";

command !=(v:inet,w:inet):bit
address INET_comp_NEQ
comment "Inequality of two inets";

command <(v:inet,w:inet):bit
address INET_comp_LT
comment "Whether v is less than w";

command >(v:inet,w:inet):bit
address INET_comp_GT
comment "Whether v is greater than w";

command <=(v:inet,w:inet):bit
address INET_comp_LE
comment "Whether v is less than or equal to w";

command >=(v:inet,w:inet):bit
address INET_comp_GE
comment "Whether v is equal to or greater than w";
