Dibbler - a portable DHCPv6  1.0.2RC1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
lexfn.cpp File Reference
#include <ctype.h>
#include "dnsmessage.h"
#include "domainfn.h"
#include "sysstring.h"
#include "rr.h"
#include "exception.h"
#include "lexfn.h"
#include "Portable.h"
+ Include dependency graph for lexfn.cpp:

Macros

#define hexfromint(hex)   (((hex) < 10) ? (hex) + '0' : ((hex) - 10) + 'a')
#define R_ANY   3
#define R_IP4   0
#define R_IP6   1
#define R_NONE   2

Functions

bool addrrange_matches (const unsigned char *iprange, _addr *a)
 Checks for range matches.
int hextoint (char val)
bool in_addr_list (std::list< _addr > &lst, _addr *a, bool match_port)
 looks item up in address list
bool in_addrrange_list (std::list< addrrange > &lst, _addr *a)
 looks item up in match list
std::string intstring (u_int16 x)
bool ip6range_matches (const unsigned char *iprange, const unsigned char *ip)
 Checks for IPv6 ranges.
bool iprange_matches (const unsigned char *iprange, const unsigned char *ip)
 Checks for IPv4 ranges.
std::string pos_degtostring (unsigned int val, char plus, char min)
u_int32 poslib_degstr (char *&src, char pre, char post)
unsigned char poslib_loc_precision (const char *str)
int power10ed (unsigned char val)
std::string str_class (u_int16 ctype)
std::string str_degrees (unsigned int value, char pos, char neg)
std::string str_loc (const unsigned char *locrr)
std::string str_opcode (u_int16 opcode)
std::string str_qclass (u_int16 qctype)
std::string str_qtype (u_int16 qtype)
std::string str_rcode (int rcode)
std::string str_ttl (unsigned int ttl)
std::string str_type (u_int16 type)
void txt_to_addr (_addr *ret, const char *addr, int default_port, bool is_client)
 convert text to address
void txt_to_addrrange (unsigned char *iprange, const char *val)
 Convert text to an address range.
bool txt_to_bool (const char *buff)
 convert text to boolean
void txt_to_dname (_domain target, const char *src, _cdomain origin)
 convert text domain name to binary domain name
void txt_to_email (_domain target, const char *src, _cdomain origin)
 convert e-mail address to binary domain name
int txt_to_int (const char *buff)
 convert text to numbers
int txt_to_int_internal (const char *_buff, bool support_negative)
int txt_to_ip (unsigned char ip[4], const char *_buff, bool do_portion)
 convert text to ipv4
void txt_to_ip6range (unsigned char *iprange, const char *val)
void txt_to_iprange (unsigned char *iprange, const char *val)
 Convert text to an IP range.
int txt_to_ipv6 (unsigned char ipv6[16], const char *buff, bool do_portion)
 convert text to ipv6
void txt_to_loc (unsigned char *res, char *&src)
 convert text to LOC RR
int txt_to_negint (const char *buff)
 convert text to numbers
unsigned short txt_to_qclass (const char *str, bool allow_q)
 convert text to DNS class

Variables

char incr_mask [8] = { 0, 128, 192, 224, 240, 248, 252, 254 }

Macro Definition Documentation

#define hexfromint (   hex)    (((hex) < 10) ? (hex) + '0' : ((hex) - 10) + 'a')
#define R_ANY   3
#define R_IP4   0
#define R_IP6   1
#define R_NONE   2

Function Documentation

bool addrrange_matches ( const unsigned char *  iprange,
_addr a 
)

Checks for range matches.

Returns true if the given address number is in the given IP range.

Parameters
iprangeThe address range
aThe address
Returns
true if the ip is within the range
See Also
txt_to_addrrange
int hextoint ( char  val)
bool in_addr_list ( std::list< _addr > &  lst,
_addr a,
bool  match_port = false 
)

looks item up in address list

This function returns true if the given address is one of the addresses in the address match list.

Parameters
lstAddress list
aAddress to check
match_portWhether the port should also match
Returns
true if the address matches one of the items in the list
bool in_addrrange_list ( std::list< addrrange > &  lst,
_addr a 
)

looks item up in match list

This function returns true if the given address matches one of the address match items of the address match list.

Parameters
lstAddress range list
aAddress to check
Returns
true if the address matches one of the items in the list
std::string intstring ( u_int16  x)

Converts int to string

bool ip6range_matches ( const unsigned char *  iprange,
const unsigned char *  ip 
)

Checks for IPv6 ranges.

Returns true if the given IPv6 number is in the given IP range.

Parameters
iprangeThe IPv6 range
ipThe IPv6 number
Returns
true if the ip is within the range
See Also
txt_to_ipv6, txt_to_ip6range
bool iprange_matches ( const unsigned char *  iprange,
const unsigned char *  ip 
)

Checks for IPv4 ranges.

Returns true if the given IP number is in the given IP range.

Parameters
iprangeThe IP range
ipThe IPv4 number
Returns
true if the ip is within the range
See Also
txt_to_ip, txt_to_iprange
std::string pos_degtostring ( unsigned int  val,
char  plus,
char  min 
)
u_int32 poslib_degstr ( char *&  src,
char  pre,
char  post 
)
unsigned char poslib_loc_precision ( const char *  str)
int power10ed ( unsigned char  val)
std::string str_class ( u_int16  ctype)

Returns string representation for the RR CLASS.

< Internet class

< CSNET class

< Chaos class

< Hesiod class

std::string str_degrees ( unsigned int  value,
char  pos,
char  neg 
)
std::string str_loc ( const unsigned char *  rr)

Returns string representation for a LOC RR

std::string str_opcode ( u_int16  opcode)

Returns string representation for the OPCODE.

< Normal query

< Inverse query (deprecated)

< Status request

< Completion query (deprecated)

< Notification message

< DNS update message

std::string str_qclass ( u_int16  qctype)

Returns string representation for the QCLASS.

< All classes

< No class (for DNS update)

std::string str_qtype ( u_int16  qtype)

Returns string representation for the QTYPE.

< Complete Zone Transfer QTYPE

< Incremental Zone Transfer QTYPE

< Mailbox-related RRs QTYPE (experimental)

< Mail agent RRs QTYPE (deprecated)

< All RR types QTYPE

< No RR (DNS update)

std::string str_rcode ( int  rcode)

Returns string representation for the RCODE.

< No error

< Error in query

< Server failure

< Domain name doesn't exist

< Feature not implemented

< Action refused

< Domain name should'nt exist (DNS Update)

< RRset shouldn't exist (DNS Update)

< RRset doesn't exist (DNS Update)

< Not authoritative when required

< Domain name not in zone

< Bad signature

< Bad key

< Bad sign time

std::string str_ttl ( unsigned int  ttl)

Returns string representation for the ttl (e.g. 2h1m)

std::string str_type ( u_int16  type)

Returns string representation for the RR type.

void txt_to_addr ( _addr ret,
const char *  addr,
int  default_port,
bool  is_client 
)

convert text to address

Converts the text pointed to by addr to an _addr address structure. If the client parameter is set to true, the default IP is 127.0.0.1, else it is 0.0.0.0 . Addresses can be given by only an address, only a port, or a combination separated by a # . Being based on the txt_to_ip and txt_to_ipv6 functions, this function also supports the literval values any , local, :any and :local .

Parameters
retMemory to store result in
addrText describing the address
default_portDefault port if none is given
is_clientInfluences default address
Parameters
default_portDefault port for DNS.
void txt_to_addrrange ( unsigned char *  iprange,
const char *  val 
)

Convert text to an address range.

Converts the buffer to an address IP range, in the form of ip[/nsig].

Parameters
iprangeResult buffer (should be of size sz_addrrange).
valString value describing the range
bool txt_to_bool ( const char *  buff)

convert text to boolean

Converts text to a boolean value. The following positive values are supported: yes true 1 on yo absolutely . The following negative values are supported: no false 0 off nope never .

Parameters
buffBuffer containing boolean
Returns
Either true or false.
void txt_to_dname ( _domain  target,
const char *  src,
_cdomain  origin = NULL 
)

convert text domain name to binary domain name

Converts the domain name or in src to a binary domain name.

Parameters
targetTarget
srcSource
originOrigin for relative domain names
void txt_to_email ( _domain  target,
const char *  src,
_cdomain  origin = NULL 
)

convert e-mail address to binary domain name

Converts the domain name or email address in src to a binary domain name.

Parameters
targetTarget
srcSource
originOrigin for relative domain names
int txt_to_int ( const char *  buff)

convert text to numbers

Converts text to a number. This function uses postfix operators. It doesn't support negative numbers.

Parameters
buffBuffer containing text
Returns
Numeric value of the buffer
See Also
txt_to_negint
int txt_to_int_internal ( const char *  _buff,
bool  support_negative 
)
int txt_to_ip ( unsigned char  ip[4],
const char *  buff,
bool  do_portion = false 
)

convert text to ipv4

Converts the text to an IPv4 address. As an extension, Poslib also supports the literal any value, which maps to 0.0.0.0 and the local value, which maps to 127.0.0.1 .

Parameters
ipTarget
buffSource
do_portionIf true, also accept portions such as 192.*.
Returns
The number of nodes of the address (4 for a complete one)
void txt_to_ip6range ( unsigned char *  iprange,
const char *  val 
)
void txt_to_iprange ( unsigned char *  iprange,
const char *  val 
)

Convert text to an IP range.

Converts the buffer to an IPv4 IP range, in the form of ip[/nsig].

Parameters
iprangeResult buffer (should be of size sz_iprange).
valString value describing the range
int txt_to_ipv6 ( unsigned char  ipv6[16],
const char *  buff,
bool  do_portion = false 
)

convert text to ipv6

Converts the text to an IPv6 address. As an extension, Poslib also supports the literal :any value, mapping to ::0 and the :local value, mapping to ::1 .

Parameters
ipv6Target
buffSource
do_portionIf true, also accepts portions such as dead:beef:*
Returns
The number of nodes of the address (16 for a complete one)
void txt_to_loc ( unsigned char *  res,
char *&  src 
)

convert text to LOC RR

Converts the text pointed to by rr to LOC information as described in RFC 1876.

Parameters
res(used to be: Memory to store result in (should be >= 16 bytes))
src
int txt_to_negint ( const char *  buff)

convert text to numbers

Converts text to a number. This function uses postfix operators, and can also handle negative amounts.

Parameters
buffBuffer containing text
Returns
Numeric value of the buffer
See Also
txt_to_int
unsigned short txt_to_qclass ( const char *  str,
bool  allow_q = true 
)

convert text to DNS class

Converts text to one of the class constants supported by DNS (CLASS_IN, CLASS_HS, CLASS_CH, CLASS_CS), or, if allow_q is set, possibly to a supported QCLASS (CLASS_NONE or CLASS_ANY). Only symbolic constants are allowed; numeric values result in an exception.

Parameters
strString to convert
allow_qWhether to allow QCLASSes (defaults to true)
Returns
A DNS CLASS or QCLASS constant

< Internet class

< CSNET class

< Chaos class

< Hesiod class

< Any class

< No class (for DNS update)

Variable Documentation

char incr_mask[8] = { 0, 128, 192, 224, 240, 248, 252, 254 }