Changeset 47f5a77 in mainline
- Timestamp:
- 2013-07-17T08:46:06Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3a0a4d8
- Parents:
- cdc3afa (diff), 1d94e21 (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. - Files:
-
- 4 added
- 44 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/arm32/src/mach/beaglebone/beaglebone.c
rcdc3afa r47f5a77 177 177 { 178 178 const unsigned inum = am335x_irc_inum_get(bbone.irc_addr); 179 am335x_irc_irq_ack(bbone.irc_addr);180 179 181 180 irq_t *irq = irq_dispatch_and_lock(inum); … … 187 186 printf("Spurious interrupt\n"); 188 187 } 188 189 am335x_irc_irq_ack(bbone.irc_addr); 189 190 } 190 191 -
kernel/genarch/src/drivers/am335x/timer.c
rcdc3afa r47f5a77 119 119 /* Disable compare mode */ 120 120 tclr &= ~AM335x_TIMER_TCLR_CE_FLAG; 121 /* Enable the prescaler, divisor = 2 */ 122 tclr |= AM335x_TIMER_TCLR_PRE_FLAG; 123 tclr &= ~(AM335x_TIMER_TCLR_PTV_MASK << AM335x_TIMER_TCLR_PTV_SHIFT); 121 124 122 /* Enable auto-reload mode */ 125 123 tclr |= AM335x_TIMER_TCLR_AR_FLAG; -
uspace/app/mkmfs/mkmfs.c
rcdc3afa r47f5a77 649 649 mark_bmap(ibmap_buf, i, FREE); 650 650 651 for (i = 2; i < sb->n_zones ; ++i)651 for (i = 2; i < sb->n_zones - sb->first_data_zone; ++i) 652 652 mark_bmap(zbmap_buf, i, FREE); 653 653 -
uspace/app/ping6/ping6.c
rcdc3afa r47f5a77 102 102 } 103 103 104 printf("Received ICMP echo reply: from %s to %s, seq. no %u, "104 printf("Received ICMPv6 echo reply: from %s to %s, seq. no %u, " 105 105 "payload size %zu\n", asrc, adest, sdu->seq_no, sdu->size); 106 106 -
uspace/drv/block/ata_bd/main.c
rcdc3afa r47f5a77 198 198 } 199 199 200 ddf_fun_add_to_category(fun, "bd"); 201 200 202 free(fun_name); 201 203 disk->afun = afun; -
uspace/drv/char/ns8250/ns8250.c
rcdc3afa r47f5a77 236 236 * 237 237 * @param fun The serial port function 238 * @param buf The ou put buffer for read data.238 * @param buf The output buffer for read data. 239 239 * @param count The number of bytes to be read. 240 240 * … … 420 420 ns->irq = res->res.interrupt.irq; 421 421 irq = true; 422 ddf_msg(LVL_NOTE, "Device %s was as igned irq = 0x%x.",422 ddf_msg(LVL_NOTE, "Device %s was assigned irq = 0x%x.", 423 423 ddf_dev_get_name(ns->dev), ns->irq); 424 424 break; … … 433 433 } 434 434 ioport = true; 435 ddf_msg(LVL_NOTE, "Device %s was as igned I/O address = "435 ddf_msg(LVL_NOTE, "Device %s was assigned I/O address = " 436 436 "0x%x.", ddf_dev_get_name(ns->dev), ns->io_addr); 437 437 break; … … 827 827 ddf_fun_t *fun = NULL; 828 828 bool need_cleanup = false; 829 bool need_unreg_intr_handler = false; 829 830 int rc; 830 831 … … 869 870 goto fail; 870 871 } 872 need_unreg_intr_handler = true; 871 873 872 874 /* Enable interrupt. */ … … 903 905 if (fun != NULL) 904 906 ddf_fun_destroy(fun); 907 if (need_unreg_intr_handler) 908 ns8250_unregister_interrupt_handler(ns); 905 909 if (need_cleanup) 906 910 ns8250_dev_cleanup(ns); … … 914 918 915 919 fibril_mutex_lock(&ns->mutex); 916 920 if (ns->client_connections > 0) { 917 921 fibril_mutex_unlock(&ns->mutex); 918 922 return EBUSY; -
uspace/lib/c/generic/inet/addr.c
rcdc3afa r47f5a77 70 70 { 71 71 memcpy(dst, src, 16); 72 } 73 74 int addr128_compare(const addr128_t a, const addr128_t b) 75 { 76 return memcmp(a, b, 16); 72 77 } 73 78 … … 212 217 } 213 218 219 void inet_addr_naddr(const inet_addr_t *addr, uint8_t prefix, 220 inet_naddr_t *naddr) 221 { 222 naddr->family = addr->family; 223 memcpy(naddr->addr6, addr->addr6, 16); 224 naddr->prefix = prefix; 225 } 226 214 227 void inet_addr_any(inet_addr_t *addr) 215 228 { … … 234 247 return (a->addr == b->addr); 235 248 case AF_INET6: 236 return memcmp(&a->addr6, &b->addr6, 16);249 return addr128_compare(a->addr6, b->addr6); 237 250 default: 238 251 return 0; … … 245 258 (inet_addr_compare(addr, &inet_addr_any_addr)) || 246 259 (inet_addr_compare(addr, &inet_addr_any_addr6))); 260 } 261 262 int inet_naddr_compare(const inet_naddr_t *naddr, const inet_addr_t *addr) 263 { 264 if (naddr->family != addr->family) 265 return 0; 266 267 switch (naddr->family) { 268 case AF_INET: 269 return (naddr->addr == addr->addr); 270 case AF_INET6: 271 return addr128_compare(naddr->addr6, addr->addr6); 272 default: 273 return 0; 274 } 247 275 } 248 276 -
uspace/lib/c/generic/inetping6.c
rcdc3afa r47f5a77 79 79 80 80 ipc_call_t answer; 81 aid_t req = async_send_3(exch, INETPING6_SEND, (sysarg_t) sdu->src, 82 (sysarg_t) sdu->dest, sdu->seq_no, &answer); 83 sysarg_t retval = async_data_write_start(exch, sdu->data, sdu->size); 81 aid_t req = async_send_1(exch, INETPING6_SEND, sdu->seq_no, &answer); 82 83 int rc = async_data_write_start(exch, &sdu->src, sizeof(addr128_t)); 84 if (rc != EOK) { 85 async_exchange_end(exch); 86 async_forget(req); 87 return rc; 88 } 89 90 rc = async_data_write_start(exch, &sdu->dest, sizeof(addr128_t)); 91 if (rc != EOK) { 92 async_exchange_end(exch); 93 async_forget(req); 94 return rc; 95 } 96 97 rc = async_data_write_start(exch, sdu->data, sdu->size); 84 98 85 99 async_exchange_end(exch); 86 100 87 if (retval != EOK) { 88 async_forget(req); 89 return retval; 90 } 91 101 if (rc != EOK) { 102 async_forget(req); 103 return rc; 104 } 105 106 sysarg_t retval; 92 107 async_wait_for(req, &retval); 93 return retval; 108 109 return (int) retval; 94 110 } 95 111 … … 142 158 } 143 159 144 if (size != sizeof( inet_addr_t)) {160 if (size != sizeof(addr128_t)) { 145 161 async_answer_0(callid, EINVAL); 146 162 async_answer_0(iid, EINVAL); … … 161 177 } 162 178 163 if (size != sizeof( inet_addr_t)) {179 if (size != sizeof(addr128_t)) { 164 180 async_answer_0(callid, EINVAL); 165 181 async_answer_0(iid, EINVAL); -
uspace/lib/c/generic/iplink.c
rcdc3afa r47f5a77 86 86 87 87 ipc_call_t answer; 88 aid_t req = async_send_0(exch, IPLINK_SEND, &answer); 89 90 int rc = async_data_write_start(exch, &sdu->src, sizeof(inet_addr_t)); 88 aid_t req = async_send_2(exch, IPLINK_SEND, (sysarg_t) sdu->src, 89 (sysarg_t) sdu->dest, &answer); 90 91 int rc = async_data_write_start(exch, sdu->data, sdu->size); 92 93 async_exchange_end(exch); 94 95 if (rc != EOK) { 96 async_forget(req); 97 return rc; 98 } 99 100 sysarg_t retval; 101 async_wait_for(req, &retval); 102 103 return (int) retval; 104 } 105 106 int iplink_send6(iplink_t *iplink, iplink_sdu6_t *sdu) 107 { 108 async_exch_t *exch = async_exchange_begin(iplink->sess); 109 110 ipc_call_t answer; 111 aid_t req = async_send_0(exch, IPLINK_SEND6, &answer); 112 113 int rc = async_data_write_start(exch, &sdu->dest, sizeof(addr48_t)); 91 114 if (rc != EOK) { 92 115 async_exchange_end(exch); … … 95 118 } 96 119 97 rc = async_data_write_start(exch, &sdu->dest, sizeof(inet_addr_t));98 if (rc != EOK) {99 async_exchange_end(exch);100 async_forget(req);101 return rc;102 }103 104 120 rc = async_data_write_start(exch, sdu->data, sdu->size); 105 121 … … 119 135 int iplink_get_mtu(iplink_t *iplink, size_t *rmtu) 120 136 { 137 async_exch_t *exch = async_exchange_begin(iplink->sess); 138 121 139 sysarg_t mtu; 122 async_exch_t *exch = async_exchange_begin(iplink->sess);123 124 140 int rc = async_req_0_1(exch, IPLINK_GET_MTU, &mtu); 125 async_exchange_end(exch); 126 141 142 async_exchange_end(exch); 143 127 144 if (rc != EOK) 128 145 return rc; 129 146 130 147 *rmtu = mtu; 131 148 return EOK; 149 } 150 151 int iplink_get_mac48(iplink_t *iplink, addr48_t *mac) 152 { 153 async_exch_t *exch = async_exchange_begin(iplink->sess); 154 155 ipc_call_t answer; 156 aid_t req = async_send_0(exch, IPLINK_GET_MAC48, &answer); 157 158 int rc = async_data_read_start(exch, mac, sizeof(addr48_t)); 159 160 loc_exchange_end(exch); 161 162 if (rc != EOK) { 163 async_forget(req); 164 return rc; 165 } 166 167 sysarg_t retval; 168 async_wait_for(req, &retval); 169 170 return (int) retval; 132 171 } 133 172 -
uspace/lib/c/generic/iplink_srv.c
rcdc3afa r47f5a77 50 50 } 51 51 52 static void iplink_get_mac48_srv(iplink_srv_t *srv, ipc_callid_t iid, 53 ipc_call_t *icall) 54 { 55 addr48_t mac; 56 int rc = srv->ops->get_mac48(srv, &mac); 57 if (rc != EOK) { 58 async_answer_0(iid, rc); 59 return; 60 } 61 62 ipc_callid_t callid; 63 size_t size; 64 if (!async_data_read_receive(&callid, &size)) { 65 async_answer_0(callid, EREFUSED); 66 async_answer_0(iid, EREFUSED); 67 return; 68 } 69 70 if (size != sizeof(addr48_t)) { 71 async_answer_0(callid, EINVAL); 72 async_answer_0(iid, EINVAL); 73 return; 74 } 75 76 rc = async_data_read_finalize(callid, &mac, size); 77 if (rc != EOK) 78 async_answer_0(callid, rc); 79 80 async_answer_0(iid, (sysarg_t) rc); 81 } 82 52 83 static void iplink_addr_add_srv(iplink_srv_t *srv, ipc_callid_t iid, 53 84 ipc_call_t *icall) … … 111 142 iplink_sdu_t sdu; 112 143 144 sdu.src = IPC_GET_ARG1(*icall); 145 sdu.dest = IPC_GET_ARG2(*icall); 146 147 int rc = async_data_write_accept(&sdu.data, false, 0, 0, 0, 148 &sdu.size); 149 if (rc != EOK) { 150 async_answer_0(iid, rc); 151 return; 152 } 153 154 rc = srv->ops->send(srv, &sdu); 155 free(sdu.data); 156 async_answer_0(iid, rc); 157 } 158 159 static void iplink_send6_srv(iplink_srv_t *srv, ipc_callid_t iid, 160 ipc_call_t *icall) 161 { 162 iplink_sdu6_t sdu; 163 113 164 ipc_callid_t callid; 114 165 size_t size; … … 119 170 } 120 171 121 if (size != sizeof( inet_addr_t)) {172 if (size != sizeof(addr48_t)) { 122 173 async_answer_0(callid, EINVAL); 123 174 async_answer_0(iid, EINVAL); … … 125 176 } 126 177 127 int rc = async_data_write_finalize(callid, &sdu. src, size);178 int rc = async_data_write_finalize(callid, &sdu.dest, size); 128 179 if (rc != EOK) { 129 180 async_answer_0(callid, (sysarg_t) rc); … … 131 182 } 132 183 133 if (!async_data_write_receive(&callid, &size)) {134 async_answer_0(callid, EREFUSED);135 async_answer_0(iid, EREFUSED);136 return;137 }138 139 if (size != sizeof(inet_addr_t)) {140 async_answer_0(callid, EINVAL);141 async_answer_0(iid, EINVAL);142 return;143 }144 145 rc = async_data_write_finalize(callid, &sdu.dest, size);146 if (rc != EOK) {147 async_answer_0(callid, (sysarg_t) rc);148 async_answer_0(iid, (sysarg_t) rc);149 }150 151 184 rc = async_data_write_accept(&sdu.data, false, 0, 0, 0, 152 185 &sdu.size); 153 if (rc != EOK) 154 return; 155 156 rc = srv->ops->send(srv, &sdu); 186 if (rc != EOK) { 187 async_answer_0(iid, rc); 188 return; 189 } 190 191 rc = srv->ops->send6(srv, &sdu); 157 192 free(sdu.data); 158 193 async_answer_0(iid, rc); … … 170 205 int iplink_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg) 171 206 { 172 iplink_srv_t *srv = (iplink_srv_t *) arg;207 iplink_srv_t *srv = (iplink_srv_t *) arg; 173 208 int rc; 174 209 … … 214 249 iplink_get_mtu_srv(srv, callid, &call); 215 250 break; 251 case IPLINK_GET_MAC48: 252 iplink_get_mac48_srv(srv, callid, &call); 253 break; 216 254 case IPLINK_SEND: 217 255 iplink_send_srv(srv, callid, &call); 256 break; 257 case IPLINK_SEND6: 258 iplink_send6_srv(srv, callid, &call); 218 259 break; 219 260 case IPLINK_ADDR_ADD: -
uspace/lib/c/generic/net/socket_parse.c
rcdc3afa r47f5a77 53 53 int socket_parse_address_family(const char *name, int *af) 54 54 { 55 if (str_lcmp(name, "AF_INET ", 7) == 0) {56 *af = AF_INET ;55 if (str_lcmp(name, "AF_INET6", 8) == 0) { 56 *af = AF_INET6; 57 57 return EOK; 58 58 } 59 59 60 if (str_lcmp(name, "AF_INET 6", 8) == 0) {61 *af = AF_INET 6;60 if (str_lcmp(name, "AF_INET", 7) == 0) { 61 *af = AF_INET; 62 62 return EOK; 63 63 } -
uspace/lib/c/include/inet/addr.h
rcdc3afa r47f5a77 73 73 extern void addr128(const addr128_t, addr128_t); 74 74 75 extern int addr128_compare(const addr128_t, const addr128_t); 76 75 77 extern void host2addr128_t_be(const addr128_t, addr128_t); 76 78 extern void addr128_t_be2host(const addr128_t, addr128_t); … … 87 89 extern int inet_addr_family(const char *, uint16_t *); 88 90 extern void inet_naddr_addr(const inet_naddr_t *, inet_addr_t *); 91 extern void inet_addr_naddr(const inet_addr_t *, uint8_t, inet_naddr_t *); 89 92 90 93 extern void inet_addr_any(inet_addr_t *); … … 94 97 extern int inet_addr_is_any(const inet_addr_t *); 95 98 99 extern int inet_naddr_compare(const inet_naddr_t *, const inet_addr_t *); 96 100 extern int inet_naddr_compare_mask(const inet_naddr_t *, const inet_addr_t *); 97 101 -
uspace/lib/c/include/inet/iplink.h
rcdc3afa r47f5a77 47 47 } iplink_t; 48 48 49 /** I nternetlink Service Data Unit */49 /** IPv4 link Service Data Unit */ 50 50 typedef struct { 51 51 /** Local source address */ 52 inet_addr_t src;52 addr32_t src; 53 53 /** Local destination address */ 54 inet_addr_t dest;54 addr32_t dest; 55 55 /** Serialized IP packet */ 56 56 void *data; … … 58 58 size_t size; 59 59 } iplink_sdu_t; 60 61 /** IPv6 link Service Data Unit */ 62 typedef struct { 63 /** Local MAC destination address */ 64 addr48_t dest; 65 /** Serialized IP packet */ 66 void *data; 67 /** Size of @c data in bytes */ 68 size_t size; 69 } iplink_sdu6_t; 60 70 61 71 /** Internet link receive Service Data Unit */ … … 74 84 extern void iplink_close(iplink_t *); 75 85 extern int iplink_send(iplink_t *, iplink_sdu_t *); 86 extern int iplink_send6(iplink_t *, iplink_sdu6_t *); 76 87 extern int iplink_addr_add(iplink_t *, inet_addr_t *); 77 88 extern int iplink_addr_remove(iplink_t *, inet_addr_t *); 78 89 extern int iplink_get_mtu(iplink_t *, size_t *); 90 extern int iplink_get_mac48(iplink_t *, addr48_t *); 79 91 80 92 #endif -
uspace/lib/c/include/inet/iplink_srv.h
rcdc3afa r47f5a77 57 57 int (*close)(iplink_srv_t *); 58 58 int (*send)(iplink_srv_t *, iplink_sdu_t *); 59 int (*send6)(iplink_srv_t *, iplink_sdu6_t *); 59 60 int (*get_mtu)(iplink_srv_t *, size_t *); 61 int (*get_mac48)(iplink_srv_t *, addr48_t *); 60 62 int (*addr_add)(iplink_srv_t *, inet_addr_t *); 61 63 int (*addr_remove)(iplink_srv_t *, inet_addr_t *); -
uspace/lib/c/include/ipc/iplink.h
rcdc3afa r47f5a77 40 40 typedef enum { 41 41 IPLINK_GET_MTU = IPC_FIRST_USER_METHOD, 42 IPLINK_GET_MAC48, 42 43 IPLINK_SEND, 44 IPLINK_SEND6, 43 45 IPLINK_ADDR_ADD, 44 46 IPLINK_ADDR_REMOVE -
uspace/srv/net/dnsrsrv/dns_std.h
rcdc3afa r47f5a77 65 65 DTYPE_MX = 15, 66 66 DTYPE_TXT = 16, 67 DTYPE_AAAA = 28, 67 68 DQTYPE_AXFR = 252, 68 69 DQTYPE_MAILB = 253, -
uspace/srv/net/ethip/ethip.c
rcdc3afa r47f5a77 56 56 static int ethip_close(iplink_srv_t *srv); 57 57 static int ethip_send(iplink_srv_t *srv, iplink_sdu_t *sdu); 58 static int ethip_send6(iplink_srv_t *srv, iplink_sdu6_t *sdu); 58 59 static int ethip_get_mtu(iplink_srv_t *srv, size_t *mtu); 60 static int ethip_get_mac48(iplink_srv_t *srv, addr48_t *mac); 59 61 static int ethip_addr_add(iplink_srv_t *srv, inet_addr_t *addr); 60 62 static int ethip_addr_remove(iplink_srv_t *srv, inet_addr_t *addr); … … 66 68 .close = ethip_close, 67 69 .send = ethip_send, 70 .send6 = ethip_send6, 68 71 .get_mtu = ethip_get_mtu, 72 .get_mac48 = ethip_get_mac48, 69 73 .addr_add = ethip_addr_add, 70 74 .addr_remove = ethip_addr_remove … … 169 173 170 174 ethip_nic_t *nic = (ethip_nic_t *) srv->arg; 171 172 addr32_t src_v4;173 addr128_t src_v6;174 uint16_t src_af = inet_addr_get(&sdu->src, &src_v4, &src_v6);175 176 addr32_t dest_v4;177 addr128_t dest_v6;178 uint16_t dest_af = inet_addr_get(&sdu->dest, &dest_v4, &dest_v6);179 180 if (src_af != dest_af)181 return EINVAL;182 183 int rc;184 175 eth_frame_t frame; 185 176 186 switch (src_af) { 187 case AF_INET: 188 rc = arp_translate(nic, src_v4, dest_v4, frame.dest); 189 if (rc != EOK) { 190 log_msg(LOG_DEFAULT, LVL_WARN, "Failed to look up IPv4 address 0x%" 191 PRIx32, dest_v4); 192 return rc; 193 } 194 195 addr48(nic->mac_addr, frame.src); 196 frame.etype_len = ETYPE_IP; 197 frame.data = sdu->data; 198 frame.size = sdu->size; 199 200 break; 201 case AF_INET6: 202 // FIXME TODO 203 return ENOTSUP; 204 default: 205 return EINVAL; 206 } 177 int rc = arp_translate(nic, sdu->src, sdu->dest, frame.dest); 178 if (rc != EOK) { 179 log_msg(LOG_DEFAULT, LVL_WARN, "Failed to look up IPv4 address 0x%" 180 PRIx32, sdu->dest); 181 return rc; 182 } 183 184 addr48(nic->mac_addr, frame.src); 185 frame.etype_len = ETYPE_IP; 186 frame.data = sdu->data; 187 frame.size = sdu->size; 207 188 208 189 void *data; 209 190 size_t size; 210 191 rc = eth_pdu_encode(&frame, &data, &size); 192 if (rc != EOK) 193 return rc; 194 195 rc = ethip_nic_send(nic, data, size); 196 free(data); 197 198 return rc; 199 } 200 201 static int ethip_send6(iplink_srv_t *srv, iplink_sdu6_t *sdu) 202 { 203 log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_send6()"); 204 205 ethip_nic_t *nic = (ethip_nic_t *) srv->arg; 206 eth_frame_t frame; 207 208 addr48(sdu->dest, frame.dest); 209 addr48(nic->mac_addr, frame.src); 210 frame.etype_len = ETYPE_IPV6; 211 frame.data = sdu->data; 212 frame.size = sdu->size; 213 214 void *data; 215 size_t size; 216 int rc = eth_pdu_encode(&frame, &data, &size); 211 217 if (rc != EOK) 212 218 return rc; … … 268 274 } 269 275 276 static int ethip_get_mac48(iplink_srv_t *srv, addr48_t *mac) 277 { 278 log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_get_mac48()"); 279 280 ethip_nic_t *nic = (ethip_nic_t *) srv->arg; 281 addr48(nic->mac_addr, *mac); 282 283 return EOK; 284 } 285 270 286 static int ethip_addr_add(iplink_srv_t *srv, inet_addr_t *addr) 271 287 { -
uspace/srv/net/ethip/pdu.c
rcdc3afa r47f5a77 46 46 #include "pdu.h" 47 47 48 #define MAC48_BYTES 649 50 48 /** Encode Ethernet PDU. */ 51 49 int eth_pdu_encode(eth_frame_t *frame, void **rdata, size_t *rsize) -
uspace/srv/net/inetsrv/Makefile
rcdc3afa r47f5a77 39 39 inetping.c \ 40 40 inetping6.c \ 41 ndp.c \ 42 ntrans.c \ 41 43 pdu.c \ 42 44 reass.c \ -
uspace/srv/net/inetsrv/addrobj.c
rcdc3afa r47f5a77 42 42 #include <stdlib.h> 43 43 #include <str.h> 44 #include <net/socket_codes.h> 44 45 #include "addrobj.h" 45 46 #include "inetsrv.h" 46 47 #include "inet_link.h" 48 #include "ndp.h" 47 49 48 50 static inet_addrobj_t *inet_addrobj_find_by_name_locked(const char *, inet_link_t *); … … 117 119 inet_addrobj_t, addr_list); 118 120 119 if (inet_naddr_compare_mask(&naddr->naddr, addr)) { 120 fibril_mutex_unlock(&addr_list_lock); 121 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_addrobj_find: found %p", 122 naddr); 123 return naddr; 121 switch (find) { 122 case iaf_net: 123 if (inet_naddr_compare_mask(&naddr->naddr, addr)) { 124 fibril_mutex_unlock(&addr_list_lock); 125 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_addrobj_find: found %p", 126 naddr); 127 return naddr; 128 } 129 break; 130 case iaf_addr: 131 if (inet_naddr_compare(&naddr->naddr, addr)) { 132 fibril_mutex_unlock(&addr_list_lock); 133 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_addrobj_find: found %p", 134 naddr); 135 return naddr; 136 } 137 break; 124 138 } 125 139 } … … 214 228 inet_naddr_addr(&addr->naddr, &lsrc_addr); 215 229 216 return inet_link_send_dgram(addr->ilink, &lsrc_addr, ldest, dgram, 217 proto, ttl, df); 230 addr32_t lsrc_v4; 231 addr128_t lsrc_v6; 232 uint16_t lsrc_af = inet_addr_get(&lsrc_addr, &lsrc_v4, &lsrc_v6); 233 234 addr32_t ldest_v4; 235 addr128_t ldest_v6; 236 uint16_t ldest_af = inet_addr_get(ldest, &ldest_v4, &ldest_v6); 237 238 if (lsrc_af != ldest_af) 239 return EINVAL; 240 241 int rc; 242 addr48_t ldest_mac; 243 244 switch (ldest_af) { 245 case AF_INET: 246 return inet_link_send_dgram(addr->ilink, lsrc_v4, ldest_v4, 247 dgram, proto, ttl, df); 248 case AF_INET6: 249 /* 250 * Translate local destination IPv6 address. 251 */ 252 rc = ndp_translate(lsrc_v6, ldest_v6, ldest_mac, addr->ilink); 253 if (rc != EOK) 254 return rc; 255 256 return inet_link_send_dgram6(addr->ilink, ldest_mac, dgram, 257 proto, ttl, df); 258 } 259 260 return ENOTSUP; 218 261 } 219 262 -
uspace/srv/net/inetsrv/icmp.c
rcdc3afa r47f5a77 153 153 return ENOMEM; 154 154 155 icmp_echo_t *request = (icmp_echo_t *) rdata;155 icmp_echo_t *request = (icmp_echo_t *) rdata; 156 156 157 157 request->type = ICMP_ECHO_REQUEST; -
uspace/srv/net/inetsrv/icmpv6.c
rcdc3afa r47f5a77 47 47 #include "pdu.h" 48 48 49 static int ndp_received(inet_dgram_t *dgram)50 {51 // FIXME TODO52 return ENOTSUP;53 }54 55 49 static int icmpv6_recv_echo_request(inet_dgram_t *dgram) 56 50 { … … 84 78 inet_dgram_t rdgram; 85 79 86 rdgram.src = dgram->dest;80 inet_get_srcaddr(&dgram->src, 0, &rdgram.src); 87 81 rdgram.dest = dgram->src; 88 82 rdgram.tos = 0; … … 90 84 rdgram.size = size; 91 85 92 icmpv6_p seudo_headerphdr;86 icmpv6_phdr_t phdr; 93 87 94 88 host2addr128_t_be(dest_v6, phdr.src_addr); … … 100 94 uint16_t cs_phdr = 101 95 inet_checksum_calc(INET_CHECKSUM_INIT, &phdr, 102 sizeof(icmpv6_p seudo_header));96 sizeof(icmpv6_phdr_t)); 103 97 104 98 uint16_t cs_all = inet_checksum_calc(cs_phdr, reply, size); … … 156 150 case ICMPV6_NEIGHBOUR_SOLICITATION: 157 151 case ICMPV6_NEIGHBOUR_ADVERTISEMENT: 158 #ifdef ACCEPT_RA159 152 case ICMPV6_ROUTER_ADVERTISEMENT: 160 #endif161 153 return ndp_received(dgram); 162 154 default: … … 192 184 dgram.size = rsize; 193 185 194 icmpv6_p seudo_headerphdr;186 icmpv6_phdr_t phdr; 195 187 196 188 host2addr128_t_be(sdu->src, phdr.src_addr); … … 202 194 uint16_t cs_phdr = 203 195 inet_checksum_calc(INET_CHECKSUM_INIT, &phdr, 204 sizeof(icmpv6_p seudo_header));196 sizeof(icmpv6_phdr_t)); 205 197 206 198 uint16_t cs_all = inet_checksum_calc(cs_phdr, rdata, rsize); -
uspace/srv/net/inetsrv/icmpv6_std.h
rcdc3afa r47f5a77 47 47 #define INET6_HOP_LIMIT_MAX 255 48 48 49 #define NDP_FLAG_ROUTER 0x80 50 #define NDP_FLAG_OVERRIDE 0x40 51 #define NDP_FLAG_SOLICITED 0x20 52 49 53 /** ICMPv6 message type */ 50 54 enum icmpv6_type { … … 83 87 uint8_t flags; 84 88 /** Reserved bytes */ 85 uint8_t reserved 89 uint8_t reserved[3]; 86 90 } ndp; 87 91 } un; … … 91 95 typedef struct { 92 96 /** Source IPv6 address */ 93 uint8_t src_addr 97 uint8_t src_addr[16]; 94 98 /** Target IPv6 address */ 95 uint8_t dest_addr 99 uint8_t dest_addr[16]; 96 100 /** ICMPv6 length */ 97 101 uint32_t length; 98 102 /** Zeroes */ 99 uint8_t zeroes 103 uint8_t zeroes[3]; 100 104 /** Next header */ 101 105 uint8_t next; 102 } icmpv6_p seudo_header;106 } icmpv6_phdr_t; 103 107 104 108 /** NDP neighbour body */ 105 109 typedef struct { 106 110 /** Target IPv6 address */ 107 uint8_t target_address 111 uint8_t target_address[16]; 108 112 /** Option code */ 109 113 uint8_t option; … … 111 115 uint8_t length; 112 116 /** MAC address */ 113 uint8_t mac 117 uint8_t mac[6]; 114 118 } ndp_message_t; 115 119 … … 131 135 uint32_t reserved; 132 136 /** Prefix */ 133 uint8_t prefix 137 uint8_t prefix[16]; 134 138 } ndp_prefix_t; 135 139 -
uspace/srv/net/inetsrv/inet_link.c
rcdc3afa r47f5a77 49 49 #include "pdu.h" 50 50 51 static bool first_link = true; 52 static bool first_link6 = true; 53 54 static FIBRIL_MUTEX_INITIALIZE(ip_ident_lock); 55 static uint16_t ip_ident = 0; 56 51 57 static int inet_link_open(service_id_t); 52 58 static int inet_iplink_recv(iplink_t *, iplink_recv_sdu_t *, uint16_t); … … 58 64 static LIST_INITIALIZE(inet_link_list); 59 65 static FIBRIL_MUTEX_INITIALIZE(inet_discovery_lock); 66 67 static addr128_t link_local_node_ip = 68 {0xfe, 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xfe, 0, 0, 0}; 69 70 static void inet_link_local_node_ip(addr48_t mac_addr, 71 addr128_t ip_addr) 72 { 73 memcpy(ip_addr, link_local_node_ip, 16); 74 75 ip_addr[8] = mac_addr[0] ^ 0x02; 76 ip_addr[9] = mac_addr[1]; 77 ip_addr[10] = mac_addr[2]; 78 ip_addr[13] = mac_addr[3]; 79 ip_addr[14] = mac_addr[4]; 80 ip_addr[15] = mac_addr[5]; 81 } 60 82 61 83 static int inet_iplink_recv(iplink_t *iplink, iplink_recv_sdu_t *sdu, uint16_t af) … … 159 181 if (ilink->svc_name != NULL) 160 182 free(ilink->svc_name); 183 161 184 free(ilink); 162 185 } … … 201 224 goto error; 202 225 } 226 227 /* 228 * Get the MAC address of the link. If the link has a MAC 229 * address, we assume that it supports NDP. 230 */ 231 rc = iplink_get_mac48(ilink->iplink, &ilink->mac); 232 ilink->mac_valid = (rc == EOK); 203 233 204 234 log_msg(LOG_DEFAULT, LVL_DEBUG, "Opened IP link '%s'", ilink->svc_name); 205 235 list_append(&ilink->link_list, &inet_link_list); 206 236 207 inet_addrobj_t *addr; 208 inet_addrobj_t *addr6; 209 210 static int first = 1; 211 212 addr = inet_addrobj_new(); 213 addr6 = inet_addrobj_new(); 214 215 if (first) { 237 inet_addrobj_t *addr = NULL; 238 239 if (first_link) { 240 addr = inet_addrobj_new(); 241 216 242 inet_naddr(&addr->naddr, 127, 0, 0, 1, 24); 217 inet_naddr6(&addr6->naddr, 0, 0, 0, 0, 0, 0, 0, 1, 128); 218 first = 0; 243 first_link = false; 219 244 } else { 220 245 /* 221 246 * FIXME 222 * Setting static IP addresses for testing purposes247 * Setting static IPv4 address for testing purposes: 223 248 * 10.0.2.15/24 224 * fd19:1680::4/120225 249 */ 250 addr = inet_addrobj_new(); 251 226 252 inet_naddr(&addr->naddr, 10, 0, 2, 15, 24); 227 inet_naddr6(&addr6->naddr, 0xfd19, 0x1680, 0, 0, 0, 0, 0, 4, 120); 228 } 229 230 addr->ilink = ilink; 231 addr6->ilink = ilink; 232 addr->name = str_dup("v4a"); 233 addr6->name = str_dup("v6a"); 234 235 rc = inet_addrobj_add(addr); 236 if (rc != EOK) { 237 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed adding IPv4 address."); 238 inet_addrobj_delete(addr); 239 /* XXX Roll back */ 240 return rc; 241 } 242 243 rc = inet_addrobj_add(addr6); 244 if (rc != EOK) { 245 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed adding IPv6 address."); 246 inet_addrobj_delete(addr6); 247 /* XXX Roll back */ 248 return rc; 249 } 250 251 inet_naddr_addr(&addr->naddr, &iaddr); 252 rc = iplink_addr_add(ilink->iplink, &iaddr); 253 if (rc != EOK) { 254 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed setting IPv4 address on internet link."); 255 inet_addrobj_remove(addr); 256 inet_addrobj_delete(addr); 257 /* XXX Roll back */ 258 return rc; 259 } 260 261 inet_naddr_addr(&addr6->naddr, &iaddr); 262 rc = iplink_addr_add(ilink->iplink, &iaddr); 263 if (rc != EOK) { 264 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed setting IPv6 address on internet link."); 265 inet_addrobj_remove(addr6); 266 inet_addrobj_delete(addr6); 267 /* XXX Roll back */ 268 return rc; 253 } 254 255 if (addr != NULL) { 256 addr->ilink = ilink; 257 addr->name = str_dup("v4a"); 258 259 rc = inet_addrobj_add(addr); 260 if (rc == EOK) { 261 inet_naddr_addr(&addr->naddr, &iaddr); 262 rc = iplink_addr_add(ilink->iplink, &iaddr); 263 if (rc != EOK) { 264 log_msg(LOG_DEFAULT, LVL_ERROR, 265 "Failed setting IPv4 address on internet link."); 266 inet_addrobj_remove(addr); 267 inet_addrobj_delete(addr); 268 } 269 } else { 270 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed adding IPv4 address."); 271 inet_addrobj_delete(addr); 272 } 273 } 274 275 inet_addrobj_t *addr6 = NULL; 276 277 if (first_link6) { 278 addr6 = inet_addrobj_new(); 279 280 inet_naddr6(&addr6->naddr, 0, 0, 0, 0, 0, 0, 0, 1, 128); 281 first_link6 = false; 282 } else if (ilink->mac_valid) { 283 addr6 = inet_addrobj_new(); 284 285 addr128_t link_local; 286 inet_link_local_node_ip(ilink->mac, link_local); 287 288 inet_naddr_set6(link_local, 64, &addr6->naddr); 289 } 290 291 if (addr6 != NULL) { 292 addr6->ilink = ilink; 293 addr6->name = str_dup("v6a"); 294 295 rc = inet_addrobj_add(addr6); 296 if (rc == EOK) { 297 inet_naddr_addr(&addr6->naddr, &iaddr); 298 rc = iplink_addr_add(ilink->iplink, &iaddr); 299 if (rc != EOK) { 300 log_msg(LOG_DEFAULT, LVL_ERROR, 301 "Failed setting IPv6 address on internet link."); 302 inet_addrobj_remove(addr6); 303 inet_addrobj_delete(addr6); 304 } 305 } else { 306 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed adding IPv6 address."); 307 inet_addrobj_delete(addr6); 308 } 269 309 } 270 310 … … 298 338 } 299 339 300 /** Send datagram over Internet link */ 301 int inet_link_send_dgram(inet_link_t *ilink, inet_addr_t *lsrc, 302 inet_addr_t *ldest, inet_dgram_t *dgram, uint8_t proto, uint8_t ttl, int df) 303 { 340 /** Send IPv4 datagram over Internet link 341 * 342 * @param ilink Internet link 343 * @param lsrc Source IPv4 address 344 * @param ldest Destination IPv4 address 345 * @param dgram IPv4 datagram body 346 * @param proto Protocol 347 * @param ttl Time-to-live 348 * @param df Do-not-Fragment flag 349 * 350 * @return EOK on success 351 * @return ENOMEM when not enough memory to create the datagram 352 * @return ENOTSUP if networking mode is not supported 353 * 354 */ 355 int inet_link_send_dgram(inet_link_t *ilink, addr32_t lsrc, addr32_t ldest, 356 inet_dgram_t *dgram, uint8_t proto, uint8_t ttl, int df) 357 { 358 addr32_t src_v4; 359 uint16_t src_af = inet_addr_get(&dgram->src, &src_v4, NULL); 360 if (src_af != AF_INET) 361 return EINVAL; 362 363 addr32_t dest_v4; 364 uint16_t dest_af = inet_addr_get(&dgram->dest, &dest_v4, NULL); 365 if (dest_af != AF_INET) 366 return EINVAL; 367 304 368 /* 305 369 * Fill packet structure. Fragmentation is performed by 306 370 * inet_pdu_encode(). 307 371 */ 372 373 iplink_sdu_t sdu; 374 375 sdu.src = lsrc; 376 sdu.dest = ldest; 308 377 309 378 inet_packet_t packet; … … 314 383 packet.proto = proto; 315 384 packet.ttl = ttl; 385 386 /* Allocate identifier */ 387 fibril_mutex_lock(&ip_ident_lock); 388 packet.ident = ++ip_ident; 389 fibril_mutex_unlock(&ip_ident_lock); 390 316 391 packet.df = df; 317 392 packet.data = dgram->data; 318 393 packet.size = dgram->size; 319 394 320 i plink_sdu_t sdu;395 int rc; 321 396 size_t offs = 0; 322 int rc;323 324 sdu.src = *lsrc;325 sdu.dest = *ldest;326 397 327 398 do { 328 399 /* Encode one fragment */ 400 329 401 size_t roffs; 330 rc = inet_pdu_encode(&packet, offs, ilink->def_mtu, &sdu.data,331 &sdu. size, &roffs);402 rc = inet_pdu_encode(&packet, src_v4, dest_v4, offs, ilink->def_mtu, 403 &sdu.data, &sdu.size, &roffs); 332 404 if (rc != EOK) 333 405 return rc; … … 335 407 /* Send the PDU */ 336 408 rc = iplink_send(ilink->iplink, &sdu); 409 337 410 free(sdu.data); 338 411 offs = roffs; 412 } while (offs < packet.size); 413 414 return rc; 415 } 416 417 /** Send IPv6 datagram over Internet link 418 * 419 * @param ilink Internet link 420 * @param ldest Destination MAC address 421 * @param dgram IPv6 datagram body 422 * @param proto Next header 423 * @param ttl Hop limit 424 * @param df Do-not-Fragment flag (unused) 425 * 426 * @return EOK on success 427 * @return ENOMEM when not enough memory to create the datagram 428 * 429 */ 430 int inet_link_send_dgram6(inet_link_t *ilink, addr48_t ldest, 431 inet_dgram_t *dgram, uint8_t proto, uint8_t ttl, int df) 432 { 433 addr128_t src_v6; 434 uint16_t src_af = inet_addr_get(&dgram->src, NULL, &src_v6); 435 if (src_af != AF_INET6) 436 return EINVAL; 437 438 addr128_t dest_v6; 439 uint16_t dest_af = inet_addr_get(&dgram->dest, NULL, &dest_v6); 440 if (dest_af != AF_INET6) 441 return EINVAL; 442 443 iplink_sdu6_t sdu6; 444 addr48(ldest, sdu6.dest); 445 446 /* 447 * Fill packet structure. Fragmentation is performed by 448 * inet_pdu_encode6(). 449 */ 450 451 inet_packet_t packet; 452 453 packet.src = dgram->src; 454 packet.dest = dgram->dest; 455 packet.tos = dgram->tos; 456 packet.proto = proto; 457 packet.ttl = ttl; 458 459 /* Allocate identifier */ 460 fibril_mutex_lock(&ip_ident_lock); 461 packet.ident = ++ip_ident; 462 fibril_mutex_unlock(&ip_ident_lock); 463 464 packet.df = df; 465 packet.data = dgram->data; 466 packet.size = dgram->size; 467 468 int rc; 469 size_t offs = 0; 470 471 do { 472 /* Encode one fragment */ 473 474 size_t roffs; 475 rc = inet_pdu_encode6(&packet, src_v6, dest_v6, offs, ilink->def_mtu, 476 &sdu6.data, &sdu6.size, &roffs); 477 if (rc != EOK) 478 return rc; 479 480 /* Send the PDU */ 481 rc = iplink_send6(ilink->iplink, &sdu6); 482 483 free(sdu6.data); 339 484 offs = roffs; 340 485 } while (offs < packet.size); -
uspace/srv/net/inetsrv/inet_link.h
rcdc3afa r47f5a77 42 42 43 43 extern int inet_link_discovery_start(void); 44 extern int inet_link_send_dgram(inet_link_t *, inet_addr_t *, 45 inet_addr_t *, inet_dgram_t *, uint8_t, uint8_t, int); 44 extern int inet_link_send_dgram(inet_link_t *, addr32_t, 45 addr32_t, inet_dgram_t *, uint8_t, uint8_t, int); 46 extern int inet_link_send_dgram6(inet_link_t *, addr48_t, inet_dgram_t *, 47 uint8_t, uint8_t, int); 46 48 extern inet_link_t *inet_link_get_by_id(sysarg_t); 47 49 -
uspace/srv/net/inetsrv/inet_std.h
rcdc3afa r47f5a77 48 48 /** Total Length */ 49 49 uint16_t tot_len; 50 /** Identifi cation*/50 /** Identifier */ 51 51 uint16_t id; 52 52 /** Flags, Fragment Offset */ … … 90 90 }; 91 91 92 /** Bits in ip6_frag_header_t.offsmf */ 93 enum flags_offsmt_bits { 94 /** More fragments */ 95 OF_FLAG_M = 0, 96 /** Fragment offset, highest bit */ 97 OF_FRAGOFF_h = 15, 98 /** Fragment offset, lowest bit */ 99 OF_FRAGOFF_l = 3 100 }; 101 92 102 /** IPv6 Datagram header (fixed part) */ 93 103 typedef struct { … … 114 124 /** Reserved */ 115 125 uint8_t reserved; 116 /** Fragment Offset, Flags*/117 uint16_t foff_flags;118 /** Identifi cation*/126 /** Fragmentation offset, reserved and M flag */ 127 uint16_t offsmf; 128 /** Identifier */ 119 129 uint32_t id; 120 130 } ip6_header_fragment_t; -
uspace/srv/net/inetsrv/inetping6.c
rcdc3afa r47f5a77 109 109 aid_t req = async_send_1(exch, INETPING6_EV_RECV, sdu->seq_no, &answer); 110 110 111 int rc = async_data_write_start(exch, sdu->src, 16);111 int rc = async_data_write_start(exch, sdu->src, sizeof(addr128_t)); 112 112 if (rc != EOK) { 113 113 async_exchange_end(exch); … … 116 116 } 117 117 118 rc = async_data_write_start(exch, sdu->dest, 16);118 rc = async_data_write_start(exch, sdu->dest, sizeof(addr128_t)); 119 119 if (rc != EOK) { 120 120 async_exchange_end(exch); -
uspace/srv/net/inetsrv/inetsrv.c
rcdc3afa r47f5a77 62 62 #define NAME "inetsrv" 63 63 64 static inet_naddr_t solicited_node_mask = { 65 .family = AF_INET6, 66 .addr6 = {0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01, 0xff, 0, 0, 0}, 67 .prefix = 104 68 }; 69 70 static inet_addr_t multicast_all_nodes = { 71 .family = AF_INET, 72 .addr6 = {0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01} 73 }; 74 64 75 static void inet_client_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg); 65 76 … … 514 525 515 526 addr = inet_addrobj_find(&packet->dest, iaf_addr); 516 if (addr != NULL) { 527 if ((addr != NULL) || 528 (inet_naddr_compare_mask(&solicited_node_mask, &packet->dest)) || 529 (inet_addr_compare(&multicast_all_nodes, &packet->dest))) { 517 530 /* Destined for one of the local addresses */ 518 531 -
uspace/srv/net/inetsrv/inetsrv.h
rcdc3afa r47f5a77 113 113 uint8_t ttl; 114 114 /** Identifier */ 115 uint 16_t ident;115 uint32_t ident; 116 116 /** Do not fragment */ 117 117 bool df; … … 141 141 iplink_t *iplink; 142 142 size_t def_mtu; 143 addr48_t mac; 144 bool mac_valid; 143 145 } inet_link_t; 144 146 -
uspace/srv/net/inetsrv/pdu.c
rcdc3afa r47f5a77 49 49 #include "pdu.h" 50 50 51 static FIBRIL_MUTEX_INITIALIZE(ip_ident_lock);52 static uint16_t ip_ident = 0;53 54 51 /** One's complement addition. 55 52 * … … 88 85 } 89 86 90 /** Encode I nternetPDU.87 /** Encode IPv4 PDU. 91 88 * 92 89 * Encode internet packet into PDU (serialized form). Will encode a … … 96 93 * be set in the header, otherwise the offset will equal @a packet->size. 97 94 * 98 * @param packet Packet to encode 99 * @param offs Offset into packet payload (in bytes) 100 * @param mtu MTU (Maximum Transmission Unit) in bytes 101 * @param rdata Place to store pointer to allocated data buffer 102 * @param rsize Place to store size of allocated data buffer 103 * @param roffs Place to store offset of remaning data 104 */ 105 int inet_pdu_encode(inet_packet_t *packet, size_t offs, size_t mtu, 106 void **rdata, size_t *rsize, size_t *roffs) 107 { 108 addr32_t src_v4; 109 addr128_t src_v6; 110 uint16_t src_af = inet_addr_get(&packet->src, &src_v4, &src_v6); 111 112 addr32_t dest_v4; 113 addr128_t dest_v6; 114 uint16_t dest_af = inet_addr_get(&packet->dest, &dest_v4, &dest_v6); 115 116 if (src_af != dest_af) 117 return EINVAL; 118 95 * @param packet Packet to encode 96 * @param src Source address 97 * @param dest Destination address 98 * @param offs Offset into packet payload (in bytes) 99 * @param mtu MTU (Maximum Transmission Unit) in bytes 100 * @param rdata Place to store pointer to allocated data buffer 101 * @param rsize Place to store size of allocated data buffer 102 * @param roffs Place to store offset of remaning data 103 * 104 */ 105 int inet_pdu_encode(inet_packet_t *packet, addr32_t src, addr32_t dest, 106 size_t offs, size_t mtu, void **rdata, size_t *rsize, size_t *roffs) 107 { 119 108 /* Upper bound for fragment offset field */ 120 109 size_t fragoff_limit = 1 << (FF_FRAGOFF_h - FF_FRAGOFF_l); … … 124 113 return ELIMIT; 125 114 126 size_t hdr_size; 127 128 switch (src_af) { 129 case AF_INET: 130 hdr_size = sizeof(ip_header_t); 131 break; 132 case AF_INET6: 133 hdr_size = sizeof(ip6_header_t); 134 break; 135 default: 136 assert(false); 137 } 115 size_t hdr_size = sizeof(ip_header_t); 138 116 139 117 size_t data_offs = ROUND_UP(hdr_size, 4); … … 171 149 return ENOMEM; 172 150 173 /* Allocate identifier */174 fibril_mutex_lock(&ip_ident_lock);175 uint16_t ident = ++ip_ident;176 fibril_mutex_unlock(&ip_ident_lock);177 178 151 /* Encode header fields */ 179 ip_header_t *hdr; 180 ip6_header_t *hdr6; 181 182 switch (src_af) { 183 case AF_INET: 184 hdr = (ip_header_t *) data; 185 186 hdr->ver_ihl = 187 (4 << VI_VERSION_l) | (hdr_size / sizeof(uint32_t)); 188 hdr->tos = packet->tos; 189 hdr->tot_len = host2uint16_t_be(size); 190 hdr->id = host2uint16_t_be(ident); 191 hdr->flags_foff = host2uint16_t_be(flags_foff); 192 hdr->ttl = packet->ttl; 193 hdr->proto = packet->proto; 194 hdr->chksum = 0; 195 hdr->src_addr = host2uint32_t_be(src_v4); 196 hdr->dest_addr = host2uint32_t_be(dest_v4); 197 198 /* Compute checksum */ 199 uint16_t chksum = inet_checksum_calc(INET_CHECKSUM_INIT, 200 (void *) hdr, hdr_size); 201 hdr->chksum = host2uint16_t_be(chksum); 202 203 break; 204 case AF_INET6: 205 // TODO FIXME: fragmentation 206 207 hdr6 = (ip6_header_t *) data; 208 209 hdr6->ver_tc = (6 << (VI_VERSION_l)); 210 memset(hdr6->tc_fl, 0, 3); 211 hdr6->payload_len = host2uint16_t_be(packet->size); 212 hdr6->next = packet->proto; 213 hdr6->hop_limit = packet->ttl; 214 215 host2addr128_t_be(src_v6, hdr6->src_addr); 216 host2addr128_t_be(dest_v6, hdr6->dest_addr); 217 218 break; 219 default: 220 assert(false); 221 } 152 ip_header_t *hdr = (ip_header_t *) data; 153 154 hdr->ver_ihl = 155 (4 << VI_VERSION_l) | (hdr_size / sizeof(uint32_t)); 156 hdr->tos = packet->tos; 157 hdr->tot_len = host2uint16_t_be(size); 158 hdr->id = host2uint16_t_be(packet->ident); 159 hdr->flags_foff = host2uint16_t_be(flags_foff); 160 hdr->ttl = packet->ttl; 161 hdr->proto = packet->proto; 162 hdr->chksum = 0; 163 hdr->src_addr = host2uint32_t_be(src); 164 hdr->dest_addr = host2uint32_t_be(dest); 165 166 /* Compute checksum */ 167 uint16_t chksum = inet_checksum_calc(INET_CHECKSUM_INIT, 168 (void *) hdr, hdr_size); 169 hdr->chksum = host2uint16_t_be(chksum); 222 170 223 171 /* Copy payload */ … … 231 179 } 232 180 181 /** Encode IPv6 PDU. 182 * 183 * Encode internet packet into PDU (serialized form). Will encode a 184 * fragment of the payload starting at offset @a offs. The resulting 185 * PDU will have at most @a mtu bytes. @a *roffs will be set to the offset 186 * of remaining payload. If some data is remaining, the MF flag will 187 * be set in the header, otherwise the offset will equal @a packet->size. 188 * 189 * @param packet Packet to encode 190 * @param src Source address 191 * @param dest Destination address 192 * @param offs Offset into packet payload (in bytes) 193 * @param mtu MTU (Maximum Transmission Unit) in bytes 194 * @param rdata Place to store pointer to allocated data buffer 195 * @param rsize Place to store size of allocated data buffer 196 * @param roffs Place to store offset of remaning data 197 * 198 */ 199 int inet_pdu_encode6(inet_packet_t *packet, addr128_t src, addr128_t dest, 200 size_t offs, size_t mtu, void **rdata, size_t *rsize, size_t *roffs) 201 { 202 /* Upper bound for fragment offset field */ 203 size_t fragoff_limit = 1 << (FF_FRAGOFF_h - FF_FRAGOFF_l); 204 205 /* Verify that total size of datagram is within reasonable bounds */ 206 if (offs + packet->size > FRAG_OFFS_UNIT * fragoff_limit) 207 return ELIMIT; 208 209 size_t hdr_size = sizeof(ip6_header_t); 210 211 size_t data_offs = ROUND_UP(hdr_size, 4); 212 213 assert(offs % FRAG_OFFS_UNIT == 0); 214 assert(offs / FRAG_OFFS_UNIT < fragoff_limit); 215 216 #if 0 217 // FIXME TODO fragmentation 218 219 /* Value for the fragment offset field */ 220 uint16_t foff = offs / FRAG_OFFS_UNIT; 221 #endif 222 223 if (hdr_size >= mtu) 224 return EINVAL; 225 226 /* Amount of space in the PDU available for payload */ 227 size_t spc_avail = mtu - hdr_size; 228 spc_avail -= (spc_avail % FRAG_OFFS_UNIT); 229 230 /* Amount of data (payload) to transfer */ 231 size_t xfer_size = min(packet->size - offs, spc_avail); 232 233 /* Total PDU size */ 234 size_t size = hdr_size + xfer_size; 235 236 /* Offset of remaining payload */ 237 size_t rem_offs = offs + xfer_size; 238 239 #if 0 240 // FIXME TODO fragmentation 241 242 /* Flags */ 243 uint16_t flags_foff = 244 (packet->df ? BIT_V(uint16_t, FF_FLAG_DF) : 0) + 245 (rem_offs < packet->size ? BIT_V(uint16_t, FF_FLAG_MF) : 0) + 246 (foff << FF_FRAGOFF_l); 247 #endif 248 249 void *data = calloc(size, 1); 250 if (data == NULL) 251 return ENOMEM; 252 253 /* Encode header fields */ 254 ip6_header_t *hdr6 = (ip6_header_t *) data; 255 256 hdr6->ver_tc = (6 << (VI_VERSION_l)); 257 memset(hdr6->tc_fl, 0, 3); 258 hdr6->payload_len = host2uint16_t_be(packet->size); 259 hdr6->next = packet->proto; 260 hdr6->hop_limit = packet->ttl; 261 262 host2addr128_t_be(src, hdr6->src_addr); 263 host2addr128_t_be(dest, hdr6->dest_addr); 264 265 /* Copy payload */ 266 memcpy((uint8_t *) data + data_offs, packet->data + offs, xfer_size); 267 268 *rdata = data; 269 *rsize = size; 270 *roffs = rem_offs; 271 272 return EOK; 273 } 274 275 /** Decode IPv4 datagram 276 * 277 * @param data Serialized IPv4 datagram 278 * @param size Length of serialized IPv4 datagram 279 * @param packet IP datagram structure to be filled 280 * 281 * @return EOK on success 282 * @return EINVAL if the datagram is invalid or damaged 283 * @return ENOMEM if not enough memory 284 * 285 */ 233 286 int inet_pdu_decode(void *data, size_t size, inet_packet_t *packet) 234 287 { … … 257 310 if (tot_len > size) { 258 311 log_msg(LOG_DEFAULT, LVL_DEBUG, "Total Length = %zu > PDU size = %zu", 259 312 tot_len, size); 260 313 return EINVAL; 261 314 } … … 294 347 } 295 348 349 /** Decode IPv6 datagram 350 * 351 * @param data Serialized IPv6 datagram 352 * @param size Length of serialized IPv6 datagram 353 * @param packet IP datagram structure to be filled 354 * 355 * @return EOK on success 356 * @return EINVAL if the datagram is invalid or damaged 357 * @return ENOMEM if not enough memory 358 * 359 */ 296 360 int inet_pdu_decode6(void *data, size_t size, inet_packet_t *packet) 297 361 { 298 // FIXME TODO 299 return ENOTSUP; 362 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_pdu_decode6()"); 363 364 if (size < sizeof(ip6_header_t)) { 365 log_msg(LOG_DEFAULT, LVL_DEBUG, "PDU too short (%zu)", size); 366 return EINVAL; 367 } 368 369 ip6_header_t *hdr6 = (ip6_header_t *) data; 370 371 uint8_t version = BIT_RANGE_EXTRACT(uint8_t, VI_VERSION_h, 372 VI_VERSION_l, hdr6->ver_tc); 373 if (version != 6) { 374 log_msg(LOG_DEFAULT, LVL_DEBUG, "Version (%d) != 6", version); 375 return EINVAL; 376 } 377 378 size_t payload_len = uint16_t_be2host(hdr6->payload_len); 379 if (payload_len + sizeof(ip6_header_t) > size) { 380 log_msg(LOG_DEFAULT, LVL_DEBUG, "Total Length = %zu > PDU size = %zu", 381 payload_len + sizeof(ip6_header_t), size); 382 return EINVAL; 383 } 384 385 #if 0 386 // FIXME TODO fragmentation 387 388 uint16_t ident = uint16_t_be2host(hdr->id); 389 uint16_t flags_foff = uint16_t_be2host(hdr->flags_foff); 390 uint16_t foff = BIT_RANGE_EXTRACT(uint16_t, FF_FRAGOFF_h, FF_FRAGOFF_l, 391 flags_foff); 392 #endif 393 394 /* XXX Checksum */ 395 396 addr128_t src; 397 addr128_t dest; 398 399 addr128_t_be2host(hdr6->src_addr, src); 400 inet_addr_set6(src, &packet->src); 401 402 addr128_t_be2host(hdr6->dest_addr, dest); 403 inet_addr_set6(dest, &packet->dest); 404 405 packet->tos = 0; 406 packet->proto = hdr6->next; 407 packet->ttl = hdr6->hop_limit; 408 409 #if 0 410 // FIXME TODO fragmentation 411 412 packet->ident = ident; 413 packet->df = (flags_foff & BIT_V(uint16_t, FF_FLAG_DF)) != 0; 414 packet->mf = (flags_foff & BIT_V(uint16_t, FF_FLAG_MF)) != 0; 415 packet->offs = foff * FRAG_OFFS_UNIT; 416 417 /* XXX IP options */ 418 size_t data_offs = sizeof(uint32_t) * 419 BIT_RANGE_EXTRACT(uint8_t, VI_IHL_h, VI_IHL_l, hdr->ver_ihl); 420 #endif 421 422 packet->ident = 0; 423 packet->df = 0; 424 packet->mf = 0; 425 packet->offs = 0; 426 427 packet->size = payload_len; 428 packet->data = calloc(packet->size, 1); 429 if (packet->data == NULL) { 430 log_msg(LOG_DEFAULT, LVL_WARN, "Out of memory."); 431 return ENOMEM; 432 } 433 434 memcpy(packet->data, (uint8_t *) data + sizeof(ip6_header_t), packet->size); 435 436 return EOK; 437 } 438 439 /** Encode NDP packet 440 * 441 * @param ndp NDP packet structure to be serialized 442 * @param dgram IPv6 datagram structure to be filled 443 * 444 * @return EOK on success 445 * 446 */ 447 int ndp_pdu_encode(ndp_packet_t *ndp, inet_dgram_t *dgram) 448 { 449 inet_addr_set6(ndp->sender_proto_addr, &dgram->src); 450 inet_addr_set6(ndp->target_proto_addr, &dgram->dest); 451 dgram->tos = 0; 452 dgram->size = sizeof(icmpv6_message_t) + sizeof(ndp_message_t); 453 454 dgram->data = calloc(1, dgram->size); 455 if (dgram->data == NULL) 456 return ENOMEM; 457 458 icmpv6_message_t *icmpv6 = (icmpv6_message_t *) dgram->data; 459 460 icmpv6->type = ndp->opcode; 461 icmpv6->code = 0; 462 memset(icmpv6->un.ndp.reserved, 0, 3); 463 464 ndp_message_t *message = (ndp_message_t *) (icmpv6 + 1); 465 466 if (ndp->opcode == ICMPV6_NEIGHBOUR_SOLICITATION) { 467 host2addr128_t_be(ndp->solicited_ip, message->target_address); 468 message->option = 1; 469 icmpv6->un.ndp.flags = 0; 470 } else { 471 host2addr128_t_be(ndp->sender_proto_addr, message->target_address); 472 message->option = 2; 473 icmpv6->un.ndp.flags = NDP_FLAG_OVERRIDE | NDP_FLAG_SOLICITED; 474 } 475 476 message->length = 1; 477 addr48(ndp->sender_hw_addr, message->mac); 478 479 icmpv6_phdr_t phdr; 480 481 host2addr128_t_be(ndp->sender_proto_addr, phdr.src_addr); 482 host2addr128_t_be(ndp->target_proto_addr, phdr.dest_addr); 483 phdr.length = host2uint32_t_be(dgram->size); 484 memset(phdr.zeroes, 0, 3); 485 phdr.next = IP_PROTO_ICMPV6; 486 487 uint16_t cs_phdr = 488 inet_checksum_calc(INET_CHECKSUM_INIT, &phdr, 489 sizeof(icmpv6_phdr_t)); 490 491 uint16_t cs_all = inet_checksum_calc(cs_phdr, dgram->data, 492 dgram->size); 493 494 icmpv6->checksum = host2uint16_t_be(cs_all); 495 496 return EOK; 497 } 498 499 /** Decode NDP packet 500 * 501 * @param dgram Incoming IPv6 datagram encapsulating NDP packet 502 * @param ndp NDP packet structure to be filled 503 * 504 * @return EOK on success 505 * @return EINVAL if the Datagram is invalid 506 * 507 */ 508 int ndp_pdu_decode(inet_dgram_t *dgram, ndp_packet_t *ndp) 509 { 510 uint16_t src_af = inet_addr_get(&dgram->src, NULL, 511 &ndp->sender_proto_addr); 512 if (src_af != AF_INET6) 513 return EINVAL; 514 515 if (dgram->size < sizeof(icmpv6_message_t) + sizeof(ndp_message_t)) 516 return EINVAL; 517 518 icmpv6_message_t *icmpv6 = (icmpv6_message_t *) dgram->data; 519 520 ndp->opcode = icmpv6->type; 521 522 ndp_message_t *message = (ndp_message_t *) (icmpv6 + 1); 523 524 addr128_t_be2host(message->target_address, ndp->target_proto_addr); 525 addr48(message->mac, ndp->sender_hw_addr); 526 527 return EOK; 300 528 } 301 529 -
uspace/srv/net/inetsrv/pdu.h
rcdc3afa r47f5a77 40 40 #include <sys/types.h> 41 41 #include "inetsrv.h" 42 #include "ndp.h" 42 43 43 44 #define INET_CHECKSUM_INIT 0xffff … … 45 46 extern uint16_t inet_checksum_calc(uint16_t, void *, size_t); 46 47 47 extern int inet_pdu_encode(inet_packet_t *, size_t, size_t, void **, 48 size_t *, size_t *); 48 extern int inet_pdu_encode(inet_packet_t *, addr32_t, addr32_t, size_t, size_t, 49 void **, size_t *, size_t *); 50 extern int inet_pdu_encode6(inet_packet_t *, addr128_t, addr128_t, size_t, 51 size_t, void **, size_t *, size_t *); 49 52 extern int inet_pdu_decode(void *, size_t, inet_packet_t *); 50 53 extern int inet_pdu_decode6(void *, size_t, inet_packet_t *); 54 55 extern int ndp_pdu_decode(inet_dgram_t *, ndp_packet_t *); 56 extern int ndp_pdu_encode(ndp_packet_t *, inet_dgram_t *); 51 57 52 58 #endif -
uspace/srv/net/loopip/loopip.c
rcdc3afa r47f5a77 40 40 #include <inet/iplink_srv.h> 41 41 #include <inet/addr.h> 42 #include <net/socket_codes.h> 42 43 #include <io/log.h> 43 44 #include <loc.h> … … 50 51 static int loopip_close(iplink_srv_t *srv); 51 52 static int loopip_send(iplink_srv_t *srv, iplink_sdu_t *sdu); 53 static int loopip_send6(iplink_srv_t *srv, iplink_sdu6_t *sdu); 52 54 static int loopip_get_mtu(iplink_srv_t *srv, size_t *mtu); 55 static int loopip_get_mac48(iplink_srv_t *srv, addr48_t *mac); 53 56 static int loopip_addr_add(iplink_srv_t *srv, inet_addr_t *addr); 54 57 static int loopip_addr_remove(iplink_srv_t *srv, inet_addr_t *addr); … … 60 63 .close = loopip_close, 61 64 .send = loopip_send, 65 .send6 = loopip_send6, 62 66 .get_mtu = loopip_get_mtu, 67 .get_mac48 = loopip_get_mac48, 63 68 .addr_add = loopip_addr_add, 64 69 .addr_remove = loopip_addr_remove … … 162 167 log_msg(LOG_DEFAULT, LVL_DEBUG, "loopip_send()"); 163 168 164 addr32_t src_v4;165 addr128_t src_v6;166 uint16_t src_af = inet_addr_get(&sdu->src, &src_v4, &src_v6);167 168 addr32_t dest_v4;169 addr128_t dest_v6;170 uint16_t dest_af = inet_addr_get(&sdu->dest, &dest_v4, &dest_v6);171 172 if (src_af != dest_af)173 return EINVAL;174 175 169 rqueue_entry_t *rqe = calloc(1, sizeof(rqueue_entry_t)); 176 170 if (rqe == NULL) … … 180 174 * Clone SDU 181 175 */ 182 rqe->af = src_af;176 rqe->af = AF_INET; 183 177 rqe->sdu.data = malloc(sdu->size); 184 178 if (rqe->sdu.data == NULL) { … … 198 192 } 199 193 194 static int loopip_send6(iplink_srv_t *srv, iplink_sdu6_t *sdu) 195 { 196 log_msg(LOG_DEFAULT, LVL_DEBUG, "loopip6_send()"); 197 198 rqueue_entry_t *rqe = calloc(1, sizeof(rqueue_entry_t)); 199 if (rqe == NULL) 200 return ENOMEM; 201 202 /* 203 * Clone SDU 204 */ 205 rqe->af = AF_INET6; 206 rqe->sdu.data = malloc(sdu->size); 207 if (rqe->sdu.data == NULL) { 208 free(rqe); 209 return ENOMEM; 210 } 211 212 memcpy(rqe->sdu.data, sdu->data, sdu->size); 213 rqe->sdu.size = sdu->size; 214 215 /* 216 * Insert to receive queue 217 */ 218 prodcons_produce(&loopip_rcv_queue, &rqe->link); 219 220 return EOK; 221 } 222 200 223 static int loopip_get_mtu(iplink_srv_t *srv, size_t *mtu) 201 224 { … … 203 226 *mtu = 1500; 204 227 return EOK; 228 } 229 230 static int loopip_get_mac48(iplink_srv_t *src, addr48_t *mac) 231 { 232 log_msg(LOG_DEFAULT, LVL_DEBUG, "loopip_get_mac48()"); 233 return ENOTSUP; 205 234 } 206 235 -
uspace/srv/net/slip/slip.c
rcdc3afa r47f5a77 58 58 static int slip_close(iplink_srv_t *); 59 59 static int slip_send(iplink_srv_t *, iplink_sdu_t *); 60 static int slip_send6(iplink_srv_t *, iplink_sdu6_t *); 60 61 static int slip_get_mtu(iplink_srv_t *, size_t *); 62 static int slip_get_mac48(iplink_srv_t *, addr48_t *); 61 63 static int slip_addr_add(iplink_srv_t *, inet_addr_t *); 62 64 static int slip_addr_remove(iplink_srv_t *, inet_addr_t *); … … 68 70 .close = slip_close, 69 71 .send = slip_send, 72 .send6 = slip_send6, 70 73 .get_mtu = slip_get_mtu, 74 .get_mac48 = slip_get_mac48, 71 75 .addr_add = slip_addr_add, 72 76 .addr_remove = slip_addr_remove … … 122 126 int slip_send(iplink_srv_t *srv, iplink_sdu_t *sdu) 123 127 { 128 log_msg(LOG_DEFAULT, LVL_DEBUG, "slip_send()"); 129 124 130 async_sess_t *sess = (async_sess_t *) srv->arg; 125 131 uint8_t *data = sdu->data; 126 unsigned i; 127 128 log_msg(LOG_DEFAULT, LVL_DEBUG, "slip_send()"); 129 132 130 133 /* 131 132 133 134 134 * Strictly speaking, this is not prescribed by the RFC, but the RFC 135 * suggests to start with sending a SLIP_END byte as a synchronization 136 * measure for dealing with previous possible noise on the line. 137 */ 135 138 write_buffered(sess, SLIP_END); 136 137 for ( i = 0; i < sdu->size; i++) {139 140 for (size_t i = 0; i < sdu->size; i++) { 138 141 switch (data[i]) { 139 142 case SLIP_END: … … 150 153 } 151 154 } 155 152 156 write_buffered(sess, SLIP_END); 153 157 write_flush(sess); 154 155 return EOK; 158 159 return EOK; 160 } 161 162 int slip_send6(iplink_srv_t *srv, iplink_sdu6_t *sdu) 163 { 164 log_msg(LOG_DEFAULT, LVL_DEBUG, "slip_send6()"); 165 166 return ENOTSUP; 156 167 } 157 168 … … 161 172 *mtu = SLIP_MTU; 162 173 return EOK; 174 } 175 176 int slip_get_mac48(iplink_srv_t *src, addr48_t *mac) 177 { 178 log_msg(LOG_DEFAULT, LVL_DEBUG, "slip_get_mac48()"); 179 return ENOTSUP; 163 180 } 164 181 -
uspace/srv/net/tcp/conn.c
rcdc3afa r47f5a77 312 312 static bool tcp_socket_match(tcp_sock_t *sock, tcp_sock_t *patt) 313 313 { 314 log_msg(LOG_DEFAULT, LVL_DEBUG2, 315 "tcp_socket_match(sock=(%u), pat=(%u))", sock->port, patt->port); 316 314 317 if ((!inet_addr_is_any(&patt->addr)) && 315 318 (!inet_addr_compare(&patt->addr, &sock->addr))) … … 351 354 { 352 355 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_conn_find_ref(%p)", sp); 356 357 log_msg(LOG_DEFAULT, LVL_DEBUG2, "compare conn (f:(%u), l:(%u))", 358 sp->foreign.port, sp->local.port); 353 359 354 360 fibril_mutex_lock(&conn_list_lock); … … 357 363 tcp_conn_t *conn = list_get_instance(link, tcp_conn_t, link); 358 364 tcp_sockpair_t *csp = &conn->ident; 365 366 log_msg(LOG_DEFAULT, LVL_DEBUG2, " - with (f:(%u), l:(%u))", 367 csp->foreign.port, csp->local.port); 359 368 360 369 if (tcp_sockpair_match(sp, csp)) { -
uspace/srv/net/tcp/pdu.c
rcdc3afa r47f5a77 172 172 phdr6->tcp_length = 173 173 host2uint32_t_be(pdu->header_size + pdu->text_size); 174 memset(phdr6->zero , 0, 3);174 memset(phdr6->zeroes, 0, 3); 175 175 phdr6->next = IP_PROTO_TCP; 176 176 break; -
uspace/srv/net/tcp/sock.c
rcdc3afa r47f5a77 613 613 ipc_callid_t wcallid; 614 614 size_t length; 615 uint8_t buffer[TCP_SOCK_FRAGMENT_SIZE];616 615 tcp_error_t trc; 617 616 int rc; 617 618 uint8_t *buffer = calloc(TCP_SOCK_FRAGMENT_SIZE, 1); 619 if (buffer == NULL) { 620 async_answer_0(callid, ENOMEM); 621 return; 622 } 618 623 619 624 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_send()"); … … 625 630 if (sock_core == NULL) { 626 631 async_answer_0(callid, ENOTSOCK); 627 return;632 goto out; 628 633 } 629 634 … … 641 646 fibril_mutex_unlock(&socket->lock); 642 647 async_answer_0(callid, EINVAL); 643 return;648 goto out; 644 649 } 645 650 … … 651 656 fibril_mutex_unlock(&socket->lock); 652 657 async_answer_0(callid, rc); 653 return;658 goto out; 654 659 } 655 660 … … 676 681 fibril_mutex_unlock(&socket->lock); 677 682 async_answer_0(callid, rc); 678 return;683 goto out; 679 684 } 680 685 } … … 685 690 IPC_GET_ARG2(answer)); 686 691 fibril_mutex_unlock(&socket->lock); 692 693 out: 694 free(buffer); 687 695 } 688 696 -
uspace/srv/net/tcp/std.h
rcdc3afa r47f5a77 75 75 }; 76 76 77 /** TCP IPv4pseudo header */77 /** TCP over IPv4 checksum pseudo header */ 78 78 typedef struct { 79 79 /** Source address */ … … 89 89 } tcp_phdr_t; 90 90 91 /** TCP IPv6pseudo header */91 /** TCP over IPv6 checksum pseudo header */ 92 92 typedef struct { 93 93 /** Source address */ … … 98 98 uint32_t tcp_length; 99 99 /** Zeroes */ 100 uint8_t zero [3];100 uint8_t zeroes[3]; 101 101 /** Next header */ 102 102 uint8_t next; -
uspace/srv/net/tcp/tcp.c
rcdc3afa r47f5a77 54 54 #define NAME "tcp" 55 55 56 #define IP_PROTO_TCP 657 58 56 static int tcp_inet_ev_recv(inet_dgram_t *dgram); 59 57 static void tcp_received_pdu(tcp_pdu_t *pdu); -
uspace/srv/net/tcp/tqueue.c
rcdc3afa r47f5a77 282 282 void tcp_transmit_segment(tcp_sockpair_t *sp, tcp_segment_t *seg) 283 283 { 284 log_msg(LOG_DEFAULT, LVL_DEBUG, 285 "tcp_transmit_segment(f:(%u),l:(%u), %p)", 286 sp->local.port, sp->foreign.port, seg); 287 284 288 log_msg(LOG_DEFAULT, LVL_DEBUG, "SEG.SEQ=%" PRIu32 ", SEG.WND=%" PRIu32, 285 289 seg->seq, seg->wnd); -
uspace/srv/net/tcp/ucall.c
rcdc3afa r47f5a77 298 298 tcp_conn_t *conn; 299 299 300 log_msg(LOG_DEFAULT, LVL_DEBUG, 301 "tcp_as_segment_arrived(f:(%u), l:(%u))", 302 sp->foreign.port, sp->local.port); 303 300 304 conn = tcp_conn_find_ref(sp); 301 305 if (conn == NULL) { -
uspace/srv/net/udp/assoc.c
rcdc3afa r47f5a77 372 372 static bool udp_socket_match(udp_sock_t *sock, udp_sock_t *patt) 373 373 { 374 log_msg(LOG_DEFAULT, LVL_DEBUG, 375 "udp_socket_match(sock=(%u), pat=(%u))", sock->port, patt->port); 376 374 377 if ((!inet_addr_is_any(&patt->addr)) && 375 378 (!inet_addr_compare(&patt->addr, &sock->addr))) -
uspace/srv/net/udp/pdu.c
rcdc3afa r47f5a77 110 110 host2addr128_t_be(dest_v6, phdr6->dest_addr); 111 111 phdr6->udp_length = host2uint32_t_be(pdu->data_size); 112 memset(phdr6->zero , 0, 3);112 memset(phdr6->zeroes, 0, 3); 113 113 phdr6->next = IP_PROTO_UDP; 114 114 break; -
uspace/srv/net/udp/sock.c
rcdc3afa r47f5a77 265 265 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_send()"); 266 266 267 uint8_t *buffer = calloc(UDP_FRAGMENT_SIZE, 1); 268 if (buffer == NULL) { 269 async_answer_0(callid, ENOMEM); 270 return; 271 } 272 267 273 struct sockaddr_in6 *addr6 = NULL; 268 274 struct sockaddr_in *addr; … … 276 282 if (rc != EOK) { 277 283 async_answer_0(callid, rc); 278 return;284 goto out; 279 285 } 280 286 … … 357 363 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_sendto: Failed to " 358 364 "determine local address."); 359 return;365 goto out; 360 366 } 361 367 … … 379 385 length = UDP_FRAGMENT_SIZE; 380 386 381 uint8_t buffer[UDP_FRAGMENT_SIZE];382 387 int rc = async_data_write_finalize(wcallid, buffer, length); 383 388 if (rc != EOK) { … … 425 430 if (addr6 != NULL) 426 431 free(addr6); 432 433 free(buffer); 427 434 } 428 435 -
uspace/srv/net/udp/std.h
rcdc3afa r47f5a77 54 54 } udp_header_t; 55 55 56 /** UDP IPv4pseudo header */56 /** UDP over IPv4 checksum pseudo header */ 57 57 typedef struct { 58 58 /** Source address */ … … 68 68 } udp_phdr_t; 69 69 70 /** UDP IPv6pseudo header */70 /** UDP over IPv6 checksum pseudo header */ 71 71 typedef struct { 72 72 /** Source address */ … … 76 76 /** UDP length */ 77 77 uint32_t udp_length; 78 /** Reserved*/79 uint8_t zero [3];78 /** Zeroes */ 79 uint8_t zeroes[3]; 80 80 /** Next header */ 81 81 uint8_t next;
Note:
See TracChangeset
for help on using the changeset viewer.