mp_afi = ntohs(mp_afi);
parse_capabilities(struct peer *peer, u_char *d, u_int16_t dlen){	u_int16_t	 len;	u_int8_t	 capa_code;	u_int8_t	 capa_len;	u_char		*capa_val;	u_int16_t	 mp_afi;	u_int8_t	 mp_safi;	len = dlen;	while (len > 0) {		if (len < 2) {			log_peer_warnx(&peer->conf, "parse_capabilities: "			    "expect len >= 2, len is %u", len);			return (-1);		}		memcpy(&capa_code, d, sizeof(capa_code));		d += sizeof(capa_code);		len -= sizeof(capa_code);		memcpy(&capa_len, d, sizeof(capa_len));		d += sizeof(capa_len);		len -= sizeof(capa_len);		if (capa_len > 0) {			if (len < capa_len) {				log_peer_warnx(&peer->conf,				    "parse_capabilities: "				    "len %u smaller than capa_len %u",				    len, capa_len);				return (-1);			}			capa_val = d;			d += capa_len;			len -= capa_len;		} else			capa_val = NULL;		switch (capa_code) {		case CAPA_MP:			/* RFC 2858 */			if (capa_len != 4) {				log_peer_warnx(&peer->conf,				    "parse_capabilities: "				    "expect len 4, len is %u", capa_len);				return (-1);			}			memcpy(&mp_afi, capa_val, sizeof(mp_afi));			memcpy(&mp_safi, capa_val + 3, sizeof(mp_safi));			switch (mp_afi) {			case AFI_IPv4:				if (mp_safi < 1 || mp_safi > 3) {					log_peer_warnx(&peer->conf,					    "parse_capabilities: AFI IPv4, "					    "mp_safi %u illegal", mp_safi);					return (-1);				}				peer->capa.mp_v4 = mp_safi;				break;			case AFI_IPv6:				if (mp_safi < 1 || mp_safi > 3) {					log_peer_warnx(&peer->conf,					    "parse_capabilities: AFI IPv6, "					    "mp_safi %u illegal", mp_safi);					return (-1);				}				peer->capa.mp_v6 = mp_safi;				break;			default:			/* ignore */				break;			}			break;		case CAPA_REFRESH:			peer->capa.refresh = 1;			break;		default:			break;		}	}	return (0);}