summaryrefslogtreecommitdiff
path: root/lib/prefix.c
AgeCommit message (Collapse)Author
2012-03-23lib: fix endianness bug in prefix.cRenato Westphal
While defining two "maskbytes" arrays for the respective endiannesses, the code was unconditionally using one that only worked on little endian systems. Use preprocessor macros to avoid the somewhat expensive htonl/ntohl macros. From: Renato Westphal <renatowestphal@gmail.com> Signed-off-by: David Lamparter <equinox@diac24.net>
2012-01-08lib: use prefix bit length macrosDenis Ovsienko
2012-01-06general: remove inline qualifiers and move in-header functions to objectsPaul Jakma
* (general) Move functions in headers into files, to be compiled into shared object files. Remove inline qualifier from functions. Let the compiler do the work.
2012-01-02lib: address type-punned pointers in prefix_same()Denis Ovsienko
IPV4_ADDR_SAME() wasn't passed the right union member, this could cause a bug due to strict-aliasing. IPV6_ADDR_SAME() case got its fix before the error could be created by macro upgrade.
2012-01-02lib: fix type-punning in ip_masklen()Denis Ovsienko
ip_masklen() was likely to return incorrect results after being compiled with -fstrict-aliasing (-O2, -O3, -Os)
2012-01-02lib: optimize ip_masklen()Denis Ovsienko
The new implementation makes use of a 64KB mapping table, which makes it possible to compute masklen faster and with constant execution time. The map also allows for additional version of the function, which can detect errors in input argument. The previous implementation had a variable cost of execution, which depended on masklen in a non-linear manner, and at its worst (/31) was 4 times slower, than the new implementation. The only case of old function just slightly outperforming the new one is /0, which is of little practical interest.
2012-01-01Revert "lib: optimize apply_mask_ipv6()"Denis Ovsienko
Experience with IPv4 counterpart of this function suggests, that this way of type-punning is likely to cause errors.
2011-12-13lib: optimize apply_mask_ipv6()Denis Ovsienko
2011-12-13lib: optimize apply_mask_ipv4()Denis Ovsienko
2011-12-13lib: make masklen2ip6() safer and fasterDenis Ovsienko
2011-12-13lib: fix endianness of masklen2ip()Denis Ovsienko
2011-12-13lib: make masklen2ip() safer and fasterDenis Ovsienko
2011-11-21lib: prefix2sockunion, prefix_common_bits helper functionsDavid Lamparter
prefix2sockunion converts a struct prefix* to a union sockunion *; prefix_common_bits counts the number of common bits in the prefix's address part.
2010-12-08lib: prefix.c nano-optimisationPaul Jakma
* lib/prefix.c: (prefix_match) nano-optimisation, let it return early without copying pointers.
2010-10-06bgpd, lib: adopt afi_t and safi_t in several placesMichael Lambert
* bgpd/bgp_attr.c, bgpd/bgp_open.h, bgpd/bgp_route.c, lib/prefix.c, lib/prefix.h: Various integer types were being used where, if we had strict type checking, afi_t and safi_t would be required. Signed-off-by: G.Balaji <balajig81@gmail.com> (cherry picked from commit c8af35ffa2dc79ff7d7ff00b1b61f1f50a100ab6)
2009-12-21lib: make some structures constantStephen Hemminger
* isisd/isis_pdu.c * maskbit: this pre-initialized array is not modified * lib/prefix.c * maskbit: idem * lib/command.c * facility_map: idem * itoa64: idem * default_motd: make local var static * facility_name(): update local var accordingly * facility_match(): idem
2009-08-28lib/trivial: str2prefix checks return of inet_pton in fragile wayPaul Jakma
* prefix.c: (str2prefix_ipv6) inet_pton succesful return is presumed to be 1, rather than the "not zero" the man page describes - seemed fragile.
2005-07-262005-07-26 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs
* prefix.c: (prefix_ipv4_new, prefix_ipv6_new): Call prefix_new to allocate the memory to make sure that all struct prefix pointers point to objects of the same length (avoids memory overruns on struct prefix assignments). (prefix_ipv4_free, prefix_ipv6_free): Simply call prefix_free. It is interesting to note that these functions are never actually called anywhere in the code. Instead prefix_free was already being called directly, despite the previous MTYPE incompatibility. [backport candidate]
2005-07-262005-07-26 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs
* prefix.c: (ip_masklen) While loop should test that 'pnt' pointer is in range before dereferencing it. [backport candidate]
2005-05-062005-05-06 Paul Jakma <paul@dishone.st>paul
* (general) extern and static'ification of functions in code and header. Cleanup any definitions with unspecified arguments. Add casts for callback assignments where the callback is defined, typically, as passing void *, but the function being assigned has some other pointer type defined as its argument, as gcc complains about casts from void * to X* via function arguments. Fix some old K&R style function argument definitions. Add noreturn gcc attribute to some functions, as appropriate. Add unused gcc attribute to some functions (eg ones meant to help while debugging) Add guard defines to headers which were missing them. * command.c: (install_node) add const qualifier, still doesnt shut up the warning though, because of the double pointer. (cmp_node) ditto * keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived fromn vty.h ones to fix some of the (long) < 0 warnings. * thread.c: (various) use thread_empty (cpu_record_hash_key) should cast to uintptr_t, a stdint.h type * vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they removed from ospfd/ospf_vty.h * zebra.h: Move definition of ZEBRA_PORT to here, to remove dependence of lib on zebra/zserv.h
2005-04-08 * prefix.[hc]: Pass argument to the inet6_ntoa by value making it morehasso
inet_ntoa alike. * ripngd.[hc], ripng_interface.c, ripng_peer.c: inet6_ntoa() takes argument now by value.
2005-04-05 * lib/prefix.[hc]: inet6_ntoa utility function copied fromhasso
ripngd/ripngd.c (inet6_ntop). * ripngd.[hc]: Remove inet6_ntop() and any usage of it. inet6_ntoa() from lib is used now. * ripng_interface.c: inet6_ntop() -> inet6_ntoa(). * ripng_peer.c: inet6_ntop() -> inet6_ntoa().
2004-12-082004-12-08 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs
* prefix.c: (prefix_copy) Error message before abort should have severity LOG_ERR, not LOG_INFO. * memory.c: (mtype_log) Log level should be LOG_DEBUG, not LOG_INFO.
2004-10-19OK. Here it is - PtP patch from Andrew J. Schorr. No problems with ospfd,hasso
ripd might need some more testing though.
2004-10-04First small part of lib cleanup. Mainly "constification" of arguments andhasso
adding FIXME's.
2004-01-13Explain the dual use of struct prefix for CIDR prefixes andgdt
address/netmask pairs, and clarify the two comparison functions.
2002-12-13Initial revisionpaul