Changeset 7c8267b in mainline for uspace/lib/socket/packet/packet_client.c
- Timestamp:
- 2010-09-19T12:55:05Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2fa0ad9, dc94cb2
- Parents:
- 553f430
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/socket/packet/packet_client.c
r553f430 r7c8267b 122 122 } 123 123 124 int packet_set_addr(packet_t packet, const uint8_t * src, const uint8_t * dest, size_t addr_len){ 124 int 125 packet_set_addr(packet_t packet, const uint8_t * src, const uint8_t * dest, 126 size_t addr_len) 127 { 125 128 size_t padding; 126 129 size_t allocated; 127 130 128 if (! packet_is_valid(packet)){131 if (!packet_is_valid(packet)) 129 132 return EINVAL; 130 } 133 131 134 allocated = PACKET_MAX_ADDRESS_LENGTH(packet); 132 if (allocated < addr_len){135 if (allocated < addr_len) 133 136 return ENOMEM; 134 } 137 135 138 padding = allocated - addr_len; 136 139 packet->addr_len = addr_len; 137 if(src){ 140 141 if (src) { 138 142 memcpy((void *) packet + packet->src_addr, src, addr_len); 139 if (padding){140 bzero((void *) packet + packet->src_addr + addr_len, padding);141 }142 } else{143 if (padding) 144 bzero((void *) packet + packet->src_addr + addr_len, 145 padding); 146 } else { 143 147 bzero((void *) packet + packet->src_addr, allocated); 144 148 } 145 if(dest){ 149 150 if (dest) { 146 151 memcpy((void *) packet + packet->dest_addr, dest, addr_len); 147 if (padding){148 bzero((void *) packet + packet->dest_addr + addr_len, padding);149 }150 } else{152 if (padding) 153 bzero((void *) packet + packet->dest_addr + addr_len, 154 padding); 155 } else { 151 156 bzero((void *) packet + packet->dest_addr, allocated); 152 157 } 158 153 159 return EOK; 154 160 }
Note:
See TracChangeset
for help on using the changeset viewer.