Changeset 695b6ff in mainline for uspace/srv/net/udp
- Timestamp:
- 2013-09-12T21:26:18Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b8b1adb1, ddd0499d
- Parents:
- 4a90582
- Location:
- uspace/srv/net/udp
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/udp/assoc.c
r4a90582 r695b6ff 184 184 fibril_mutex_unlock(&assoc_list_lock); 185 185 udp_assoc_delref(assoc); 186 } 187 188 /** Set IP link in association. 189 * 190 * @param assoc Association 191 * @param iplink IP link 192 */ 193 void udp_assoc_set_iplink(udp_assoc_t *assoc, service_id_t iplink) 194 { 195 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_set_iplink(%p, %zu)", 196 assoc, iplink); 197 fibril_mutex_lock(&assoc->lock); 198 assoc->ident.iplink = iplink; 199 fibril_mutex_unlock(&assoc->lock); 186 200 } 187 201 -
uspace/srv/net/udp/assoc.h
r4a90582 r695b6ff 36 36 #define ASSOC_H 37 37 38 #include <ipc/loc.h> 38 39 #include <sys/types.h> 39 40 #include "udp_type.h" … … 45 46 extern void udp_assoc_addref(udp_assoc_t *); 46 47 extern void udp_assoc_delref(udp_assoc_t *); 48 extern void udp_assoc_set_iplink(udp_assoc_t *, service_id_t); 47 49 extern void udp_assoc_set_foreign(udp_assoc_t *, udp_sock_t *); 48 50 extern void udp_assoc_set_local(udp_assoc_t *, udp_sock_t *); -
uspace/srv/net/udp/pdu.c
r4a90582 r695b6ff 215 215 return ENOMEM; 216 216 217 npdu->iplink = sp->iplink; 217 218 npdu->src = sp->local.addr; 218 219 npdu->dest = sp->foreign.addr; -
uspace/srv/net/udp/sock.c
r4a90582 r695b6ff 1 1 /* 2 2 * Copyright (c) 2008 Lukas Mejdrech 3 * Copyright (c) 201 2Jiri Svoboda3 * Copyright (c) 2013 Jiri Svoboda 4 4 * All rights reserved. 5 5 * … … 349 349 fibril_mutex_lock(&socket->lock); 350 350 351 if (inet_addr_is_any(&socket->assoc->ident.local.addr)) { 351 if (inet_addr_is_any(&socket->assoc->ident.local.addr) && 352 socket->assoc->ident.iplink == 0) { 352 353 /* Determine local IP address */ 353 354 inet_addr_t loc_addr; … … 665 666 static void udp_sock_setsockopt(udp_client_t *client, ipc_callid_t callid, ipc_call_t call) 666 667 { 667 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_setsockopt()"); 668 async_answer_0(callid, ENOTSUP); 669 } 668 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_setsockopt)"); 669 log_msg(LOG_DEFAULT, LVL_DEBUG, " - async_data_write_accept"); 670 671 void *data = NULL; 672 size_t data_len; 673 int rc = async_data_write_accept(&data, false, 0, 0, 0, &data_len); 674 if (rc != EOK) { 675 log_msg(LOG_DEFAULT, LVL_DEBUG, " - failed accepting data"); 676 async_answer_0(callid, rc); 677 return; 678 } 679 680 sysarg_t opt_level = SOL_SOCKET; 681 sysarg_t opt_name = SOCKET_GET_OPT_NAME(call); 682 683 if (opt_level != SOL_SOCKET || opt_name != SO_IPLINK || 684 data_len != sizeof(service_id_t)) { 685 log_msg(LOG_DEFAULT, LVL_DEBUG, " - failed opt_level/name/len"); 686 log_msg(LOG_DEFAULT, LVL_DEBUG, " - failed opt_level=%d, " 687 "opt_name=%d, data_len=%zu", (int)opt_level, (int)opt_name, 688 data_len); 689 async_answer_0(callid, EINVAL); 690 return; 691 } 692 693 log_msg(LOG_DEFAULT, LVL_DEBUG, " - call socket_cores_find"); 694 695 socket_core_t *sock_core = socket_cores_find(&client->sockets, 696 SOCKET_GET_SOCKET_ID(call)); 697 if (sock_core == NULL) { 698 log_msg(LOG_DEFAULT, LVL_DEBUG, " - failed getting sock_core"); 699 async_answer_0(callid, ENOENT); 700 return; 701 } 702 703 udp_sockdata_t *socket = 704 (udp_sockdata_t *) sock_core->specific_data; 705 706 service_id_t iplink = *(service_id_t *)data; 707 udp_uc_set_iplink(socket->assoc, iplink); 708 709 log_msg(LOG_DEFAULT, LVL_DEBUG, " - success"); 710 async_answer_0(callid, EOK); 711 } 712 670 713 671 714 static int udp_sock_recv_fibril(void *arg) … … 714 757 715 758 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_recv_fibril() exited loop"); 716 fibril_mutex_unlock(&sock->recv_buffer_lock);717 759 udp_uc_destroy(sock->assoc); 718 760 … … 730 772 /* Accept the connection */ 731 773 async_answer_0(iid, EOK); 774 775 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_connection: begin"); 732 776 733 777 client.sess = async_callback_receive(EXCHANGE_SERIALIZE); -
uspace/srv/net/udp/ucall.c
r4a90582 r695b6ff 55 55 *assoc = nassoc; 56 56 return UDP_EOK; 57 } 58 59 void udp_uc_set_iplink(udp_assoc_t *assoc, service_id_t iplink) 60 { 61 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_uc_set_iplink(%p, %zu)", 62 assoc, iplink); 63 64 udp_assoc_set_iplink(assoc, iplink); 57 65 } 58 66 -
uspace/srv/net/udp/ucall.h
r4a90582 r695b6ff 36 36 #define UCALL_H 37 37 38 #include <ipc/loc.h> 38 39 #include <sys/types.h> 39 40 #include "udp_type.h" 40 41 41 42 extern udp_error_t udp_uc_create(udp_assoc_t **); 43 extern void udp_uc_set_iplink(udp_assoc_t *, service_id_t); 42 44 extern udp_error_t udp_uc_set_foreign(udp_assoc_t *, udp_sock_t *); 43 45 extern udp_error_t udp_uc_set_local(udp_assoc_t *, udp_sock_t *); -
uspace/srv/net/udp/udp_inet.c
r4a90582 r695b6ff 84 84 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_transmit_pdu()"); 85 85 86 dgram.iplink = pdu->iplink; 86 87 dgram.src = pdu->src; 87 88 dgram.dest = pdu->dest; -
uspace/srv/net/udp/udp_type.h
r4a90582 r695b6ff 38 38 #include <fibril.h> 39 39 #include <fibril_synch.h> 40 #include <ipc/loc.h> 40 41 #include <socket_core.h> 41 42 #include <sys/types.h> … … 71 72 72 73 typedef struct { 74 service_id_t iplink; 73 75 udp_sock_t local; 74 76 udp_sock_t foreign; … … 85 87 /** Encoded PDU */ 86 88 typedef struct { 89 /** IP link (optional) */ 90 service_id_t iplink; 87 91 /** Source address */ 88 92 inet_addr_t src; 89 93 /** Destination address */ 90 94 inet_addr_t dest; 91 92 95 /** Encoded PDU data including header */ 93 96 void *data; … … 143 146 /** Connection */ 144 147 udp_assoc_t *assoc; 148 /** User-configured IP link */ 149 service_id_t iplink; 145 150 /** Receiving fibril */ 146 151 fid_t recv_fibril;
Note:
See TracChangeset
for help on using the changeset viewer.
