Changeset 58e8646 in mainline
- Timestamp:
- 2017-08-23T18:37:21Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 258d77e
- Parents:
- 853802e
- Location:
- uspace
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/inet/udp.c
r853802e r58e8646 227 227 } 228 228 229 /** Set UDP association sending messages with no local address 230 * 231 * @param assoc Association 232 * @param flags Flags 233 */ 234 int udp_assoc_set_nolocal(udp_assoc_t *assoc) 235 { 236 async_exch_t *exch; 237 238 exch = async_exchange_begin(assoc->udp->sess); 239 sysarg_t rc = async_req_1_0(exch, UDP_ASSOC_SET_NOLOCAL, assoc->id); 240 async_exchange_end(exch); 241 242 return rc; 243 } 244 229 245 /** Send message via UDP association. 230 246 * -
uspace/lib/c/include/inet/udp.h
r853802e r58e8646 95 95 extern int udp_assoc_create(udp_t *, inet_ep2_t *, udp_cb_t *, void *, 96 96 udp_assoc_t **); 97 extern int udp_assoc_set_nolocal(udp_assoc_t *); 97 98 extern void udp_assoc_destroy(udp_assoc_t *); 98 99 extern int udp_assoc_send_msg(udp_assoc_t *, inet_ep_t *, void *, size_t); -
uspace/lib/c/include/ipc/udp.h
r853802e r58e8646 42 42 UDP_ASSOC_CREATE, 43 43 UDP_ASSOC_DESTROY, 44 UDP_ASSOC_SET_NOLOCAL, 44 45 UDP_ASSOC_SEND_MSG, 45 46 UDP_RMSG_INFO, -
uspace/srv/net/dhcp/transport.c
r853802e r58e8646 153 153 } 154 154 155 rc = udp_assoc_set_nolocal(assoc); 156 if (rc != EOK) { 157 rc = EIO; 158 goto error; 159 } 160 155 161 dt->udp = udp; 156 162 dt->assoc = assoc; -
uspace/srv/net/dnsrsrv/query.c
r853802e r58e8646 90 90 list_append(&question->msg, &msg->question); 91 91 92 log_msg(LOG_DEFAULT, LVL_DEBUG, "dns_name_query: send DNS request"); 92 93 dns_message_t *amsg; 93 94 int rc = dns_request(msg, &amsg); -
uspace/srv/net/dnsrsrv/transport.c
r853802e r58e8646 183 183 void *req_data; 184 184 size_t req_size; 185 log_msg(LOG_DEFAULT, LVL_DEBUG, "dns_request: Encode dns message"); 185 186 int rc = dns_message_encode(req, &req_data, &req_size); 186 187 if (rc != EOK) … … 194 195 195 196 while (ntry < REQ_RETRY_MAX) { 197 log_msg(LOG_DEFAULT, LVL_DEBUG, "dns_request: Send DNS message"); 196 198 rc = udp_assoc_send_msg(transport_assoc, &ep, req_data, 197 199 req_size); 198 if (rc != EOK) 200 if (rc != EOK) { 201 log_msg(LOG_DEFAULT, LVL_DEBUG, "Error %d sending message", rc); 199 202 goto error; 203 } 200 204 201 205 treq = treq_create(req); -
uspace/srv/net/udp/assoc.c
r853802e r58e8646 40 40 #include <fibril_synch.h> 41 41 #include <inet/endpoint.h> 42 #include <inet/inet.h> 42 43 #include <io/log.h> 43 44 #include <nettl/amap.h> … … 261 262 return EINVAL; 262 263 264 /* This association has no local address set. Need to determine one. */ 265 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_send - check no local addr"); 266 if (inet_addr_is_any(&epp.local.addr) && !assoc->nolocal) { 267 log_msg(LOG_DEFAULT, LVL_DEBUG, "Determine local address."); 268 rc = inet_get_srcaddr(&epp.remote.addr, 0, &epp.local.addr); 269 if (rc != EOK) { 270 log_msg(LOG_DEFAULT, LVL_DEBUG, "Cannot determine " 271 "local address."); 272 return EINVAL; 273 } 274 } 275 263 276 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_send - check version"); 264 277 265 if (epp.remote.addr.version != epp.local.addr.version) 278 if (!inet_addr_is_any(&epp.local.addr) && 279 epp.remote.addr.version != epp.local.addr.version) 266 280 return EINVAL; 267 281 -
uspace/srv/net/udp/service.c
r853802e r58e8646 270 270 } 271 271 272 /** Set association sending messages with no local address. 273 * 274 * Handle client request to set nolocal flag (with parameters unmarshalled). 275 * 276 * @param client UDP client 277 * @param assoc_id Association ID 278 * @return EOK on success, ENOENT if no such association is found 279 */ 280 static int udp_assoc_set_nolocal_impl(udp_client_t *client, sysarg_t assoc_id) 281 { 282 udp_cassoc_t *cassoc; 283 int rc; 284 285 rc = udp_cassoc_get(client, assoc_id, &cassoc); 286 if (rc != EOK) { 287 assert(rc == ENOENT); 288 return ENOENT; 289 } 290 291 log_msg(LOG_DEFAULT, LVL_NOTE, "Setting nolocal to true"); 292 cassoc->assoc->nolocal = true; 293 return EOK; 294 } 295 272 296 /** Send message via association. 273 297 * … … 391 415 assoc_id = IPC_GET_ARG1(*icall); 392 416 rc = udp_assoc_destroy_impl(client, assoc_id); 417 async_answer_0(iid, rc); 418 } 419 420 /** Set association with no local address. 421 * 422 * Handle client request to set no local address flag. 423 * 424 * @param client UDP client 425 * @param iid Async request ID 426 * @param icall Async request data 427 */ 428 static void udp_assoc_set_nolocal_srv(udp_client_t *client, ipc_callid_t iid, 429 ipc_call_t *icall) 430 { 431 sysarg_t assoc_id; 432 int rc; 433 434 log_msg(LOG_DEFAULT, LVL_NOTE, "udp_assoc_set_nolocal_srv()"); 435 436 assoc_id = IPC_GET_ARG1(*icall); 437 rc = udp_assoc_set_nolocal_impl(client, assoc_id); 393 438 async_answer_0(iid, rc); 394 439 } … … 662 707 udp_assoc_destroy_srv(&client, callid, &call); 663 708 break; 709 case UDP_ASSOC_SET_NOLOCAL: 710 udp_assoc_set_nolocal_srv(&client, callid, &call); 711 break; 664 712 case UDP_ASSOC_SEND_MSG: 665 713 udp_assoc_send_msg_srv(&client, callid, &call); -
uspace/srv/net/udp/udp_type.h
r853802e r58e8646 41 41 #include <inet/endpoint.h> 42 42 #include <ipc/loc.h> 43 #include <stdbool.h> 43 44 #include <stddef.h> 44 45 #include <inet/addr.h> … … 119 120 /** Receive queue CV. Broadcast when new datagram is inserted */ 120 121 fibril_condvar_t rcv_queue_cv; 122 /** Allow sending messages with no local address */ 123 bool nolocal; 121 124 122 125 udp_assoc_cb_t *cb;
Note:
See TracChangeset
for help on using the changeset viewer.