void zebra_interface_if_set_value (struct stream *s, struct interface *ifp) { u_char link_params_status = 0; /* Read interface's index. */ ifp->ifindex = stream_getl (s); ifp->status = stream_getc (s); /* Read interface's value. */ ifp->flags = stream_getq (s); ifp->metric = stream_getl (s); ifp->mtu = stream_getl (s); ifp->mtu6 = stream_getl (s); ifp->bandwidth = stream_getl (s); ifp->ll_type = stream_getl (s); ifp->hw_addr_len = stream_getl (s); if (ifp->hw_addr_len) stream_get (ifp->hw_addr, s, MIN(ifp->hw_addr_len, INTERFACE_HWADDR_MAX)); /* Read Traffic Engineering status */ link_params_status = stream_getc (s); /* Then, Traffic Engineering parameters if any */ if (link_params_status) { struct if_link_params *iflp = if_link_params_get (ifp); link_params_set_value(s, iflp); } }
int main (void) { struct stream *s; s = stream_new (1024); stream_putc (s, ham); stream_putw (s, ham); stream_putl (s, ham); stream_putq (s, ham); print_stream (s); stream_resize (s, stream_get_endp (s)); print_stream (s); printf ("c: 0x%hhx\n", stream_getc (s)); printf ("w: 0x%hx\n", stream_getw (s)); printf ("l: 0x%x\n", stream_getl (s)); printf ("q: 0x%" PRIu64 "\n", stream_getq (s)); return 0; }
/* * Read interface up/down msg (ZEBRA_INTERFACE_UP/ZEBRA_INTERFACE_DOWN) * from zebra server. The format of this message is the same as * that sent for ZEBRA_INTERFACE_ADD/ZEBRA_INTERFACE_DELETE (see * comments for zebra_interface_add_read), except that no sockaddr_dl * is sent at the tail of the message. */ struct interface * zebra_interface_state_read (struct stream *s) { struct interface *ifp; char ifname_tmp[INTERFACE_NAMSIZ]; /* Read interface name. */ stream_get (ifname_tmp, s, INTERFACE_NAMSIZ); /* Lookup this by interface index. */ ifp = if_lookup_by_name_len (ifname_tmp, strnlen(ifname_tmp, INTERFACE_NAMSIZ)); /* If such interface does not exist, indicate an error */ if (! ifp) return NULL; /* Read interface's index. */ ifp->ifindex = stream_getl (s); /* Read interface's value. */ ifp->status = stream_getc (s); ifp->flags = stream_getq (s); ifp->metric = stream_getl (s); ifp->mtu = stream_getl (s); ifp->mtu6 = stream_getl (s); ifp->bandwidth = stream_getl (s); return ifp; }
struct interface * zebra_interface_add_read (struct stream *s) { struct interface *ifp; char ifname_tmp[INTERFACE_NAMSIZ]; /* Read interface name. */ stream_get (ifname_tmp, s, INTERFACE_NAMSIZ); /* Lookup/create interface by name. */ ifp = if_get_by_name_len (ifname_tmp, strnlen(ifname_tmp, INTERFACE_NAMSIZ)); /* Read interface's index. */ ifp->ifindex = stream_getl (s); /* Read interface's value. */ ifp->status = stream_getc (s); ifp->flags = stream_getq (s); ifp->metric = stream_getl (s); ifp->mtu = stream_getl (s); ifp->mtu6 = stream_getl (s); ifp->bandwidth = stream_getl (s); #ifdef HAVE_SOCKADDR_DL stream_get (&ifp->sdl, s, sizeof (ifp->sdl)); #else ifp->hw_addr_len = stream_getl (s); if (ifp->hw_addr_len) stream_get (ifp->hw_addr, s, ifp->hw_addr_len); #endif /* HAVE_SOCKADDR_DL */ return ifp; }
void zebra_interface_if_set_value (struct stream *s, struct interface *ifp) { /* Read interface's index. */ ifp->ifindex = stream_getl (s); ifp->status = stream_getc (s); /* Read interface's value. */ ifp->flags = stream_getq (s); ifp->metric = stream_getl (s); ifp->mtu = stream_getl (s); ifp->mtu6 = stream_getl (s); ifp->bandwidth = stream_getl (s); }
void zebra_interface_if_set_value (struct stream *s, struct interface *ifp) { /* Read interface's index. */ ifp->ifindex = stream_getl (s); ifp->status = stream_getc (s); /* Read interface's value. */ ifp->flags = stream_getq (s); ifp->metric = stream_getl (s); ifp->mtu = stream_getl (s); ifp->mtu6 = stream_getl (s); ifp->bandwidth = stream_getl (s); ifp->ll_type = stream_getl (s); ifp->hw_addr_len = stream_getl (s); if (ifp->hw_addr_len) stream_get (ifp->hw_addr, s, MIN(ifp->hw_addr_len, INTERFACE_HWADDR_MAX)); }
void zebra_interface_if_set_value (struct stream *s, struct interface *ifp) { /* Read interface's index. */ ifp->ifindex = stream_getl (s); ifp->status = stream_getc (s); /* Read interface's value. */ ifp->flags = stream_getq (s); ifp->metric = stream_getl (s); ifp->mtu = stream_getl (s); ifp->mtu6 = stream_getl (s); ifp->bandwidth = stream_getl (s); #ifdef HAVE_STRUCT_SOCKADDR_DL stream_get (&ifp->sdl, s, sizeof (ifp->sdl_storage)); #else ifp->hw_addr_len = stream_getl (s); if (ifp->hw_addr_len) stream_get (ifp->hw_addr, s, ifp->hw_addr_len); #endif /* HAVE_STRUCT_SOCKADDR_DL */ }