summaryrefslogtreecommitdiffstats
path: root/lib/prefix.c
Commit message (Collapse)AuthorAgeFilesLines
* lib: add SAFI_ENCAP type, safi2str prefix utilityLou Berger2016-02-261-0/+16
| | | | Signed-off-by: Lou Berger <lberger@labn.net>
* isisd: add support to import routes from other protocolsChristian Franke2015-12-081-0/+11
| | | | Signed-off-by: Christian Franke <chris@opensourcerouting.org>
* lib: make prefix2str simpler to use, and use it in zclientTimo Teräs2015-06-011-3/+4
| | | | | | | | | | | Returning the buffer allows using it in the logging functions in easier way. This also makes the API consistent with sockunion. Add also PREFIX_STRLEN to be the generic buffer length required for any prefix string representation. Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: allow caller to provide prefix storage in sockunion2hostprefixTimo Teräs2015-05-291-3/+3
| | | | | | | Avoids a dynamic allocation which is usually freed immediate afterwards. Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: nuke ^L (page feed)David Lamparter2014-06-041-3/+3
| | | | | | | | | | | | | | Quagga sources have inherited a slew of Page Feed (^L, \xC) characters from ancient history. Among other things, these break patchwork's XML-RPC API because \xC is not a valid character in XML documents. Nuke them from high orbit. Patches can be adapted simply by: sed -e 's%^L%%' -i filename.patch (you can type page feeds in some environments with Ctrl-V Ctrl-L) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: pretty ip_masklen and masklen2ipDavid Lamparter2012-04-041-109/+19
| | | | | | | | | | | | | | nonwithstanding any desire for optimisation, these versions are shorter and more concise. reading the comments, they might even be easier to understand. I've tested them on i686 and x86_64, and checked that correct assembler code is emitted for ARM, MIPS and PowerPC. IPv6 is left as an exercise for another day, none of the ideas I had led to a "yes, this is the one to go with" solution. Signed-off-by: David Lamparter <equinox@diac24.net>
* Revert "lib: optimize ip_masklen()" (BZ#720)David Lamparter2012-04-041-2081/+25
| | | | | | | | | | | This reverts commit d171bf58ef12ace43d48565e6870722dece1e6ed. There are multiple reasons for this revert, including bug #720, but also quite simply the unreadability of having 2000 lines of an autogenerated table in the middle of a source file. Signed-off-by: David Lamparter <equinox@diac24.net> Reported-by: Martin Winter <mwinter@opensourcerouting.org>
* lib: fix endianness bug in prefix.cRenato Westphal2012-03-231-4/+14
| | | | | | | | | | | | 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>
* lib: use prefix bit length macrosDenis Ovsienko2012-01-081-7/+7
|
* general: remove inline qualifiers and move in-header functions to objectsPaul Jakma2012-01-061-0/+15
| | | | | | * (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.
* lib: address type-punned pointers in prefix_same()Denis Ovsienko2012-01-021-2/+2
| | | | | | 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.
* lib: fix type-punning in ip_masklen()Denis Ovsienko2012-01-021-2/+7
| | | | | ip_masklen() was likely to return incorrect results after being compiled with -fstrict-aliasing (-O2, -O3, -Os)
* lib: optimize ip_masklen()Denis Ovsienko2012-01-021-25/+2076
| | | | | | | | | | | | | 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.
* Revert "lib: optimize apply_mask_ipv6()"Denis Ovsienko2012-01-011-7/+17
| | | | | Experience with IPv4 counterpart of this function suggests, that this way of type-punning is likely to cause errors.
* lib: optimize apply_mask_ipv6()Denis Ovsienko2011-12-131-17/+7
|
* lib: optimize apply_mask_ipv4()Denis Ovsienko2011-12-131-18/+3
|
* lib: make masklen2ip6() safer and fasterDenis Ovsienko2011-12-131-16/+135
|
* lib: fix endianness of masklen2ip()Denis Ovsienko2011-12-131-3/+39
|
* lib: make masklen2ip() safer and fasterDenis Ovsienko2011-12-131-16/+39
|
* lib: prefix2sockunion, prefix_common_bits helper functionsDavid Lamparter2011-11-211-0/+54
| | | | | | prefix2sockunion converts a struct prefix* to a union sockunion *; prefix_common_bits counts the number of common bits in the prefix's address part.
* lib: prefix.c nano-optimisationPaul Jakma2010-12-081-4/+5
| | | | | * lib/prefix.c: (prefix_match) nano-optimisation, let it return early without copying pointers.
* bgpd, lib: adopt afi_t and safi_t in several placesMichael Lambert2010-10-061-2/+2
| | | | | | | | | * 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)
* lib: make some structures constantStephen Hemminger2009-12-211-1/+1
| | | | | | | | | | | | | * 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
* lib/trivial: str2prefix checks return of inet_pton in fragile wayPaul Jakma2009-08-281-2/+2
| | | | | * 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-26 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs2005-07-261-4/+9
| | | | | | | | | | | | | * 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-26 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs2005-07-261-1/+1
| | | | | | | * prefix.c: (ip_masklen) While loop should test that 'pnt' pointer is in range before dereferencing it. [backport candidate]
* 2005-05-06 Paul Jakma <paul@dishone.st>paul2005-05-061-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | * (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
* * prefix.[hc]: Pass argument to the inet6_ntoa by value making it morehasso2005-04-081-2/+2
| | | | | | inet_ntoa alike. * ripngd.[hc], ripng_interface.c, ripng_peer.c: inet6_ntoa() takes argument now by value.
* * lib/prefix.[hc]: inet6_ntoa utility function copied fromquagga_pre_listloop_cleanuphasso2005-04-051-0/+11
| | | | | | | | 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-08 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs2004-12-081-1/+1
| | | | | | * 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.
* OK. Here it is - PtP patch from Andrew J. Schorr. No problems with ospfd,hasso2004-10-191-2/+24
| | | | ripd might need some more testing though.
* First small part of lib cleanup. Mainly "constification" of arguments andhasso2004-10-041-22/+26
| | | | adding FIXME's.
* Explain the dual use of struct prefix for CIDR prefixes andgdt2004-01-131-3/+18
| | | | address/netmask pairs, and clarify the two comparison functions.
* Initial revisionpaul2002-12-131-0/+696