version 1.1.1.1, 2012/02/21 17:26:11
|
version 1.1.1.2, 2012/10/09 09:22:28
|
Line 43
|
Line 43
|
#include "isisd/isis_pdu.h" |
#include "isisd/isis_pdu.h" |
#include "isisd/isis_lsp.h" |
#include "isisd/isis_lsp.h" |
|
|
extern struct isis *isis; |
|
|
|
/* |
|
* Prototypes. |
|
*/ |
|
int add_tlv (u_char, u_char, u_char *, struct stream *); |
|
|
|
void |
void |
free_tlv (void *val) |
free_tlv (void *val) |
{ |
{ |
Line 75 free_tlvs (struct tlvs *tlvs)
|
Line 68 free_tlvs (struct tlvs *tlvs)
|
list_delete (tlvs->es_neighs); |
list_delete (tlvs->es_neighs); |
if (tlvs->lsp_entries) |
if (tlvs->lsp_entries) |
list_delete (tlvs->lsp_entries); |
list_delete (tlvs->lsp_entries); |
if (tlvs->lan_neighs) |
|
list_delete (tlvs->lan_neighs); |
|
if (tlvs->prefix_neighs) |
if (tlvs->prefix_neighs) |
list_delete (tlvs->prefix_neighs); |
list_delete (tlvs->prefix_neighs); |
|
if (tlvs->lan_neighs) |
|
list_delete (tlvs->lan_neighs); |
if (tlvs->ipv4_addrs) |
if (tlvs->ipv4_addrs) |
list_delete (tlvs->ipv4_addrs); |
list_delete (tlvs->ipv4_addrs); |
if (tlvs->ipv4_int_reachs) |
if (tlvs->ipv4_int_reachs) |
Line 93 free_tlvs (struct tlvs *tlvs)
|
Line 86 free_tlvs (struct tlvs *tlvs)
|
if (tlvs->ipv6_reachs) |
if (tlvs->ipv6_reachs) |
list_delete (tlvs->ipv6_reachs); |
list_delete (tlvs->ipv6_reachs); |
#endif /* HAVE_IPV6 */ |
#endif /* HAVE_IPV6 */ |
| |
| memset (tlvs, 0, sizeof (struct tlvs)); |
| |
return; |
return; |
} |
} |
|
|
Line 103 free_tlvs (struct tlvs *tlvs)
|
Line 98 free_tlvs (struct tlvs *tlvs)
|
*/ |
*/ |
int |
int |
parse_tlvs (char *areatag, u_char * stream, int size, u_int32_t * expected, |
parse_tlvs (char *areatag, u_char * stream, int size, u_int32_t * expected, |
u_int32_t * found, struct tlvs *tlvs) | u_int32_t * found, struct tlvs *tlvs, u_int32_t *auth_tlv_offset) |
{ |
{ |
u_char type, length; |
u_char type, length; |
struct lan_neigh *lan_nei; |
struct lan_neigh *lan_nei; |
Line 122 parse_tlvs (char *areatag, u_char * stream, int size,
|
Line 117 parse_tlvs (char *areatag, u_char * stream, int size,
|
#endif /* HAVE_IPV6 */ |
#endif /* HAVE_IPV6 */ |
u_char virtual; |
u_char virtual; |
int value_len, retval = ISIS_OK; |
int value_len, retval = ISIS_OK; |
u_char *pnt = stream; | u_char *start = stream, *pnt = stream; |
|
|
*found = 0; |
*found = 0; |
memset (tlvs, 0, sizeof (struct tlvs)); |
memset (tlvs, 0, sizeof (struct tlvs)); |
Line 443 parse_tlvs (char *areatag, u_char * stream, int size,
|
Line 438 parse_tlvs (char *areatag, u_char * stream, int size,
|
if (*expected & TLVFLAG_AUTH_INFO) |
if (*expected & TLVFLAG_AUTH_INFO) |
{ |
{ |
tlvs->auth_info.type = *pnt; |
tlvs->auth_info.type = *pnt; |
tlvs->auth_info.len = length-1; | if (length == 0) |
| { |
| zlog_warn ("ISIS-TLV (%s): TLV (type %d, length %d) " |
| "incorrect.", areatag, type, length); |
| return ISIS_WARNING; |
| } |
| --length; |
| tlvs->auth_info.len = length; |
pnt++; |
pnt++; |
memcpy (tlvs->auth_info.passwd, pnt, length - 1); | memcpy (tlvs->auth_info.passwd, pnt, length); |
pnt += length - 1; | /* Return the authentication tlv pos for later computation |
| * of MD5 (RFC 5304, 2) |
| */ |
| if (auth_tlv_offset) |
| *auth_tlv_offset += (pnt - start - 3); |
| pnt += length; |
} |
} |
else |
else |
{ |
{ |
Line 730 parse_tlvs (char *areatag, u_char * stream, int size,
|
Line 737 parse_tlvs (char *areatag, u_char * stream, int size,
|
int |
int |
add_tlv (u_char tag, u_char len, u_char * value, struct stream *stream) |
add_tlv (u_char tag, u_char len, u_char * value, struct stream *stream) |
{ |
{ |
| if ((stream_get_size (stream) - stream_get_endp (stream)) < |
if (STREAM_SIZE (stream) - stream_get_endp (stream) < (unsigned) len + 2) | (((unsigned)len) + 2)) |
{ |
{ |
zlog_warn ("No room for TLV of type %d", tag); | zlog_warn ("No room for TLV of type %d " |
| "(total size %d available %d required %d)", |
| tag, (int)stream_get_size (stream), |
| (int)(stream_get_size (stream) - stream_get_endp (stream)), |
| len+2); |
return ISIS_WARNING; |
return ISIS_WARNING; |
} |
} |
|
|
Line 873 tlv_add_nlpid (struct nlpids *nlpids, struct stream *s
|
Line 884 tlv_add_nlpid (struct nlpids *nlpids, struct stream *s
|
} |
} |
|
|
int |
int |
tlv_add_authinfo (char auth_type, char auth_len, u_char *auth_value, | tlv_add_authinfo (u_char auth_type, u_char auth_len, u_char *auth_value, |
struct stream *stream) |
struct stream *stream) |
{ |
{ |
u_char value[255]; |
u_char value[255]; |
u_char *pos = value; |
u_char *pos = value; |
*pos++ = ISIS_PASSWD_TYPE_CLEARTXT; | *pos++ = auth_type; |
memcpy (pos, auth_value, auth_len); |
memcpy (pos, auth_value, auth_len); |
|
|
return add_tlv (AUTH_INFO, auth_len + 1, value, stream); |
return add_tlv (AUTH_INFO, auth_len + 1, value, stream); |
Line 1002 tlv_add_ipv4_reachs (struct list *ipv4_reachs, struct
|
Line 1013 tlv_add_ipv4_reachs (struct list *ipv4_reachs, struct
|
pos += IPV4_MAX_BYTELEN; |
pos += IPV4_MAX_BYTELEN; |
} |
} |
|
|
|
|
return add_tlv (IPV4_INT_REACHABILITY, pos - value, value, stream); |
return add_tlv (IPV4_INT_REACHABILITY, pos - value, value, stream); |
} |
} |
|
|
Line 1023 tlv_add_te_ipv4_reachs (struct list *te_ipv4_reachs, s
|
Line 1033 tlv_add_te_ipv4_reachs (struct list *te_ipv4_reachs, s
|
if (pos - value + (5 + prefix_size) > 255) |
if (pos - value + (5 + prefix_size) > 255) |
{ |
{ |
retval = |
retval = |
add_tlv (IPV4_INT_REACHABILITY, pos - value, value, stream); | add_tlv (TE_IPV4_REACHABILITY, pos - value, value, stream); |
if (retval != ISIS_OK) |
if (retval != ISIS_OK) |
return retval; |
return retval; |
pos = value; |
pos = value; |
Line 1106 tlv_add_padding (struct stream *stream)
|
Line 1116 tlv_add_padding (struct stream *stream)
|
/* |
/* |
* How many times can we add full padding ? |
* How many times can we add full padding ? |
*/ |
*/ |
fullpads = (STREAM_SIZE (stream) - stream_get_endp (stream)) / 257; | fullpads = (stream_get_size (stream) - stream_get_endp (stream)) / 257; |
for (i = 0; i < fullpads; i++) |
for (i = 0; i < fullpads; i++) |
{ |
{ |
if (!stream_putc (stream, (u_char) PADDING)) /* TAG */ |
if (!stream_putc (stream, (u_char) PADDING)) /* TAG */ |
Line 1116 tlv_add_padding (struct stream *stream)
|
Line 1126 tlv_add_padding (struct stream *stream)
|
stream_put (stream, NULL, 255); /* zero padding */ |
stream_put (stream, NULL, 255); /* zero padding */ |
} |
} |
|
|
left = STREAM_SIZE (stream) - stream_get_endp (stream); | left = stream_get_size (stream) - stream_get_endp (stream); |
|
|
if (left < 2) |
if (left < 2) |
return ISIS_OK; |
return ISIS_OK; |