*/
-#define NETDISSECT_REWORKED
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h>
-#include "interface.h"
+#include "netdissect.h"
#include "addrtoname.h"
#include "extract.h"
ospf6_print_lshdr(netdissect_options *ndo,
register const struct lsa6_hdr *lshp, const u_char *dataend)
{
- if ((u_char *)(lshp + 1) > dataend)
+ if ((const u_char *)(lshp + 1) > dataend)
goto trunc;
ND_TCHECK(lshp->ls_type);
ND_TCHECK(lshp->ls_seq);
ospf6_print_lsaprefix(netdissect_options *ndo,
const uint8_t *tptr, u_int lsa_length)
{
- const struct lsa6_prefix *lsapp = (struct lsa6_prefix *)tptr;
+ const struct lsa6_prefix *lsapp = (const struct lsa6_prefix *)tptr;
u_int wordlen;
struct in6_addr prefix;
* If it does, find the length of what follows the
* header.
*/
- if (length < sizeof(struct lsa6_hdr) || (u_char *)lsap + length > dataend)
+ if (length < sizeof(struct lsa6_hdr) || (const u_char *)lsap + length > dataend)
return (1);
lsa_length = length - sizeof(struct lsa6_hdr);
- tptr = (uint8_t *)lsap+sizeof(struct lsa6_hdr);
+ tptr = (const uint8_t *)lsap+sizeof(struct lsa6_hdr);
switch (EXTRACT_16BITS(&lsap->ls_hdr.ls_type)) {
case LS_TYPE_ROUTER | LS_SCOPE_AREA:
ND_PRINT((ndo, ", metric %u",
EXTRACT_32BITS(&lsap->lsa_un.un_inter_ap.inter_ap_metric) & SLA_MASK_METRIC));
- tptr = (uint8_t *)lsap->lsa_un.un_inter_ap.inter_ap_prefix;
+ tptr = (const uint8_t *)lsap->lsa_un.un_inter_ap.inter_ap_prefix;
while (lsa_length != 0) {
bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length);
if (bytelen < 0)
EXTRACT_32BITS(&lsap->lsa_un.un_asla.asla_metric) &
ASLA_MASK_METRIC));
- tptr = (uint8_t *)lsap->lsa_un.un_asla.asla_prefix;
- lsapp = (struct lsa6_prefix *)tptr;
+ tptr = (const uint8_t *)lsap->lsa_un.un_asla.asla_prefix;
+ lsapp = (const struct lsa6_prefix *)tptr;
bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length);
if (bytelen < 0)
goto trunc;
tptr += bytelen;
if ((flags32 & ASLA_FLAG_FWDADDR) != 0) {
- struct in6_addr *fwdaddr6;
+ const struct in6_addr *fwdaddr6;
- fwdaddr6 = (struct in6_addr *)tptr;
+ fwdaddr6 = (const struct in6_addr *)tptr;
if (lsa_length < sizeof (*fwdaddr6))
return (1);
lsa_length -= sizeof (*fwdaddr6);
if (lsa_length < sizeof (uint32_t))
return (1);
lsa_length -= sizeof (uint32_t);
- ND_TCHECK(*(uint32_t *)tptr);
+ ND_TCHECK(*(const uint32_t *)tptr);
ND_PRINT((ndo, " tag %s",
- ipaddr_string(ndo, (uint32_t *)tptr)));
+ ipaddr_string(ndo, (const uint32_t *)tptr)));
tptr += sizeof(uint32_t);
}
if (lsa_length < sizeof (uint32_t))
return (1);
lsa_length -= sizeof (uint32_t);
- ND_TCHECK(*(uint32_t *)tptr);
+ ND_TCHECK(*(const uint32_t *)tptr);
ND_PRINT((ndo, " RefLSID: %s",
- ipaddr_string(ndo, (uint32_t *)tptr)));
+ ipaddr_string(ndo, (const uint32_t *)tptr)));
tptr += sizeof(uint32_t);
}
break;
ip6addr_string(ndo, &llsap->llsa_lladdr),
prefixes));
- tptr = (uint8_t *)llsap->llsa_prefix;
+ tptr = (const uint8_t *)llsap->llsa_prefix;
while (prefixes > 0) {
bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length);
if (bytelen < 0)
prefixes = EXTRACT_16BITS(&lsap->lsa_un.un_intra_ap.intra_ap_nprefix);
ND_PRINT((ndo, "\n\t Prefixes %d:", prefixes));
- tptr = (uint8_t *)lsap->lsa_un.un_intra_ap.intra_ap_prefix;
+ tptr = (const uint8_t *)lsap->lsa_un.un_intra_ap.intra_ap_prefix;
while (prefixes > 0) {
bytelen = ospf6_print_lsaprefix(ndo, tptr, lsa_length);
if (bytelen < 0)
switch (op->ospf6_type) {
case OSPF_TYPE_HELLO: {
- register const struct hello6 *hellop = (const struct hello6 *)((uint8_t *)op + OSPF6HDR_LEN);
+ register const struct hello6 *hellop = (const struct hello6 *)((const uint8_t *)op + OSPF6HDR_LEN);
ND_PRINT((ndo, "\n\tOptions [%s]",
bittok2str(ospf6_option_values, "none",
if (ndo->ndo_vflag > 1) {
ND_PRINT((ndo, "\n\t Neighbor List:"));
ap = hellop->hello_neighbor;
- while ((u_char *)ap < dataend) {
+ while ((const u_char *)ap < dataend) {
ND_TCHECK(*ap);
ND_PRINT((ndo, "\n\t %s", ipaddr_string(ndo, ap)));
++ap;
}
case OSPF_TYPE_DD: {
- register const struct dd6 *ddp = (const struct dd6 *)((uint8_t *)op + OSPF6HDR_LEN);
+ register const struct dd6 *ddp = (const struct dd6 *)((const uint8_t *)op + OSPF6HDR_LEN);
ND_TCHECK(ddp->db_options);
ND_PRINT((ndo, "\n\tOptions [%s]",
if (ndo->ndo_vflag > 1) {
/* Print all the LS adv's */
lshp = ddp->db_lshdr;
- while ((u_char *)lshp < dataend) {
+ while ((const u_char *)lshp < dataend) {
if (ospf6_print_lshdr(ndo, lshp++, dataend))
goto trunc;
}
case OSPF_TYPE_LS_REQ:
if (ndo->ndo_vflag > 1) {
- lsrp = (const struct lsr6 *)((uint8_t *)op + OSPF6HDR_LEN);
- while ((u_char *)lsrp < dataend) {
+ lsrp = (const struct lsr6 *)((const uint8_t *)op + OSPF6HDR_LEN);
+ while ((const u_char *)lsrp < dataend) {
ND_TCHECK(*lsrp);
ND_PRINT((ndo, "\n\t Advertising Router %s",
ipaddr_string(ndo, &lsrp->ls_router)));
case OSPF_TYPE_LS_UPDATE:
if (ndo->ndo_vflag > 1) {
- register const struct lsu6 *lsup = (const struct lsu6 *)((uint8_t *)op + OSPF6HDR_LEN);
+ register const struct lsu6 *lsup = (const struct lsu6 *)((const uint8_t *)op + OSPF6HDR_LEN);
ND_TCHECK(lsup->lsu_count);
i = EXTRACT_32BITS(&lsup->lsu_count);
lsap = lsup->lsu_lsa;
- while ((u_char *)lsap < dataend && i--) {
+ while ((const u_char *)lsap < dataend && i--) {
if (ospf6_print_lsa(ndo, lsap, dataend))
goto trunc;
- lsap = (struct lsa6 *)((u_char *)lsap +
+ lsap = (const struct lsa6 *)((const u_char *)lsap +
EXTRACT_16BITS(&lsap->ls_hdr.ls_length));
}
}
case OSPF_TYPE_LS_ACK:
if (ndo->ndo_vflag > 1) {
- lshp = (const struct lsa6_hdr *)((uint8_t *)op + OSPF6HDR_LEN);
- while ((u_char *)lshp < dataend) {
+ lshp = (const struct lsa6_hdr *)((const uint8_t *)op + OSPF6HDR_LEN);
+ while ((const u_char *)lshp < dataend) {
if (ospf6_print_lshdr(ndo, lshp++, dataend))
goto trunc;
}
int lls_dd = 0;
if (op->ospf6_type == OSPF_TYPE_HELLO) {
- const struct hello6 *hellop = (const struct hello6 *)((uint8_t *)op + OSPF6HDR_LEN);
+ const struct hello6 *hellop = (const struct hello6 *)((const uint8_t *)op + OSPF6HDR_LEN);
if (EXTRACT_32BITS(&hellop->hello_options) & OSPF6_OPTION_L)
lls_hello = 1;
} else if (op->ospf6_type == OSPF_TYPE_DD) {
- const struct dd6 *ddp = (const struct dd6 *)((uint8_t *)op + OSPF6HDR_LEN);
+ const struct dd6 *ddp = (const struct dd6 *)((const uint8_t *)op + OSPF6HDR_LEN);
if (EXTRACT_32BITS(&ddp->db_options) & OSPF6_OPTION_L)
lls_dd = 1;
}
register const char *cp;
uint16_t datalen;
- op = (struct ospf6hdr *)bp;
+ op = (const struct ospf6hdr *)bp;
/* If the type is valid translate it, or just print the type */
/* value. If it's not valid, say so and return */