Commit 23c212e7 authored by Ondrej Zajicek (work)'s avatar Ondrej Zajicek (work)
Browse files

Follow-up work on integration

parent e92a4b85
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -205,7 +205,6 @@ f_generate_ec(u16 kind, struct f_inst *tk, struct f_inst *tv)
      cf_error("Can't operate with key of non-integer/IPv4 type in EC constructor");
  }

#ifndef IPV6
  /* IP->Quad implicit conversion */
  else if (tk->code == 'C') {
    c1 = 1;
@@ -223,7 +222,6 @@ f_generate_ec(u16 kind, struct f_inst *tk, struct f_inst *tv)
    else
      cf_error("Can't operate with key of non-integer/IPv4 type in EC constructor");
  }
#endif

  if (tv->code == 'c') {
    if (tv->aux != T_INT)
+3 −3
Original line number Diff line number Diff line
@@ -31,15 +31,15 @@ net_format(const net_addr *N, char *buf, int buflen)
{
  net_addr_union *n = (void *) N;

  /* FIXME: quick hack */
  /* XXXX fix %I vs %R */
  switch (n->n.type)
  {
  case NET_IP4:
    return bsnprintf(buf, buflen, "%I/%d", n->ip4.prefix, n->ip4.pxlen);
    return bsnprintf(buf, buflen, "%R/%d", n->ip4.prefix, n->ip4.pxlen);
  case NET_IP6:
    return bsnprintf(buf, buflen, "%I/%d", n->ip6.prefix, n->ip6.pxlen);
  case NET_VPN4:
    return bsnprintf(buf, buflen, "%u:%u %I/%d", (u32) (n->vpn4.rd >> 32), (u32) n->vpn4.rd, n->vpn4.prefix, n->vpn4.pxlen);
    return bsnprintf(buf, buflen, "%u:%u %R/%d", (u32) (n->vpn4.rd >> 32), (u32) n->vpn4.rd, n->vpn4.prefix, n->vpn4.pxlen);
  case NET_VPN6:
    return bsnprintf(buf, buflen, "%u:%u %I/%d", (u32) (n->vpn6.rd >> 32), (u32) n->vpn6.rd, n->vpn6.prefix, n->vpn6.pxlen);
  }
+4 −4
Original line number Diff line number Diff line
@@ -199,20 +199,20 @@ static inline void net_copy_vpn6(net_addr_vpn6 *dst, const net_addr_vpn6 *src)


static inline u32 net_hash_ip4(const net_addr_ip4 *n)
{ return ip4_hash(n->prefix) ^ ((u32) n->pxlen << 26); }
{ return ip4_hash32(n->prefix) ^ ((u32) n->pxlen << 26); }

static inline u32 net_hash_ip6(const net_addr_ip6 *n)
{ return ip6_hash(n->prefix) ^ ((u32) n->pxlen << 26); }
{ return ip6_hash32(n->prefix) ^ ((u32) n->pxlen << 26); }

/* XXXX */
static inline u32 u64_hash(u32 a)
{ return u32_hash(a); }

static inline u32 net_hash_vpn4(const net_addr_vpn4 *n)
{ return ip4_hash(n->prefix) ^ ((u32) n->pxlen << 26) ^ u64_hash(n->rd); }
{ return ip4_hash32(n->prefix) ^ ((u32) n->pxlen << 26) ^ u64_hash(n->rd); }

static inline u32 net_hash_vpn6(const net_addr_vpn6 *n)
{ return ip6_hash(n->prefix) ^ ((u32) n->pxlen << 26) ^ u64_hash(n->rd); }
{ return ip6_hash32(n->prefix) ^ ((u32) n->pxlen << 26) ^ u64_hash(n->rd); }


static inline int net_validate_ip4(const net_addr_ip4 *n)
+7 −7
Original line number Diff line number Diff line
@@ -292,9 +292,13 @@ int bvsnprintf(char *buf, int size, const char *fmt, va_list args)
		case 'I': {
			ip_addr a = va_arg(args, ip_addr);
			if (flags & SPECIAL)
				ipa_ntox(a, ipbuf);
				ip6_ntox(ipa_to_ip6(a), ipbuf);
			else {
				ipa_ntop(a, ipbuf);
				// XXXX better IPv4 / IPv6 distinction
				if (ipa_is_ip4(a))
					ip4_ntop(ipa_to_ip4(a), ipbuf);
				else
					ip6_ntop(ipa_to_ip6(a), ipbuf);
				if (field_width == 1)
					field_width = (ipa_is_ip4(a) ? IP4_MAX_TEXT_LENGTH : IP6_MAX_TEXT_LENGTH);
			}
@@ -319,11 +323,7 @@ int bvsnprintf(char *buf, int size, const char *fmt, va_list args)
		/* Router/Network ID - essentially IPv4 address in u32 value */
		case 'R':
			x = va_arg(args, u32);
			bsprintf(ipbuf, "%d.%d.%d.%d",
				 ((x >> 24) & 0xff),
				 ((x >> 16) & 0xff),
				 ((x >> 8) & 0xff),
				 (x & 0xff));
			ip4_ntop(ip4_from_u32(x), ipbuf);
			s = ipbuf;
			goto str;

+6 −10
Original line number Diff line number Diff line
@@ -67,18 +67,14 @@ void sk_set_tbsize(sock *s, uint val); /* Resize TX buffer, keeping content */
void sk_set_tbuf(sock *s, void *tbuf);	/* Switch TX buffer, NULL-> return to internal */
void sk_dump_all(void);

static inline int sk_send_buffer_empty(sock *sk)
{ return sk->tbuf == sk->tpos; }

static inline int sk_is_ipv4(sock *s)
{ return s->af == AF_INET; }

#ifdef IPV6
#define sk_is_ipv4(X) 0
#define sk_is_ipv6(X) 1
#else
#define sk_is_ipv4(X) 1
#define sk_is_ipv6(X) 0
#endif
static inline int sk_is_ipv6(sock *s)
{ return s->af == AF_INET6; }

static inline int sk_send_buffer_empty(sock *sk)
{ return sk->tbuf == sk->tpos; }

int sk_setup_multicast(sock *s);	/* Prepare UDP or IP socket for multicasting */
int sk_join_group(sock *s, ip_addr maddr);	/* Join multicast group on sk iface */
Loading