mirror of
				https://git.proxmox.com/git/mirror_frr
				synced 2025-11-04 15:30:26 +00:00 
			
		
		
		
	This is a rather large mechanical commit that splits up the memory types defined in lib/memtypes.c and distributes them into *_memory.[ch] files in the individual daemons. The zebra change is slightly annoying because there is no nice place to put the #include "zebra_memory.h" statement. bgpd, ospf6d, isisd and some tests were reusing MTYPEs defined in the library for its own use. This is bad practice and would break when the memtype are made static. Acked-by: Vincent JARDIN <vincent.jardin@6wind.com> Acked-by: Donald Sharp <sharpd@cumulusnetworks.com> [CF: rebased for cmaster-next] Signed-off-by: David Lamparter <equinox@opensourcerouting.org> Signed-off-by: Christian Franke <chris@opensourcerouting.org>
		
			
				
	
	
		
			136 lines
		
	
	
		
			4.9 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			136 lines
		
	
	
		
			4.9 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
/*
 | 
						|
 * Copyright (C) 2003 Yasuhiro Ohara
 | 
						|
 *
 | 
						|
 * This file is part of GNU Zebra.
 | 
						|
 *
 | 
						|
 * GNU Zebra is free software; you can redistribute it and/or modify it
 | 
						|
 * under the terms of the GNU General Public License as published by the
 | 
						|
 * Free Software Foundation; either version 2, or (at your option) any
 | 
						|
 * later version.
 | 
						|
 *
 | 
						|
 * GNU Zebra is distributed in the hope that it will be useful, but
 | 
						|
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
						|
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 | 
						|
 * General Public License for more details.
 | 
						|
 *
 | 
						|
 * You should have received a copy of the GNU General Public License
 | 
						|
 * along with GNU Zebra; see the file COPYING.  If not, write to the 
 | 
						|
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 
 | 
						|
 * Boston, MA 02111-1307, USA.  
 | 
						|
 */
 | 
						|
 | 
						|
#ifndef OSPF6D_H
 | 
						|
#define OSPF6D_H
 | 
						|
 | 
						|
#define OSPF6_DAEMON_VERSION    "0.9.7r"
 | 
						|
 | 
						|
#include "libospf.h"
 | 
						|
#include "thread.h"
 | 
						|
 | 
						|
#include "ospf6_memory.h"
 | 
						|
 | 
						|
/* global variables */
 | 
						|
extern struct thread_master *master;
 | 
						|
 | 
						|
/* Historical for KAME.  */
 | 
						|
#ifndef IPV6_JOIN_GROUP
 | 
						|
#ifdef IPV6_ADD_MEMBERSHIP
 | 
						|
#define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP
 | 
						|
#endif /* IPV6_ADD_MEMBERSHIP. */
 | 
						|
#ifdef IPV6_JOIN_MEMBERSHIP
 | 
						|
#define IPV6_JOIN_GROUP  IPV6_JOIN_MEMBERSHIP
 | 
						|
#endif /* IPV6_JOIN_MEMBERSHIP. */
 | 
						|
#endif /* ! IPV6_JOIN_GROUP*/
 | 
						|
 | 
						|
#ifndef IPV6_LEAVE_GROUP
 | 
						|
#ifdef IPV6_DROP_MEMBERSHIP
 | 
						|
#define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP
 | 
						|
#endif /* IPV6_DROP_MEMBERSHIP */
 | 
						|
#endif /* ! IPV6_LEAVE_GROUP */
 | 
						|
 | 
						|
#define MSG_OK    0
 | 
						|
#define MSG_NG    1
 | 
						|
 | 
						|
/* cast macro: XXX - these *must* die, ick ick. */
 | 
						|
#define OSPF6_PROCESS(x) ((struct ospf6 *) (x))
 | 
						|
#define OSPF6_AREA(x) ((struct ospf6_area *) (x))
 | 
						|
#define OSPF6_INTERFACE(x) ((struct ospf6_interface *) (x))
 | 
						|
#define OSPF6_NEIGHBOR(x) ((struct ospf6_neighbor *) (x))
 | 
						|
 | 
						|
/* operation on timeval structure */
 | 
						|
#ifndef timerclear
 | 
						|
#define timerclear(a) (a)->tv_sec = (tvp)->tv_usec = 0
 | 
						|
#endif /*timerclear*/
 | 
						|
#ifndef timersub
 | 
						|
#define timersub(a, b, res)                           \
 | 
						|
  do {                                                \
 | 
						|
    (res)->tv_sec = (a)->tv_sec - (b)->tv_sec;        \
 | 
						|
    (res)->tv_usec = (a)->tv_usec - (b)->tv_usec;     \
 | 
						|
    if ((res)->tv_usec < 0)                           \
 | 
						|
      {                                               \
 | 
						|
        (res)->tv_sec--;                              \
 | 
						|
        (res)->tv_usec += 1000000;                    \
 | 
						|
      }                                               \
 | 
						|
  } while (0)
 | 
						|
#endif /*timersub*/
 | 
						|
#define timerstring(tv, buf, size)                      \
 | 
						|
  do {                                                  \
 | 
						|
    if ((tv)->tv_sec / 60 / 60 / 24)                    \
 | 
						|
      snprintf (buf, size, "%lldd%02lld:%02lld:%02lld", \
 | 
						|
                (tv)->tv_sec / 60LL / 60 / 24,          \
 | 
						|
                (tv)->tv_sec / 60LL / 60 % 24,          \
 | 
						|
                (tv)->tv_sec / 60LL % 60,               \
 | 
						|
                (tv)->tv_sec % 60LL);                   \
 | 
						|
    else                                                \
 | 
						|
      snprintf (buf, size, "%02lld:%02lld:%02lld",      \
 | 
						|
                (tv)->tv_sec / 60LL / 60 % 24,          \
 | 
						|
                (tv)->tv_sec / 60LL % 60,               \
 | 
						|
                (tv)->tv_sec % 60LL);                   \
 | 
						|
  } while (0)
 | 
						|
#define timerstring_local(tv, buf, size)                  \
 | 
						|
  do {                                                    \
 | 
						|
    int ret;                                              \
 | 
						|
    struct tm *tm;                                        \
 | 
						|
    tm = localtime (&(tv)->tv_sec);                       \
 | 
						|
    ret = strftime (buf, size, "%Y/%m/%d %H:%M:%S", tm);  \
 | 
						|
    if (ret == 0)                                         \
 | 
						|
      zlog_warn ("strftime error");                       \
 | 
						|
  } while (0)
 | 
						|
 | 
						|
#define threadtimer_string(now, t, buf, size)                         \
 | 
						|
  do {                                                                \
 | 
						|
    struct timeval result;                                            \
 | 
						|
    if (!t)                                                           \
 | 
						|
      snprintf(buf, size, "inactive");				      \
 | 
						|
    else {                                                            \
 | 
						|
      timersub(&t->u.sands, &now, &result);                           \
 | 
						|
      timerstring(&result, buf, size);                                \
 | 
						|
    }                                                                 \
 | 
						|
} while (0)
 | 
						|
 | 
						|
/* for commands */
 | 
						|
#define OSPF6_AREA_STR      "Area information\n"
 | 
						|
#define OSPF6_AREA_ID_STR   "Area ID (as an IPv4 notation)\n"
 | 
						|
#define OSPF6_SPF_STR       "Shortest Path First tree information\n"
 | 
						|
#define OSPF6_ROUTER_ID_STR "Specify Router-ID\n"
 | 
						|
#define OSPF6_LS_ID_STR     "Specify Link State ID\n"
 | 
						|
 | 
						|
#define VNL VTY_NEWLINE
 | 
						|
#define OSPF6_CMD_CHECK_RUNNING() \
 | 
						|
  if (ospf6 == NULL) \
 | 
						|
    { \
 | 
						|
      vty_out (vty, "OSPFv3 is not running%s", VTY_NEWLINE); \
 | 
						|
      return CMD_SUCCESS; \
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
/* Function Prototypes */
 | 
						|
extern struct route_node *route_prev (struct route_node *node);
 | 
						|
 | 
						|
extern void ospf6_debug (void);
 | 
						|
extern void ospf6_init (void);
 | 
						|
 | 
						|
#endif /* OSPF6D_H */
 | 
						|
 | 
						|
 |