Revision fe9f1a6d proto/ospf/ospf.h

View differences:

proto/ospf/ospf.h
132 132

  
133 133
struct area_net
134 134
{
135
  struct fib_node fn;
136 135
  u32 metric;			/* With possible LSA_EXT3_EBIT for NSSA area nets */
137 136
  u32 tag;
138 137
  u8 hidden;
139 138
  u8 active;
139
  struct fib_node fn;
140 140
};
141 141

  
142 142
struct ospf_stubnet_config
......
681 681

  
682 682
struct ospf_lsa_ext_local
683 683
{
684
  ip_addr ip, fwaddr;
685
  int pxlen;
684
  net_addr net;
685
  ip_addr fwaddr;
686 686
  u32 metric, ebit, fbit, tag, propagate;
687 687
  u8 pxopts;
688 688
};
......
720 720
/* In ospf_area->rtr we store paths to routers, but we use RID (and not IP address)
721 721
   as index, so we need to encapsulate RID to IP address */
722 722

  
723
#define ipa_from_rid(x) ipa_from_u32(x)
724
#define ipa_to_rid(x) ipa_to_u32(x)
723
#define net_from_rid(x) NET_ADDR_IP4(ip4_from_u32(x), IP4_MAX_PREFIX_LENGTH)
724
#define rid_from_net(x) ip4_to_u32(((net_addr_ip4 *) x)->prefix)
725 725

  
726 726
#define IPV6_PREFIX_SPACE(x) ((((x) + 63) / 32) * 4)
727 727
#define IPV6_PREFIX_WORDS(x) (((x) + 63) / 32)
......
730 730
   also should be named as ospf3_* instead of *_ipv6_* */
731 731

  
732 732
static inline u32 *
733
lsa_get_ipv6_prefix(u32 *buf, ip_addr *addr, int *pxlen, u8 *pxopts, u16 *rest)
733
ospf_get_ipv6_prefix(u32 *buf, net_addr *N, u8 *pxopts, u16 *rest)
734 734
{
735
  u8 pxl = (*buf >> 24);
736
  *pxopts = (*buf >> 16);
737
  *rest = *buf;
738
  *pxlen = pxl;
735
  net_addr_ip6 *net = (void *) N;
736
  u8 pxlen = (*buf >> 24);
737
  *pxopts = (*buf >> 16) & 0xff;
738
  if (rest) *rest = *buf & 0xffff;
739 739
  buf++;
740 740

  
741
  *addr = IPA_NONE;
741
  *net = NET_ADDR_IP6(IP6_NONE, pxlen);
742 742

  
743
#ifdef IPV6
744
  if (pxl > 0)
745
    _I0(*addr) = *buf++;
746
  if (pxl > 32)
747
    _I1(*addr) = *buf++;
748
  if (pxl > 64)
749
    _I2(*addr) = *buf++;
750
  if (pxl > 96)
751
    _I3(*addr) = *buf++;
743
  if (pxlen > 0)
744
    _I0(net->prefix) = *buf++;
745
  if (pxlen > 32)
746
    _I1(net->prefix) = *buf++;
747
  if (pxlen > 64)
748
    _I2(net->prefix) = *buf++;
749
  if (pxlen > 96)
750
    _I3(net->prefix) = *buf++;
752 751

  
753 752
  /* Clean up remaining bits */
754
  if (pxl < 128)
755
    addr->addr[pxl / 32] &= u32_mkmask(pxl % 32);
756
#endif
753
  if (pxlen < 128)
754
    net->prefix.addr[pxlen / 32] &= u32_mkmask(pxlen % 32);
757 755

  
758 756
  return buf;
759 757
}
760 758

  
761 759
static inline u32 *
762
lsa_get_ipv6_addr(u32 *buf, ip_addr *addr)
760
ospf_get_ipv6_addr(u32 *buf, ip_addr *addr)
763 761
{
764
  *addr = *(ip_addr *) buf;
762
  *addr = ipa_from_ip6(*(ip6_addr *) buf);
765 763
  return buf + 4;
766 764
}
767 765

  
768 766
static inline u32 *
769
put_ipv6_prefix(u32 *buf, ip_addr addr, u8 pxlen, u8 pxopts, u16 lh)
767
ospf_put_ipv6_prefix(u32 *buf, net_addr *N, u8 pxopts, u16 rest)
770 768
{
771
#ifdef IPV6
772
  *buf++ = ((pxlen << 24) | (pxopts << 16) | lh);
769
  net_addr_ip6 *net = (void *) N;
770
  u32 pxlen = net->pxlen;
771

  
772
  *buf++ = ((pxlen << 24) | (pxopts << 16) | rest);
773 773

  
774 774
  if (pxlen > 0)
775
    *buf++ = _I0(addr);
775
    *buf++ = _I0(net->prefix);
776 776
  if (pxlen > 32)
777
    *buf++ = _I1(addr);
777
    *buf++ = _I1(net->prefix);
778 778
  if (pxlen > 64)
779
    *buf++ = _I2(addr);
779
    *buf++ = _I2(net->prefix);
780 780
  if (pxlen > 96)
781
    *buf++ = _I3(addr);
782
#endif
781
    *buf++ = _I3(net->prefix);
782

  
783 783
  return buf;
784 784
}
785 785

  
786 786
static inline u32 *
787
put_ipv6_addr(u32 *buf, ip_addr addr)
787
ospf_put_ipv6_addr(u32 *buf, ip_addr addr)
788 788
{
789
  *(ip_addr *) buf = addr;
789
  *(ip6_addr *) buf = ipa_to_ip6(addr);
790 790
  return buf + 4;
791 791
}
792 792

  
......
896 896

  
897 897
/* packet.c */
898 898
void ospf_pkt_fill_hdr(struct ospf_iface *ifa, void *buf, u8 h_type);
899
uint ospf_pkt_maxsize(struct ospf_iface *ifa);
899
uint ospf_pkt_maxsize(struct ospf_proto *p, struct ospf_iface *ifa);
900 900
int ospf_rx_hook(sock * sk, int size);
901 901
// void ospf_tx_hook(sock * sk);
902 902
void ospf_err_hook(sock * sk, int err);

Also available in: Unified diff