Changes in / [119b46e:8fe2c9bd] in mainline
- Files:
-
- 1 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
contrib/conf/ia32-qe.sh
r119b46e r8fe2c9bd 1 1 #!/bin/sh 2 3 if [ -z "${QEMU_BINARY}" ] ; then4 QEMU_BINARY="`which --tty-only qemu 2> /dev/null`"5 fi6 7 if [ -z "${QEMU_BINARY}" ] ; then8 QEMU_BINARY="`which --tty-only qemu-system-i386 2> /dev/null`"9 fi10 11 if [ -z "${QEMU_BINARY}" ] ; then12 echo "QEMU binary not found"13 fi14 2 15 3 DISK_IMG=hdisk.img … … 20 8 fi 21 9 22 "${QEMU_BINARY}" "$@"-m 32 -hda "$DISK_IMG" -cdrom image.iso -boot d10 qemu $@ -m 32 -hda "$DISK_IMG" -cdrom image.iso -boot d -
contrib/conf/net-qe.sh
r119b46e r8fe2c9bd 1 1 #!/bin/sh 2 3 if [ -z "${QEMU_BINARY}" ] ; then4 QEMU_BINARY="`which --tty-only qemu 2> /dev/null`"5 fi6 7 if [ -z "${QEMU_BINARY}" ] ; then8 QEMU_BINARY="`which --tty-only qemu-system-x86_64 2> /dev/null`"9 fi10 11 if [ -z "${QEMU_BINARY}" ] ; then12 QEMU_BINARY="`which --tty-only qemu-system-i386 2> /dev/null`"13 fi14 15 if [ -z "${QEMU_BINARY}" ] ; then16 echo "QEMU binary not found"17 fi18 2 19 3 case "$1" in 20 4 ne2k) 21 5 shift 22 "${QEMU_BINARY}" "$@"-device ne2k_isa,irq=5,vlan=0 -net user -boot d -redir udp:8080::8080 -redir udp:8081::8081 -redir tcp:8080::8080 -redir tcp:8081::8081 -cdrom image.iso6 qemu $@ -device ne2k_isa,irq=5,vlan=0 -net user -boot d -redir udp:8080::8080 -redir udp:8081::8081 -redir tcp:8080::8080 -redir tcp:8081::8081 -cdrom image.iso 23 7 ;; 24 8 e1k) 25 9 shift 26 "${QEMU_BINARY}" "$@"-device e1000,vlan=0 -net user -boot d -redir udp:8080::8080 -redir udp:8081::8081 -redir tcp:8080::8080 -redir tcp:8081::8081 -cdrom image.iso10 qemu $@ -device e1000,vlan=0 -net user -boot d -redir udp:8080::8080 -redir udp:8081::8081 -redir tcp:8080::8080 -redir tcp:8081::8081 -cdrom image.iso 27 11 ;; 28 12 rtl8139) 29 13 shift 30 "${QEMU_BINARY}" "$@"-device rtl8139,vlan=0 -net user -boot d -redir udp:8080::8080 -redir udp:8081::8081 -redir tcp:8080::8080 -redir tcp:8081::8081 -cdrom image.iso14 qemu $@ -device rtl8139,vlan=0 -net user -boot d -redir udp:8080::8080 -redir udp:8081::8081 -redir tcp:8080::8080 -redir tcp:8081::8081 -cdrom image.iso 31 15 ;; 32 16 *) -
uspace/app/netecho/netecho.c
r119b46e r8fe2c9bd 243 243 if (verbose) 244 244 printf("accept()\n"); 245 245 socket_id = accept(listening_id, (void *) address_buf, &addrlen); 246 246 if (socket_id <= 0) { 247 247 socket_print_error(stderr, socket_id, "Socket accept: ", "\n"); … … 312 312 rc = sendto(socket_id, reply ? reply : data, reply ? reply_length : length, 0, address, addrlen); 313 313 if (rc != EOK) 314 socket_print_error(stderr, rc, "Socket send to: ", "\n");314 socket_print_error(stderr, rc, "Socket send: ", "\n"); 315 315 } 316 316 } … … 394 394 return listening_id; 395 395 } 396 397 /* Bind the listening socket */ 398 rc = bind(listening_id, address, addrlen); 399 if (rc != EOK) { 400 socket_print_error(stderr, rc, "Socket bind: ", "\n"); 401 return rc; 402 } 403 396 404 397 /* if the stream socket is used */ 405 398 if (type == SOCK_STREAM) { … … 409 402 backlog = 3; 410 403 } 411 404 412 405 /* Set the backlog */ 413 406 rc = listen(listening_id, backlog); … … 416 409 return rc; 417 410 } 411 } 412 413 /* Bind the listening socket */ 414 rc = bind(listening_id, address, addrlen); 415 if (rc != EOK) { 416 socket_print_error(stderr, rc, "Socket bind: ", "\n"); 417 return rc; 418 418 } 419 419 -
uspace/app/nettest3/nettest3.c
r119b46e r8fe2c9bd 63 63 port = 7; 64 64 65 data = (char *) 65 data = (char *)"Hello World!"; 66 66 size = str_size(data); 67 67 … … 98 98 99 99 printf("connect()\n"); 100 rc = connect(fd, (struct sockaddr *) 100 rc = connect(fd, (struct sockaddr *)&addr, sizeof(addr)); 101 101 printf(" -> %d\n", rc); 102 102 if (rc != 0) … … 115 115 } while (rc > 0); 116 116 117 async_usleep(1000 *1000);117 async_usleep(1000*1000); 118 118 119 119 printf("closesocket()\n"); … … 124 124 } 125 125 126 126 127 /** @} 127 128 */ -
uspace/lib/c/generic/async.c
r119b46e r8fe2c9bd 2068 2068 2069 2069 async_sess_t *sess = exch->sess; 2070 assert(sess != NULL);2071 2070 2072 2071 atomic_dec(&sess->refcnt); -
uspace/lib/c/generic/net/socket_client.c
r119b46e r8fe2c9bd 192 192 /** Default thread for new connections. 193 193 * 194 * @param[in] iid The initial message identifier. 195 * @param[in] icall The initial message call structure. 196 * @param[in] arg Local argument. 197 * 194 * @param[in] iid The initial message identifier. 195 * @param[in] icall The initial message call structure. 196 * @param[in] arg Local argument. 198 197 */ 199 198 static void socket_connection(ipc_callid_t iid, ipc_call_t * icall, void *arg) 200 199 { 201 while (true) { 202 ipc_call_t call; 203 ipc_callid_t callid = async_get_call(&call); 204 205 if (!IPC_GET_IMETHOD(call)) { 206 async_answer_0(callid, 0); 207 return; 200 ipc_callid_t callid; 201 ipc_call_t call; 202 socket_t *socket; 203 int rc; 204 205 loop: 206 callid = async_get_call(&call); 207 208 switch (IPC_GET_IMETHOD(call)) { 209 case NET_SOCKET_RECEIVED: 210 case NET_SOCKET_ACCEPTED: 211 case NET_SOCKET_DATA_FRAGMENT_SIZE: 212 fibril_rwlock_read_lock(&socket_globals.lock); 213 214 /* Find the socket */ 215 socket = sockets_find(socket_get_sockets(), 216 SOCKET_GET_SOCKET_ID(call)); 217 if (!socket) { 218 rc = ENOTSOCK; 219 fibril_rwlock_read_unlock(&socket_globals.lock); 220 break; 208 221 } 209 210 int rc;211 222 212 223 switch (IPC_GET_IMETHOD(call)) { 213 224 case NET_SOCKET_RECEIVED: 225 fibril_mutex_lock(&socket->receive_lock); 226 /* Push the number of received packet fragments */ 227 rc = dyn_fifo_push(&socket->received, 228 SOCKET_GET_DATA_FRAGMENTS(call), 229 SOCKET_MAX_RECEIVED_SIZE); 230 if (rc == EOK) { 231 /* Signal the received packet */ 232 fibril_condvar_signal(&socket->receive_signal); 233 } 234 fibril_mutex_unlock(&socket->receive_lock); 235 break; 236 214 237 case NET_SOCKET_ACCEPTED: 215 case NET_SOCKET_DATA_FRAGMENT_SIZE: 216 fibril_rwlock_read_lock(&socket_globals.lock); 217 218 /* Find the socket */ 219 socket_t *socket = sockets_find(socket_get_sockets(), 220 SOCKET_GET_SOCKET_ID(call)); 221 if (!socket) { 222 rc = ENOTSOCK; 223 fibril_rwlock_read_unlock(&socket_globals.lock); 224 break; 238 /* Push the new socket identifier */ 239 fibril_mutex_lock(&socket->accept_lock); 240 rc = dyn_fifo_push(&socket->accepted, 1, 241 SOCKET_MAX_ACCEPTED_SIZE); 242 if (rc == EOK) { 243 /* Signal the accepted socket */ 244 fibril_condvar_signal(&socket->accept_signal); 225 245 } 226 227 switch (IPC_GET_IMETHOD(call)) { 228 case NET_SOCKET_RECEIVED: 229 fibril_mutex_lock(&socket->receive_lock); 230 /* Push the number of received packet fragments */ 231 rc = dyn_fifo_push(&socket->received, 232 SOCKET_GET_DATA_FRAGMENTS(call), 233 SOCKET_MAX_RECEIVED_SIZE); 234 if (rc == EOK) { 235 /* Signal the received packet */ 236 fibril_condvar_signal(&socket->receive_signal); 237 } 238 fibril_mutex_unlock(&socket->receive_lock); 239 break; 240 241 case NET_SOCKET_ACCEPTED: 242 /* Push the new socket identifier */ 243 fibril_mutex_lock(&socket->accept_lock); 244 rc = dyn_fifo_push(&socket->accepted, 1, 245 SOCKET_MAX_ACCEPTED_SIZE); 246 if (rc == EOK) { 247 /* Signal the accepted socket */ 248 fibril_condvar_signal(&socket->accept_signal); 249 } 250 fibril_mutex_unlock(&socket->accept_lock); 251 break; 252 253 default: 254 rc = ENOTSUP; 255 } 256 257 if ((SOCKET_GET_DATA_FRAGMENT_SIZE(call) > 0) && 258 (SOCKET_GET_DATA_FRAGMENT_SIZE(call) != 259 socket->data_fragment_size)) { 260 fibril_rwlock_write_lock(&socket->sending_lock); 261 262 /* Set the data fragment size */ 263 socket->data_fragment_size = 264 SOCKET_GET_DATA_FRAGMENT_SIZE(call); 265 266 fibril_rwlock_write_unlock(&socket->sending_lock); 267 } 268 269 fibril_rwlock_read_unlock(&socket_globals.lock); 246 fibril_mutex_unlock(&socket->accept_lock); 270 247 break; 271 248 272 249 default: 273 250 rc = ENOTSUP; 274 251 } 275 276 async_answer_0(callid, (sysarg_t) rc); 277 } 252 253 if ((SOCKET_GET_DATA_FRAGMENT_SIZE(call) > 0) && 254 (SOCKET_GET_DATA_FRAGMENT_SIZE(call) != 255 socket->data_fragment_size)) { 256 fibril_rwlock_write_lock(&socket->sending_lock); 257 258 /* Set the data fragment size */ 259 socket->data_fragment_size = 260 SOCKET_GET_DATA_FRAGMENT_SIZE(call); 261 262 fibril_rwlock_write_unlock(&socket->sending_lock); 263 } 264 265 fibril_rwlock_read_unlock(&socket_globals.lock); 266 break; 267 268 default: 269 rc = ENOTSUP; 270 } 271 272 async_answer_0(callid, (sysarg_t) rc); 273 goto loop; 278 274 } 279 275 -
uspace/srv/net/tcp/conn.c
r119b46e r8fe2c9bd 354 354 { 355 355 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_conn_find_ref(%p)", sp); 356 357 log_msg(LOG_DEFAULT, LVL_DEBUG2, "compare conn (f:(%x,%u), l:(%x,%u))", 358 sp->foreign.addr.ipv4, sp->foreign.port, 359 sp->local.addr.ipv4, sp->local.port); 360 356 361 357 fibril_mutex_lock(&conn_list_lock); 362 358 363 359 list_foreach(conn_list, link) { 364 360 tcp_conn_t *conn = list_get_instance(link, tcp_conn_t, link); 365 361 tcp_sockpair_t *csp = &conn->ident; 366 367 log_msg(LOG_DEFAULT, LVL_DEBUG2, " - with (f:(%x,%u), l:(%x,%u))", 362 log_msg(LOG_DEFAULT, LVL_DEBUG2, "compare with conn (f:(%x,%u), l:(%x,%u))", 368 363 csp->foreign.addr.ipv4, csp->foreign.port, 369 364 csp->local.addr.ipv4, csp->local.port); 370 371 365 if (tcp_sockpair_match(sp, csp)) { 372 366 tcp_conn_addref(conn); … … 375 369 } 376 370 } 377 371 378 372 fibril_mutex_unlock(&conn_list_lock); 379 373 return NULL; -
uspace/srv/net/tcp/sock.c
r119b46e r8fe2c9bd 203 203 { 204 204 int rc; 205 struct sockaddr _in*addr;206 size_t addr_ size;205 struct sockaddr *addr; 206 size_t addr_len; 207 207 socket_core_t *sock_core; 208 208 tcp_sockdata_t *socket; 209 209 210 210 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_bind()"); 211 211 log_msg(LOG_DEFAULT, LVL_DEBUG, " - async_data_write_accept"); 212 213 addr = NULL; 214 215 rc = async_data_write_accept((void **) &addr, false, 0, 0, 0, &addr_size); 212 rc = async_data_write_accept((void **) &addr, false, 0, 0, 0, &addr_len); 216 213 if (rc != EOK) { 217 214 async_answer_0(callid, rc); 218 goto out; 219 } 220 221 if (addr_size != sizeof(struct sockaddr_in)) { 222 async_answer_0(callid, EINVAL); 223 goto out; 224 } 225 215 return; 216 } 217 226 218 log_msg(LOG_DEFAULT, LVL_DEBUG, " - call socket_bind"); 227 219 rc = socket_bind(&client->sockets, &gsock, SOCKET_GET_SOCKET_ID(call), 228 addr, addr_ size, TCP_FREE_PORTS_START, TCP_FREE_PORTS_END,220 addr, addr_len, TCP_FREE_PORTS_START, TCP_FREE_PORTS_END, 229 221 last_used_port); 230 222 if (rc != EOK) { 231 223 async_answer_0(callid, rc); 232 goto out;233 } 234 224 return; 225 } 226 235 227 log_msg(LOG_DEFAULT, LVL_DEBUG, " - call socket_cores_find"); 236 228 sock_core = socket_cores_find(&client->sockets, SOCKET_GET_SOCKET_ID(call)); 237 if (sock_core == NULL) { 238 async_answer_0(callid, ENOENT); 239 goto out; 240 } 241 242 socket = (tcp_sockdata_t *)sock_core->specific_data; 243 /* XXX Anything to do? */ 244 (void) socket; 245 229 if (sock_core != NULL) { 230 socket = (tcp_sockdata_t *)sock_core->specific_data; 231 /* XXX Anything to do? */ 232 (void) socket; 233 } 234 246 235 log_msg(LOG_DEFAULT, LVL_DEBUG, " - success"); 247 236 async_answer_0(callid, EOK); 248 249 out:250 if (addr != NULL)251 free(addr);252 237 } 253 238 … … 264 249 tcp_sock_lconn_t *lconn; 265 250 int i; 266 int rc;267 251 268 252 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_listen()"); … … 284 268 return; 285 269 } 286 287 if (sock_core->port <= 0) { 288 rc = socket_bind_free_port(&gsock, sock_core, 289 TCP_FREE_PORTS_START, TCP_FREE_PORTS_END, 290 last_used_port); 291 if (rc != EOK) { 292 async_answer_0(callid, rc); 293 return; 294 } 295 296 last_used_port = sock_core->port; 297 } 298 299 socket = (tcp_sockdata_t *) sock_core->specific_data; 300 270 271 socket = (tcp_sockdata_t *)sock_core->specific_data; 272 301 273 /* 302 274 * Prepare @c backlog listening connections. 303 275 */ 304 276 fibril_mutex_lock(&socket->lock); 305 277 306 278 socket->backlog = backlog; 307 279 socket->lconn = calloc(backlog, sizeof(tcp_conn_t *)); … … 311 283 return; 312 284 } 313 285 314 286 log_msg(LOG_DEFAULT, LVL_DEBUG, " - open connections"); 315 287 316 288 lsocket.addr.ipv4 = TCP_IPV4_ANY; 317 289 lsocket.port = sock_core->port; 318 290 fsocket.addr.ipv4 = TCP_IPV4_ANY; 319 291 fsocket.port = TCP_PORT_ANY; 320 292 321 293 for (i = 0; i < backlog; i++) { 322 294 … … 390 362 return; 391 363 } 392 364 393 365 last_used_port = sock_core->port; 394 366 } … … 469 441 return; 470 442 } 471 472 if (sock_core->port <= 0) {473 rc = socket_bind_free_port(&gsock, sock_core,474 TCP_FREE_PORTS_START, TCP_FREE_PORTS_END,475 last_used_port);476 if (rc != EOK) {477 async_answer_0(callid, rc);478 return;479 }480 481 last_used_port = sock_core->port;482 }483 443 484 444 socket = (tcp_sockdata_t *)sock_core->specific_data; -
uspace/srv/net/udp/assoc.c
r119b46e r8fe2c9bd 200 200 /** Set local socket in association. 201 201 * 202 * @param assoc Association 203 * @param lsock Local socket (deeply copied) 204 * 202 * @param assoc Association 203 * @param fsock Foreign socket (deeply copied) 205 204 */ 206 205 void udp_assoc_set_local(udp_assoc_t *assoc, udp_sock_t *lsock) … … 209 208 fibril_mutex_lock(&assoc->lock); 210 209 assoc->ident.local = *lsock; 211 fibril_mutex_unlock(&assoc->lock);212 }213 214 /** Set local port in association.215 *216 * @param assoc Association217 * @param lport Local port218 *219 */220 void udp_assoc_set_local_port(udp_assoc_t *assoc, uint16_t lport)221 {222 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_set_local(%p, %" PRIu16 ")", assoc, lport);223 fibril_mutex_lock(&assoc->lock);224 assoc->ident.local.port = lport;225 210 fibril_mutex_unlock(&assoc->lock); 226 211 } … … 421 406 } 422 407 408 423 409 /** 424 410 * @} -
uspace/srv/net/udp/assoc.h
r119b46e r8fe2c9bd 47 47 extern void udp_assoc_set_foreign(udp_assoc_t *, udp_sock_t *); 48 48 extern void udp_assoc_set_local(udp_assoc_t *, udp_sock_t *); 49 extern void udp_assoc_set_local_port(udp_assoc_t *, uint16_t);50 49 extern int udp_assoc_send(udp_assoc_t *, udp_sock_t *, udp_msg_t *); 51 50 extern int udp_assoc_recv(udp_assoc_t *, udp_msg_t **, udp_sock_t *); -
uspace/srv/net/udp/sock.c
r119b46e r8fe2c9bd 90 90 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_notify_data(%d)", sock_core->socket_id); 91 91 async_exch_t *exch = async_exchange_begin(sock_core->sess); 92 async_msg_5(exch, NET_SOCKET_RECEIVED, (sysarg_t) 92 async_msg_5(exch, NET_SOCKET_RECEIVED, (sysarg_t)sock_core->socket_id, 93 93 UDP_FRAGMENT_SIZE, 0, 0, 1); 94 94 async_exchange_end(exch); … … 177 177 goto out; 178 178 } 179 180 if (addr_size != sizeof(struct sockaddr_in)) { 181 async_answer_0(callid, EINVAL); 182 goto out; 183 } 184 179 185 180 log_msg(LOG_DEFAULT, LVL_DEBUG, " - call socket_bind"); 186 181 rc = socket_bind(&client->sockets, &gsock, SOCKET_GET_SOCKET_ID(call), … … 191 186 goto out; 192 187 } 193 188 189 if (addr_size != sizeof(struct sockaddr_in)) { 190 async_answer_0(callid, EINVAL); 191 goto out; 192 } 193 194 194 log_msg(LOG_DEFAULT, LVL_DEBUG, " - call socket_cores_find"); 195 195 sock_core = socket_cores_find(&client->sockets, SOCKET_GET_SOCKET_ID(call)); … … 249 249 static void udp_sock_sendto(udp_client_t *client, ipc_callid_t callid, ipc_call_t call) 250 250 { 251 int socket_id; 252 int fragments; 253 int index; 254 struct sockaddr_in *addr; 255 size_t addr_size; 256 socket_core_t *sock_core; 257 udp_sockdata_t *socket; 258 udp_sock_t fsock, *fsockp; 259 ipc_call_t answer; 260 ipc_callid_t wcallid; 261 size_t length; 262 uint8_t buffer[UDP_FRAGMENT_SIZE]; 263 udp_error_t urc; 264 int rc; 265 251 266 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_send()"); 252 253 struct sockaddr_in *addr = NULL; 254 udp_sock_t fsock; 255 udp_sock_t *fsock_ptr; 256 267 268 addr = NULL; 269 257 270 if (IPC_GET_IMETHOD(call) == NET_SOCKET_SENDTO) { 258 size_t addr_size; 259 int rc = async_data_write_accept((void **) &addr, false, 271 rc = async_data_write_accept((void **) &addr, false, 260 272 0, 0, 0, &addr_size); 261 273 if (rc != EOK) { … … 263 275 goto out; 264 276 } 265 277 266 278 if (addr_size != sizeof(struct sockaddr_in)) { 267 279 async_answer_0(callid, EINVAL); 268 280 goto out; 269 281 } 270 282 271 283 fsock.addr.ipv4 = uint32_t_be2host(addr->sin_addr.s_addr); 272 284 fsock.port = uint16_t_be2host(addr->sin_port); 273 fsock_ptr = &fsock; 274 } else 275 fsock_ptr = NULL; 276 277 int socket_id = SOCKET_GET_SOCKET_ID(call); 278 285 fsockp = &fsock; 286 } else { 287 fsockp = NULL; 288 } 289 290 socket_id = SOCKET_GET_SOCKET_ID(call); 291 fragments = SOCKET_GET_DATA_FRAGMENTS(call); 279 292 SOCKET_GET_FLAGS(call); 280 281 socket_core_t *sock_core = 282 socket_cores_find(&client->sockets, socket_id); 293 294 sock_core = socket_cores_find(&client->sockets, socket_id); 283 295 if (sock_core == NULL) { 284 296 async_answer_0(callid, ENOTSOCK); 285 297 goto out; 286 298 } 287 288 udp_sockdata_t *socket = 289 (udp_sockdata_t *) sock_core->specific_data; 290 291 if (sock_core->port <= 0) { 299 300 if (sock_core->port == 0) { 292 301 /* Implicitly bind socket to port */ 293 int rc = socket_bind_free_port(&gsock, sock_core, 294 UDP_FREE_PORTS_START, UDP_FREE_PORTS_END, last_used_port); 302 rc = socket_bind(&client->sockets, &gsock, SOCKET_GET_SOCKET_ID(call), 303 addr, addr_size, UDP_FREE_PORTS_START, UDP_FREE_PORTS_END, 304 last_used_port); 295 305 if (rc != EOK) { 296 306 async_answer_0(callid, rc); 297 307 goto out; 298 308 } 299 300 assert(sock_core->port > 0); 301 302 udp_error_t urc = udp_uc_set_local_port(socket->assoc, 303 sock_core->port); 304 305 if (urc != UDP_EOK) { 306 // TODO: better error handling 307 async_answer_0(callid, EINTR); 308 goto out; 309 } 310 311 last_used_port = sock_core->port; 312 } 313 309 } 310 311 socket = (udp_sockdata_t *)sock_core->specific_data; 314 312 fibril_mutex_lock(&socket->lock); 315 313 316 314 if (socket->assoc->ident.local.addr.ipv4 == UDP_IPV4_ANY) { 317 315 /* Determine local IP address */ 318 316 inet_addr_t loc_addr, rem_addr; 319 320 rem_addr.ipv4 = fsock _ptr? fsock.addr.ipv4 :317 318 rem_addr.ipv4 = fsockp ? fsock.addr.ipv4 : 321 319 socket->assoc->ident.foreign.addr.ipv4; 322 323 intrc = inet_get_srcaddr(&rem_addr, 0, &loc_addr);320 321 rc = inet_get_srcaddr(&rem_addr, 0, &loc_addr); 324 322 if (rc != EOK) { 325 323 fibril_mutex_unlock(&socket->lock); … … 329 327 return; 330 328 } 331 329 332 330 socket->assoc->ident.local.addr.ipv4 = loc_addr.ipv4; 333 331 log_msg(LOG_DEFAULT, LVL_DEBUG, "Local IP address is %x", 334 332 socket->assoc->ident.local.addr.ipv4); 335 333 } 336 334 335 337 336 assert(socket->assoc != NULL); 338 339 int fragments = SOCKET_GET_DATA_FRAGMENTS(call); 340 for (int index = 0; index < fragments; index++) { 341 ipc_callid_t wcallid; 342 size_t length; 343 337 338 for (index = 0; index < fragments; index++) { 344 339 if (!async_data_write_receive(&wcallid, &length)) { 345 340 fibril_mutex_unlock(&socket->lock); … … 347 342 goto out; 348 343 } 349 344 350 345 if (length > UDP_FRAGMENT_SIZE) 351 346 length = UDP_FRAGMENT_SIZE; 352 353 uint8_t buffer[UDP_FRAGMENT_SIZE]; 354 int rc = async_data_write_finalize(wcallid, buffer, length); 347 348 rc = async_data_write_finalize(wcallid, buffer, length); 355 349 if (rc != EOK) { 356 350 fibril_mutex_unlock(&socket->lock); … … 358 352 goto out; 359 353 } 360 361 udp_error_t urc = 362 udp_uc_send(socket->assoc, fsock_ptr, buffer, length, 0); 363 354 355 urc = udp_uc_send(socket->assoc, fsockp, buffer, length, 0); 356 364 357 switch (urc) { 365 358 case UDP_EOK: 366 359 rc = EOK; 367 360 break; 368 case UDP_ENORES:369 rc = ENO MEM;370 break; 371 case UDP_EUNSPEC:372 rc = E INVAL;373 break; 374 case UDP_ENOROUTE:375 rc = E IO;376 break; 361 /* case TCP_ENOTEXIST: 362 rc = ENOTCONN; 363 break; 364 case TCP_ECLOSING: 365 rc = ENOTCONN; 366 break; 367 case TCP_ERESET: 368 rc = ECONNABORTED; 369 break;*/ 377 370 default: 378 371 assert(false); 379 372 } 380 373 381 374 if (rc != EOK) { 382 375 fibril_mutex_unlock(&socket->lock); … … 385 378 } 386 379 } 387 388 ipc_call_t answer;389 380 390 381 IPC_SET_ARG1(answer, 0); … … 535 526 static void udp_sock_close(udp_client_t *client, ipc_callid_t callid, ipc_call_t call) 536 527 { 528 int socket_id; 529 socket_core_t *sock_core; 530 udp_sockdata_t *socket; 531 int rc; 532 537 533 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close()"); 538 int socket_id = SOCKET_GET_SOCKET_ID(call); 539 540 socket_core_t *sock_core = 541 socket_cores_find(&client->sockets, socket_id); 534 socket_id = SOCKET_GET_SOCKET_ID(call); 535 536 sock_core = socket_cores_find(&client->sockets, socket_id); 542 537 if (sock_core == NULL) { 543 538 async_answer_0(callid, ENOTSOCK); 544 539 return; 545 540 } 546 547 udp_sockdata_t *socket = 548 (udp_sockdata_t *) sock_core->specific_data; 541 542 socket = (udp_sockdata_t *)sock_core->specific_data; 549 543 fibril_mutex_lock(&socket->lock); 550 551 intrc = socket_destroy(NULL, socket_id, &client->sockets, &gsock,544 545 rc = socket_destroy(NULL, socket_id, &client->sockets, &gsock, 552 546 udp_free_sock_data); 553 547 if (rc != EOK) { … … 556 550 return; 557 551 } 558 552 559 553 fibril_mutex_unlock(&socket->lock); 560 554 async_answer_0(callid, EOK); … … 589 583 &sock->recv_buffer_lock); 590 584 } 591 585 592 586 log_msg(LOG_DEFAULT, LVL_DEBUG, "[] call udp_uc_receive()"); 593 587 urc = udp_uc_receive(sock->assoc, sock->recv_buffer, 594 588 UDP_FRAGMENT_SIZE, &rcvd, &xflags, &sock->recv_fsock); 595 589 sock->recv_error = urc; 596 590 597 591 udp_sock_notify_data(sock->sock_core); 598 592 599 593 if (urc != UDP_EOK) { 600 594 fibril_condvar_broadcast(&sock->recv_buffer_cv); … … 602 596 break; 603 597 } 604 598 605 599 log_msg(LOG_DEFAULT, LVL_DEBUG, "[] got data - broadcast recv_buffer_cv"); 606 600 607 601 sock->recv_buffer_used = rcvd; 608 602 fibril_mutex_unlock(&sock->recv_buffer_lock); -
uspace/srv/net/udp/ucall.c
r119b46e r8fe2c9bd 68 68 { 69 69 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_uc_set_local(%p, %p)", assoc, lsock); 70 70 71 71 udp_assoc_set_local(assoc, lsock); 72 return UDP_EOK;73 }74 75 udp_error_t udp_uc_set_local_port(udp_assoc_t *assoc, uint16_t lport)76 {77 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_uc_set_local(%p, %" PRIu16 ")", assoc, lport);78 79 udp_assoc_set_local_port(assoc, lport);80 72 return UDP_EOK; 81 73 } -
uspace/srv/net/udp/ucall.h
r119b46e r8fe2c9bd 42 42 extern udp_error_t udp_uc_set_foreign(udp_assoc_t *, udp_sock_t *); 43 43 extern udp_error_t udp_uc_set_local(udp_assoc_t *, udp_sock_t *); 44 extern udp_error_t udp_uc_set_local_port(udp_assoc_t *, uint16_t);45 44 extern udp_error_t udp_uc_send(udp_assoc_t *, udp_sock_t *, void *, size_t, 46 45 xflags_t); -
uspace/srv/net/udp/udp_type.h
r119b46e r8fe2c9bd 66 66 }; 67 67 68 enum udp_port {68 enum tcp_port { 69 69 UDP_PORT_ANY = 0 70 70 };
Note:
See TracChangeset
for help on using the changeset viewer.