Changeset ee1c2d9 in mainline for uspace/srv/net/tcp/pdu.c
- Timestamp:
- 2015-06-13T18:30:18Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a157846
- Parents:
- 0453261 (diff), 2f9a8e8 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tcp/pdu.c
r0453261 ree1c2d9 1 1 /* 2 * Copyright (c) 201 1Jiri Svoboda2 * Copyright (c) 2015 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 38 38 #include <byteorder.h> 39 39 #include <errno.h> 40 #include <inet/endpoint.h> 40 41 #include <mem.h> 41 42 #include <stdlib.h> … … 125 126 } 126 127 127 static void tcp_header_setup( tcp_sockpair_t *sp, tcp_segment_t *seg, tcp_header_t *hdr)128 static void tcp_header_setup(inet_ep2_t *epp, tcp_segment_t *seg, tcp_header_t *hdr) 128 129 { 129 130 uint16_t doff_flags; 130 131 uint16_t doff; 131 132 132 hdr->src_port = host2uint16_t_be( sp->local.port);133 hdr->dest_port = host2uint16_t_be( sp->foreign.port);133 hdr->src_port = host2uint16_t_be(epp->local.port); 134 hdr->dest_port = host2uint16_t_be(epp->remote.port); 134 135 hdr->seq = host2uint32_t_be(seg->seq); 135 136 hdr->ack = host2uint32_t_be(seg->ack); … … 190 191 } 191 192 192 static int tcp_header_encode( tcp_sockpair_t *sp, tcp_segment_t *seg,193 static int tcp_header_encode(inet_ep2_t *epp, tcp_segment_t *seg, 193 194 void **header, size_t *size) 194 195 { … … 199 200 return ENOMEM; 200 201 201 tcp_header_setup( sp, seg, hdr);202 tcp_header_setup(epp, seg, hdr); 202 203 *header = hdr; 203 204 *size = sizeof(tcp_header_t); … … 293 294 294 295 /** Decode incoming PDU */ 295 int tcp_pdu_decode(tcp_pdu_t *pdu, tcp_sockpair_t *sp, tcp_segment_t **seg)296 int tcp_pdu_decode(tcp_pdu_t *pdu, inet_ep2_t *epp, tcp_segment_t **seg) 296 297 { 297 298 tcp_segment_t *nseg; … … 307 308 hdr = (tcp_header_t *)pdu->header; 308 309 309 sp->local.port = uint16_t_be2host(hdr->dest_port);310 sp->local.addr = pdu->dest;311 sp->foreign.port = uint16_t_be2host(hdr->src_port);312 sp->foreign.addr = pdu->src;310 epp->local.port = uint16_t_be2host(hdr->dest_port); 311 epp->local.addr = pdu->dest; 312 epp->remote.port = uint16_t_be2host(hdr->src_port); 313 epp->remote.addr = pdu->src; 313 314 314 315 *seg = nseg; … … 317 318 318 319 /** Encode outgoing PDU */ 319 int tcp_pdu_encode( tcp_sockpair_t *sp, tcp_segment_t *seg, tcp_pdu_t **pdu)320 int tcp_pdu_encode(inet_ep2_t *epp, tcp_segment_t *seg, tcp_pdu_t **pdu) 320 321 { 321 322 tcp_pdu_t *npdu; … … 327 328 return ENOMEM; 328 329 329 npdu->src = sp->local.addr;330 npdu->dest = sp->foreign.addr;331 tcp_header_encode( sp, seg, &npdu->header, &npdu->header_size);330 npdu->src = epp->local.addr; 331 npdu->dest = epp->remote.addr; 332 tcp_header_encode(epp, seg, &npdu->header, &npdu->header_size); 332 333 333 334 text_size = tcp_segment_text_size(seg);
Note:
See TracChangeset
for help on using the changeset viewer.