diff options
author | paul <paul> | 2005-05-03 09:27:23 +0000 |
---|---|---|
committer | paul <paul> | 2005-05-03 09:27:23 +0000 |
commit | 15935e9ae1619288f0f78fcc0dac15c1c25d41c6 (patch) | |
tree | 5a12ca48a8d3619f634134744abb0cf6e5f9a589 /isisd/isis_lsp.c | |
parent | 0dab930314e215a627f848ffa824ed995eb2e13c (diff) |
2005-05-03 Paul Jakma <paul@dishone.st>
* (general) More cleaning up of stream abuse, isisd should be
back to previous functionality. Replace various XMALLOC+memset's
with XCALLOC
* isis_tlv.c: (tlv_add_padding) use stream_put to clear the stream
rather than forward endp, as isisd reuses streams.
* isis_pdu.c: (process_lsp) cleanup direct reference to stream endp
(send_lsp) manual copy of a stream cleaned up to use stream_copy.
* isis_network.c: (isis_recv_pdu_bcast) replace direct memcpy with
stream_write
(isis_recv_pdu_p2p) replace recvfrom directly into stream with
stream_recvfrom. Remove dangerous and now unneeded manual update
of endp.
(isis_recv_pdu_bcast / non-GNU_LINUX) Replace direct memcpy with
stream_write.
(isis_recv_pdu_p2p) replace read direct into stream with
stream_read_try, and hence remove the manual update of endp.
* isis_lsp.c: (lsp_update_data) manual stream dup replaced with
stream_dup.
(lsppdu_realloc) mempcy into stream data replaced with stream_put.
(lsp_build_nonpseudo) remove mysterious stream_forward_endp's -
which were originally stream_set_putp - shouldn't be needed
now that all the manual fiddling of private stream data has been
corrected.
(build_topology_lsp_data) remove unneeded twiddling of endp,
appears to be due to lsppdu_realloc(), but it appears to sort of
do the right thing wrt streams.
Diffstat (limited to 'isisd/isis_lsp.c')
-rw-r--r-- | isisd/isis_lsp.c | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c index f59e804b..0860b150 100644 --- a/isisd/isis_lsp.c +++ b/isisd/isis_lsp.c @@ -20,6 +20,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + #include <stdlib.h> #include <stdio.h> #include <zebra.h> @@ -364,11 +365,8 @@ lsp_update_data (struct isis_lsp *lsp, struct stream *stream, int retval; /* copying only the relevant part of our stream */ - lsp->pdu = stream_new (stream->endp); - lsp->pdu->getp = stream->getp; - lsp->pdu->endp = stream->endp; - memcpy (lsp->pdu->data, stream->data, stream->endp); - + lsp->pdu = stream_dup (stream); + /* setting pointers to the correct place */ lsp->isis_header = (struct isis_fixed_hdr *) (STREAM_DATA (lsp->pdu)); lsp->lsp_header = (struct isis_link_state_hdr *) (STREAM_DATA (lsp->pdu) + @@ -926,8 +924,7 @@ lsppdu_realloc (struct isis_lsp * lsp, int memorytype, int size) #else /* otherwise we have to move all pointers */ u_char *newpdu; newpdu = stream_new (ntohs (lsp->lsp_header->pdu_len) + size); - memcpy (STREAM_DATA (newpdu), STREAM_DATA (lsp->pdu), - ntohs (lsp->lsp_header->pdu_len)); + stream_put (newpdu, STREAM_DATA(lsp->pdu), ntohs (lsp->lsp_header->pdu_len); XFREE (memorytype, lsp->pdu); lsp->pdu = newpdu; lsp->isis_header = (struct isis_fixed_hdr *) STREAM_DATA (lsp->pdu); @@ -1132,8 +1129,6 @@ lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area) } } - stream_forward_endp (lsp->pdu, ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN); - if (lsp->tlv_data.nlpids) tlv_add_nlpid (lsp->tlv_data.nlpids, lsp->pdu); if (lsp->tlv_data.hostname) @@ -1310,7 +1305,6 @@ lsp_build_nonpseudo (struct isis_lsp *lsp, struct isis_area *area) /* * Building the zero lsp */ - stream_forward_endp (lsp->pdu, ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN); /* * Add the authentication info if its present */ @@ -1874,8 +1868,8 @@ lsp_build_pseudo (struct isis_lsp *lsp, struct isis_circuit *circuit, lsp->tlv_data.is_neighs = list_new (); lsp->tlv_data.is_neighs->del = free_tlv; } - is_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh)); - memset (is_neigh, 0, sizeof (struct is_neigh)); + is_neigh = XCALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh)); + memcpy (&is_neigh->neigh_id, isis->sysid, ISIS_SYS_ID_LEN); listnode_add (lsp->tlv_data.is_neighs, is_neigh); @@ -1892,8 +1886,8 @@ lsp_build_pseudo (struct isis_lsp *lsp, struct isis_circuit *circuit, (level == 2 && adj->sys_type == ISIS_SYSTYPE_L2_IS)) { /* an IS neighbour -> add it */ - is_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh)); - memset (is_neigh, 0, sizeof (struct is_neigh)); + is_neigh = XCALLOC (MTYPE_ISIS_TLV, sizeof (struct is_neigh)); + memcpy (&is_neigh->neigh_id, adj->sysid, ISIS_SYS_ID_LEN); listnode_add (lsp->tlv_data.is_neighs, is_neigh); } @@ -1906,15 +1900,14 @@ lsp_build_pseudo (struct isis_lsp *lsp, struct isis_circuit *circuit, lsp->tlv_data.es_neighs = list_new (); lsp->tlv_data.es_neighs->del = free_tlv; } - es_neigh = XMALLOC (MTYPE_ISIS_TLV, sizeof (struct es_neigh)); - memset (es_neigh, 0, sizeof (struct es_neigh)); + es_neigh = XCALLOC (MTYPE_ISIS_TLV, sizeof (struct es_neigh)); + memcpy (&es_neigh->first_es_neigh, adj->sysid, ISIS_SYS_ID_LEN); listnode_add (lsp->tlv_data.es_neighs, is_neigh); } } } - stream_forward_endp (lsp->pdu, ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN); /* * Add the authentication info if it's present */ @@ -2452,8 +2445,5 @@ build_topology_lsp_data (struct isis_lsp *lsp, struct isis_area *area, (lsppdu_realloc (lsp, MTYPE_ISIS_TLV, strlen (buff)) - 1); memcpy (lsp->tlv_data.hostname->name, buff, strlen (buff)); } - - /* thanks to hannes, another bug bites the dust */ - lsp->pdu->endp = ntohs (lsp->lsp_header->pdu_len); } #endif /* TOPOLOGY_GENERATE */ |