]> git.proxmox.com Git - mirror_frr.git/blame - ospf6d/ospf6_proto.h
Merge pull request #13484 from sri-mohan1/srib-ldpd
[mirror_frr.git] / ospf6d / ospf6_proto.h
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
718e3744 2/*
049207c3 3 * Common protocol data and data structures.
508e53e2 4 * Copyright (C) 2003 Yasuhiro Ohara
718e3744 5 */
6
7#ifndef OSPF6_PROTO_H
8#define OSPF6_PROTO_H
9
10/* OSPF protocol version */
508e53e2 11#define OSPFV3_VERSION 3
718e3744 12
718e3744 13/* TOS field normaly null */
508e53e2 14#define DEFAULT_TOS_VALUE 0x0
718e3744 15
718e3744 16#define ALLSPFROUTERS6 "ff02::5"
17#define ALLDROUTERS6 "ff02::6"
18
508e53e2 19#define OSPF6_ROUTER_BIT_W (1 << 3)
20#define OSPF6_ROUTER_BIT_V (1 << 2)
21#define OSPF6_ROUTER_BIT_E (1 << 1)
22#define OSPF6_ROUTER_BIT_B (1 << 0)
ad500b22
K
23#define OSPF6_ROUTER_BIT_NT (1 << 4)
24
718e3744 25
26/* OSPF options */
27/* present in HELLO, DD, LSA */
6cb85350
AR
28#define OSPF6_OPT_SET(x, opt) ((x)[2] |= (opt))
29#define OSPF6_OPT_ISSET(x, opt) ((x)[2] & (opt))
30#define OSPF6_OPT_CLEAR(x, opt) ((x)[2] &= ~(opt))
31#define OSPF6_OPT_SET_EXT(x, opt) ((x)[1] |= (opt))
32#define OSPF6_OPT_ISSET_EXT(x, opt) ((x)[1] & (opt))
33#define OSPF6_OPT_CLEAR_EXT(x, opt) ((x)[1] &= ~(opt))
718e3744 34#define OSPF6_OPT_CLEAR_ALL(x) ((x)[0] = (x)[1] = (x)[2] = 0)
35
6cb85350
AR
36#define OSPF6_OPT_AT (1 << 2) /* Authentication trailer Capability */
37#define OSPF6_OPT_L (1 << 1) /* Link local signalling Capability */
38#define OSPF6_OPT_AF (1 << 0) /* Address family Capability */
39/* 2 bits reserved for OSPFv2 migrated options */
718e3744 40#define OSPF6_OPT_DC (1 << 5) /* Demand Circuit handling Capability */
6cb85350 41#define OSPF6_OPT_R (1 << 4) /* Forwarding Capability (Any Protocol) */
508e53e2 42#define OSPF6_OPT_N (1 << 3) /* Handling Type-7 LSA Capability */
43#define OSPF6_OPT_MC (1 << 2) /* Multicasting Capability */
44#define OSPF6_OPT_E (1 << 1) /* AS External Capability */
45#define OSPF6_OPT_V6 (1 << 0) /* IPv6 forwarding Capability */
46
47/* OSPF6 Prefix */
abc7ef44 48#define OSPF6_PREFIX_MIN_SIZE 4U /* .length == 0 */
d62a17ae 49struct ospf6_prefix {
d7c0a89a
QY
50 uint8_t prefix_length;
51 uint8_t prefix_options;
d62a17ae 52 union {
d7c0a89a
QY
53 uint16_t _prefix_metric;
54 uint16_t _prefix_referenced_lstype;
d62a17ae 55 } u;
508e53e2 56#define prefix_metric u._prefix_metric
57#define prefix_refer_lstype u._prefix_referenced_lstype
d62a17ae 58 /* followed by one address_prefix */
c0f76ddf 59 struct in6_addr addr[];
508e53e2 60};
61
62#define OSPF6_PREFIX_OPTION_NU (1 << 0) /* No Unicast */
63#define OSPF6_PREFIX_OPTION_LA (1 << 1) /* Local Address */
64#define OSPF6_PREFIX_OPTION_MC (1 << 2) /* MultiCast */
65#define OSPF6_PREFIX_OPTION_P (1 << 3) /* Propagate (NSSA) */
600d28e3 66#define OSPF6_PREFIX_OPTION_DN \
67 (1 << 4) /* DN bit to prevent loops in VPN environment */
508e53e2 68
69/* caddr_t OSPF6_PREFIX_BODY (struct ospf6_prefix *); */
0d6f7fd6 70#define OSPF6_PREFIX_BODY(x) ((caddr_t)(x) + sizeof(struct ospf6_prefix))
508e53e2 71
72/* size_t OSPF6_PREFIX_SPACE (int prefixlength); */
73#define OSPF6_PREFIX_SPACE(x) ((((x) + 31) / 32) * 4)
74
75/* size_t OSPF6_PREFIX_SIZE (struct ospf6_prefix *); */
d62a17ae 76#define OSPF6_PREFIX_SIZE(x) \
77 (OSPF6_PREFIX_SPACE((x)->prefix_length) + sizeof(struct ospf6_prefix))
508e53e2 78
79/* struct ospf6_prefix *OSPF6_PREFIX_NEXT (struct ospf6_prefix *); */
d62a17ae 80#define OSPF6_PREFIX_NEXT(x) \
81 ((struct ospf6_prefix *)((caddr_t)(x) + OSPF6_PREFIX_SIZE(x)))
82
b8ce0c36 83extern void ospf6_prefix_in6_addr(struct in6_addr *in6, const void *prefix_buf,
84 const struct ospf6_prefix *p);
d62a17ae 85extern void ospf6_prefix_apply_mask(struct ospf6_prefix *op);
d7c0a89a 86extern void ospf6_prefix_options_printbuf(uint8_t prefix_options, char *buf,
d62a17ae 87 int size);
88extern void ospf6_capability_printbuf(char capability, char *buf, int size);
d7c0a89a 89extern void ospf6_options_printbuf(uint8_t *options, char *buf, int size);
718e3744 90
91#endif /* OSPF6_PROTO_H */