diff options
author | Chris Hall <GMCH@hestia.halldom.com> | 2010-01-20 14:18:05 +0000 |
---|---|---|
committer | Chris Hall <GMCH@hestia.halldom.com> | 2010-01-20 14:18:05 +0000 |
commit | c204b3f4299cc3c3f61ebbc5c2223fa913ce5424 (patch) | |
tree | 0881913bb63e9b798af12b338d54bccf543edcd0 /lib/sockunion.c | |
parent | 13fad04d09978db15317d3d3fb71ab87ea52c110 (diff) | |
download | quagga-c204b3f4299cc3c3f61ebbc5c2223fa913ce5424.tar.bz2 quagga-c204b3f4299cc3c3f61ebbc5c2223fa913ce5424.tar.xz |
Adding verify debug code for qtimers and tidied up.
modified: bgpd/bgp_connection.c -- using _unset functions
-- added bgp_connection_close_file
modified: bgpd/bgp_connection.h
modified: bgpd/bgp_fsm.c -- checked notification handling
-- uses bgp_connection_close_file
modified: bgpd/bgp_notification.c -- added _unset function
modified: bgpd/bgp_notification.h
modified: bgpd/bgp_open_state.c -- added _unset function
modified: bgpd/bgp_open_state.h
modified: lib/qtimers.c -- added debug _verify function
modified: lib/qtimers.h
modified: lib/sockunion.c -- added _unset function
modified: lib/sockunion.h
Diffstat (limited to 'lib/sockunion.c')
-rw-r--r-- | lib/sockunion.c | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/lib/sockunion.c b/lib/sockunion.c index d1fdb189..dbfccfb8 100644 --- a/lib/sockunion.c +++ b/lib/sockunion.c @@ -732,12 +732,63 @@ sockunion_free (union sockunion *su) } /*============================================================================== - * Clear a given sockunion -- ie zeroise it + * Sockunion reference utilities + */ + +/*------------------------------------------------------------------------------ + * Unset pointer to sockunion -- free any sockunion referenced + * + * Does nothing if there is no sockunion + */ +extern void +sockunion_unset(sockunion* p_su) +{ + if (*p_su != NULL) + XFREE(MTYPE_BGP_NOTIFY, *p_su) ; /* sets *p_su NULL */ +} ; + +/*------------------------------------------------------------------------------ + * Set pointer to sockunion (if any) + * + * Frees any existing sockunion at the destination. + * + * NB: copies the source pointer -- so must be clear about responsibility + * for the sockunion. + */ +extern void +sockunion_set(sockunion* p_dst, sockunion su) +{ + sockunion_unset(p_dst) ; + *p_dst = su ; +} + +/*------------------------------------------------------------------------------ + * Set pointer to a *copy* of the given sockunion + * + * Frees any existing sockunion at the destination. + * + * NB: copies the source pointer -- so must be clear about responsibility + * for the sockunion structure. + */ +extern void +sockunion_set_dup(sockunion* p_dst, sockunion su) +{ + sockunion_set(p_dst, sockunion_dup(su)) ; +} ; + +/*------------------------------------------------------------------------------ + * Set pointer to sockunion (if any) and unset source pointer. + * + * Frees any existing sockunion at the destination. + * + * NB: responsibility for the sockunion passes to the destination. */ extern void -sockunion_clear(union sockunion* su) +sockunion_set_mov(sockunion* p_dst, sockunion* p_src) { - memset(su, 0, sizeof(union sockunion)) ; + sockunion_unset(p_dst) ; + *p_dst = *p_src ; + *p_src = NULL ; } ; /*============================================================================== |