Changeset 1812a0d in mainline for uspace/srv/net/tl/tcp/header.c
- Timestamp:
- 2011-11-23T19:06:15Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 762b48a
- Parents:
- 6896409c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/tl/tcp/header.c
r6896409c r1812a0d 164 164 } 165 165 166 /** Create PDU with the specified header and text data. 167 * 168 * Note that you still need to set addresses in the returned PDU. 169 * 170 * @param hdr Header data 171 * @param hdr_size Header size in bytes 172 * @param text Text data 173 * @param text_size Text size in bytes 174 * @return New PDU 175 */ 176 tcp_pdu_t *tcp_pdu_create(void *hdr, size_t hdr_size, void *text, 177 size_t text_size) 178 { 179 tcp_pdu_t *pdu; 180 181 pdu = tcp_pdu_new(); 182 if (pdu == NULL) 183 return NULL; 184 185 pdu->header = malloc(hdr_size); 186 pdu->text = malloc(text_size); 187 if (pdu->header == NULL || pdu->text == NULL) 188 goto error; 189 190 memcpy(pdu->header, hdr, hdr_size); 191 memcpy(pdu->text, text, text_size); 192 193 pdu->header_size = hdr_size; 194 pdu->text_size = text_size; 195 196 return pdu; 197 198 error: 199 if (pdu->header != NULL) 200 free(pdu->header); 201 if (pdu->text != NULL) 202 free(pdu->text); 203 204 return NULL; 205 } 206 166 207 void tcp_pdu_delete(tcp_pdu_t *pdu) 167 208 { 209 free(pdu->header); 168 210 free(pdu->text); 169 211 free(pdu);
Note:
See TracChangeset
for help on using the changeset viewer.