Changeset 257feec in mainline
- Timestamp:
- 2013-06-27T12:48:32Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9f391e9
- Parents:
- 679ee84
- Location:
- uspace
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/inet/inet.c
r679ee84 r257feec 44 44 #include <sys/types.h> 45 45 46 #define NAME "inet"46 #define NAME "inet" 47 47 48 48 static void print_syntax(void) … … 257 257 if (count > 0) 258 258 printf(" [Addr/Width] [Link-Name] [Addr-Name] [Def-MTU]\n"); 259 ainfo.name = linfo.name = astr = NULL; 259 ainfo.name = NULL; 260 linfo.name = NULL; 261 astr = NULL; 260 262 261 263 for (i = 0; i < count; i++) { … … 290 292 free(astr); 291 293 292 ainfo.name = linfo.name = astr = NULL; 294 ainfo.name = NULL; 295 linfo.name = NULL; 296 astr = NULL; 293 297 } 294 298 … … 329 333 printf(" [Dest/Width] [Router-Addr] [Route-Name]\n"); 330 334 331 srinfo.name = dest_str = router_str = NULL; 335 srinfo.name = NULL; 336 dest_str = NULL; 337 router_str = NULL; 332 338 333 339 for (i = 0; i < count; i++) { … … 360 366 free(router_str); 361 367 362 router_str = srinfo.name = dest_str = NULL; 368 router_str = NULL; 369 srinfo.name = NULL; 370 dest_str = NULL; 363 371 } 364 372 -
uspace/lib/c/include/net/in.h
r679ee84 r257feec 45 45 #define INET_ADDRSTRLEN (4 * 3 + 3 + 1) 46 46 47 #define INADDR_ANY 047 #define INADDR_ANY 0 48 48 49 49 /** INET address. */ -
uspace/lib/c/include/net/in6.h
r679ee84 r257feec 43 43 44 44 /** INET6 string address maximum length. */ 45 #define INET6_ADDRSTRLEN (8 * 4 + 7 + 1) 46 47 /** Type definition of the INET6 address. 48 * @see in6_addr 49 */ 50 typedef struct in6_addr in6_addr_t; 51 52 /** Type definition of the INET6 socket address. 53 * @see sockaddr_in6 54 */ 55 typedef struct sockaddr_in6 sockaddr_in6_t; 45 #define INET6_ADDRSTRLEN (8 * 4 + 7 + 1) 56 46 57 47 /** INET6 address. */ 58 struct in6_addr {48 typedef struct in6_addr { 59 49 /** 16 byte IPv6 address. */ 60 u nsigned chars6_addr[16];61 } ;50 uint8_t s6_addr[16]; 51 } in6_addr_t; 62 52 63 53 /** INET6 socket address. 64 54 * @see sockaddr 65 55 */ 66 struct sockaddr_in6 {56 typedef struct sockaddr_in6 { 67 57 /** Address family. Should be AF_INET6. */ 68 58 uint16_t sin6_family; … … 75 65 /** Scope identifier. */ 76 66 uint32_t sin6_scope_id; 77 } ;67 } sockaddr_in6_t; 78 68 79 69 #endif -
uspace/lib/c/include/net/inet.h
r679ee84 r257feec 41 41 #include <byteorder.h> 42 42 43 /** Type definition of the socket address.44 * @see sockaddr45 */46 typedef struct sockaddr sockaddr_t;47 48 43 /** Type definition of the address information. 49 44 * @see addrinfo 50 45 */ 51 typedef struct addrinfo 46 typedef struct addrinfo addrinfo_t; 52 47 53 48 /** Socket address. */ 54 struct sockaddr {49 typedef struct sockaddr { 55 50 /** Address family. @see socket.h */ 56 51 uint16_t sa_family; 57 52 /** 14 byte protocol address. */ 58 53 uint8_t sa_data[14]; 59 } ;54 } sockaddr_t; 60 55 61 56 extern int inet_ntop(uint16_t, const uint8_t *, char *, size_t); -
uspace/lib/c/include/net/socket_codes.h
r679ee84 r257feec 46 46 enum { 47 47 AF_NONE = 0, 48 AF_INET, 49 AF_INET6 48 AF_INET, /* IPv4 address */ 49 AF_INET6 /* IPv6 address */ 50 50 }; 51 51 … … 53 53 54 54 /** @name Protocol families definitions 55 * 55 * Same as address families. 56 56 */ 57 57 /*@{*/ 58 58 59 #define PF_INET 60 #define PF_INET6 59 #define PF_INET AF_INET 60 #define PF_INET6 AF_INET6 61 61 62 62 /*@}*/ -
uspace/srv/net/dnsrsrv/transport.c
r679ee84 r257feec 208 208 if (rc != EOK) 209 209 goto error; 210 210 211 211 treq = treq_create(req); 212 212 if (treq == NULL) { … … 214 214 goto error; 215 215 } 216 217 216 218 217 fibril_mutex_lock(&treq->done_lock); 219 218 while (treq->done != true) { … … 225 224 } 226 225 } 227 226 228 227 fibril_mutex_unlock(&treq->done_lock); 229 228 230 229 if (rc != ETIMEOUT) 231 230 break; 232 231 } 233 232 234 233 if (ntry >= REQ_RETRY_MAX) { 235 234 rc = EIO; 236 235 goto error; 237 236 } 238 237 239 238 if (treq->status != EOK) { 240 239 rc = treq->status; 241 240 goto error; 242 241 } 243 242 244 243 *rresp = treq->resp; 245 244 treq_destroy(treq); 246 245 free(req_data); 247 246 return EOK; 247 248 248 error: 249 249 if (treq != NULL) 250 250 treq_destroy(treq); 251 251 252 free(req_data); 252 253 return rc; -
uspace/srv/net/ethip/arp.c
r679ee84 r257feec 106 106 if (rc != EOK) 107 107 return rc; 108 108 109 109 (void) atrans_wait_timeout(ARP_REQUEST_TIMEOUT); 110 110 111 111 return atrans_lookup(ip_addr, mac_addr); 112 112 } -
uspace/srv/net/ethip/atrans.c
r679ee84 r257feec 124 124 int atrans_wait_timeout(suseconds_t timeout) 125 125 { 126 int rc;127 128 126 fibril_mutex_lock(&atrans_list_lock); 129 rc = fibril_condvar_wait_timeout(&atrans_cv, &atrans_list_lock,127 int rc = fibril_condvar_wait_timeout(&atrans_cv, &atrans_list_lock, 130 128 timeout); 131 129 fibril_mutex_unlock(&atrans_list_lock); 132 130 133 131 return rc; 134 132 } -
uspace/srv/net/ethip/ethip.c
r679ee84 r257feec 191 191 if (rc != EOK) 192 192 return rc; 193 193 194 194 rc = ethip_nic_send(nic, data, size); 195 195 free(data); 196 196 197 197 return rc; 198 198 } … … 232 232 frame.etype_len); 233 233 } 234 234 235 235 free(frame.data); 236 236 return rc; -
uspace/srv/net/ethip/ethip_nic.c
r679ee84 r257feec 364 364 { 365 365 log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_nic_addr_find()"); 366 366 367 367 list_foreach(nic->addr_list, link) { 368 368 ethip_link_addr_t *laddr = list_get_instance(link, 369 369 ethip_link_addr_t, addr_list); 370 370 371 371 if (addr == laddr->addr) 372 372 return laddr; 373 373 } 374 374 375 375 return NULL; 376 376 } -
uspace/srv/net/ethip/pdu.h
r679ee84 r257feec 47 47 extern int arp_pdu_decode(void *, size_t, arp_eth_packet_t *); 48 48 49 50 49 #endif 51 50 -
uspace/srv/net/ethip/std.h
r679ee84 r257feec 40 40 #include <sys/types.h> 41 41 42 #define ETH_ADDR_SIZE 643 #define IPV4_ADDR_SIZE 444 #define ETH_FRAME_MIN_SIZE 6042 #define ETH_ADDR_SIZE 6 43 #define IPV4_ADDR_SIZE 4 44 #define ETH_FRAME_MIN_SIZE 60 45 45 46 46 /** Ethernet frame header */ … … 91 91 }; 92 92 93 94 93 #endif 95 94 -
uspace/srv/net/inetsrv/addrobj.c
r679ee84 r257feec 137 137 } 138 138 } 139 139 140 140 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_addrobj_find: Not found"); 141 141 fibril_mutex_unlock(&addr_list_lock); 142 142 143 143 return NULL; 144 144 } -
uspace/srv/net/inetsrv/addrobj.h
r679ee84 r257feec 59 59 extern int inet_addrobj_get_id_list(sysarg_t **, size_t *); 60 60 61 62 61 #endif 63 62 -
uspace/srv/net/inetsrv/icmp_std.h
r679ee84 r257feec 43 43 44 44 /** Type of service used for ICMP */ 45 #define ICMP_TOS 45 #define ICMP_TOS 0 46 46 47 47 /** ICMP message type */ -
uspace/srv/net/inetsrv/inet_link.c
r679ee84 r257feec 70 70 return rc; 71 71 } 72 72 73 73 log_msg(LOG_DEFAULT, LVL_DEBUG, "call inet_recv_packet()"); 74 74 rc = inet_recv_packet(&packet); 75 75 log_msg(LOG_DEFAULT, LVL_DEBUG, "call inet_recv_packet -> %d", rc); 76 76 free(packet.data); 77 77 78 78 return rc; 79 79 } … … 232 232 if (ilink->iplink != NULL) 233 233 iplink_close(ilink->iplink); 234 234 235 inet_link_delete(ilink); 235 236 return rc; … … 263 264 * inet_pdu_encode(). 264 265 */ 266 265 267 inet_packet_t packet; 266 268 -
uspace/srv/net/inetsrv/inetcfg.c
r679ee84 r257feec 377 377 } 378 378 379 380 379 static void inetcfg_get_link_list_srv(ipc_callid_t callid, ipc_call_t *call) 381 380 { -
uspace/srv/net/inetsrv/inetping.c
r679ee84 r257feec 94 94 int rc = async_data_write_start(exch, sdu->data, sdu->size); 95 95 async_exchange_end(exch); 96 96 97 97 if (rc != EOK) { 98 98 async_forget(req); 99 99 return rc; 100 100 } 101 101 102 102 sysarg_t retval; 103 103 async_wait_for(req, &retval); 104 if (retval != EOK) { 105 return retval; 106 } 107 108 return EOK; 104 105 return (int) retval; 109 106 } 110 107 … … 151 148 if (sess == NULL) 152 149 return ENOMEM; 153 150 154 151 client->sess = sess; 155 152 link_initialize(&client->client_list); 156 153 157 154 fibril_mutex_lock(&client_list_lock); 158 155 client->ident = ++inetping_ident; 159 156 list_append(&client->client_list, &client_list); 160 157 fibril_mutex_unlock(&client_list_lock); 161 158 162 159 return EOK; 163 160 } … … 167 164 async_hangup(client->sess); 168 165 client->sess = NULL; 169 166 170 167 fibril_mutex_lock(&client_list_lock); 171 168 list_remove(&client->client_list); … … 204 201 if (rc != EOK) 205 202 return; 206 203 207 204 while (true) { 208 205 ipc_call_t call; 209 206 ipc_callid_t callid = async_get_call(&call); 210 207 sysarg_t method = IPC_GET_IMETHOD(call); 211 208 212 209 if (!method) { 213 210 /* The other side has hung up */ … … 215 212 break; 216 213 } 217 214 218 215 switch (method) { 219 216 case INETPING_SEND: … … 227 224 } 228 225 } 229 226 230 227 inetping_client_fini(&client); 231 228 } -
uspace/srv/net/inetsrv/pdu.c
r679ee84 r257feec 203 203 204 204 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_pdu_decode()"); 205 205 206 206 if (size < sizeof(ip_header_t)) { 207 207 log_msg(LOG_DEFAULT, LVL_DEBUG, "PDU too short (%zu)", size); … … 223 223 return EINVAL; 224 224 } 225 225 226 226 if (tot_len > size) { 227 227 log_msg(LOG_DEFAULT, LVL_DEBUG, "Total Length = %zu > PDU size = %zu", … … 242 242 packet->ttl = hdr->ttl; 243 243 packet->ident = ident; 244 244 245 245 packet->df = (flags_foff & BIT_V(uint16_t, FF_FLAG_DF)) != 0; 246 246 packet->mf = (flags_foff & BIT_V(uint16_t, FF_FLAG_MF)) != 0; 247 247 packet->offs = foff * FRAG_OFFS_UNIT; 248 248 249 249 /* XXX IP options */ 250 250 data_offs = sizeof(uint32_t) * BIT_RANGE_EXTRACT(uint8_t, VI_IHL_h, … … 257 257 return ENOMEM; 258 258 } 259 260 memcpy(packet->data, (uint8_t *) data + data_offs, packet->size);261 259 260 memcpy(packet->data, (uint8_t *) data + data_offs, packet->size); 261 262 262 return EOK; 263 263 } -
uspace/srv/net/loopip/loopip.c
r679ee84 r257feec 44 44 #include <stdlib.h> 45 45 46 #define NAME "loopip"46 #define NAME "loopip" 47 47 48 48 static int loopip_open(iplink_srv_t *srv); … … 81 81 (void) iplink_ev_recv(&loopip_iplink, &rqe->sdu); 82 82 } 83 83 84 84 return 0; 85 85 } … … 99 99 return rc; 100 100 } 101 101 102 102 iplink_srv_init(&loopip_iplink); 103 103 loopip_iplink.ops = &loopip_iplink_ops; 104 104 loopip_iplink.arg = NULL; 105 105 106 106 prodcons_initialize(&loopip_rcv_queue); 107 107 … … 117 117 return rc; 118 118 } 119 119 120 120 rc = loc_service_add_to_cat(sid, iplink_cat); 121 121 if (rc != EOK) { … … 123 123 return rc; 124 124 } 125 125 126 126 fid_t fid = fibril_create(loopip_recv_fibril, NULL); 127 127 if (fid == 0) 128 128 return ENOMEM; 129 129 130 130 fibril_add_ready(fid); 131 131 132 132 return EOK; 133 133 } … … 160 160 if (rqe == NULL) 161 161 return ENOMEM; 162 162 163 /* 163 164 * Clone SDU … … 170 171 return ENOMEM; 171 172 } 172 173 173 174 memcpy(rqe->sdu.data, sdu->data, sdu->size); 174 175 rqe->sdu.size = sdu->size; 175 176 176 177 /* 177 178 * Insert to receive queue 178 179 */ 179 180 prodcons_produce(&loopip_rcv_queue, &rqe->link); 180 181 181 182 return EOK; 182 183 } … … 211 212 return 1; 212 213 } 213 214 214 215 rc = loopip_init(); 215 216 if (rc != EOK) … … 219 220 task_retval(0); 220 221 async_manager(); 221 222 222 223 /* Not reached */ 223 224 return 0; -
uspace/srv/net/tcp/ncsim.c
r679ee84 r257feec 128 128 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_ncsim_fibril()"); 129 129 130 131 130 while (true) { 132 131 fibril_mutex_lock(&sim_queue_lock); -
uspace/srv/net/tcp/sock.c
r679ee84 r257feec 429 429 430 430 fibril_mutex_unlock(&socket->lock); 431 431 432 432 switch (trc) { 433 433 case TCP_EOK: … … 440 440 assert(false); 441 441 } 442 442 443 443 if (rc == EOK) 444 444 fibril_add_ready(socket->recv_fibril); 445 445 446 446 async_answer_0(callid, rc); 447 447 } … … 687 687 socket = (tcp_sockdata_t *)sock_core->specific_data; 688 688 fibril_mutex_lock(&socket->lock); 689 689 690 690 if (socket->conn == NULL) { 691 691 fibril_mutex_unlock(&socket->lock); … … 703 703 &socket->recv_buffer_lock); 704 704 } 705 705 706 706 log_msg(LOG_DEFAULT, LVL_DEBUG, "Got data in sock recv_buffer"); 707 707 … … 723 723 assert(false); 724 724 } 725 725 726 726 log_msg(LOG_DEFAULT, LVL_DEBUG, "**** recv result -> %d", rc); 727 727 728 if (rc != EOK) { 728 729 fibril_mutex_unlock(&socket->recv_buffer_lock); … … 769 770 } 770 771 } 771 772 772 773 log_msg(LOG_DEFAULT, LVL_DEBUG, "data read receive"); 773 774 if (!async_data_read_receive(&rcallid, &length)) { … … 777 778 return; 778 779 } 779 780 780 781 if (length > data_len) 781 782 length = data_len; 782 783 783 784 log_msg(LOG_DEFAULT, LVL_DEBUG, "data read finalize"); 784 785 rc = async_data_read_finalize(rcallid, socket->recv_buffer, length); 785 786 786 787 socket->recv_buffer_used -= length; 787 788 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_recvfrom: %zu left in buffer", … … 792 793 tcp_sock_notify_data(socket->sock_core); 793 794 } 794 795 795 796 fibril_condvar_broadcast(&socket->recv_buffer_cv); 796 797 … … 800 801 SOCKET_SET_READ_DATA_LENGTH(answer, length); 801 802 async_answer_1(callid, EOK, IPC_GET_ARG1(answer)); 802 803 803 804 fibril_mutex_unlock(&socket->recv_buffer_lock); 804 805 fibril_mutex_unlock(&socket->lock); -
uspace/srv/net/udp/sock.c
r679ee84 r257feec 222 222 assert(false); 223 223 } 224 224 225 225 log_msg(LOG_DEFAULT, LVL_DEBUG, " - success"); 226 226 async_answer_0(callid, rc); … … 428 428 socket = (udp_sockdata_t *)sock_core->specific_data; 429 429 fibril_mutex_lock(&socket->lock); 430 430 431 431 if (socket->assoc == NULL) { 432 432 fibril_mutex_unlock(&socket->lock); … … 444 444 &socket->recv_buffer_lock); 445 445 } 446 446 447 447 log_msg(LOG_DEFAULT, LVL_DEBUG, "Got data in sock recv_buffer"); 448 448 … … 467 467 assert(false); 468 468 } 469 469 470 470 log_msg(LOG_DEFAULT, LVL_DEBUG, "**** udp_uc_receive -> %d", rc); 471 471 472 if (rc != EOK) { 472 473 fibril_mutex_unlock(&socket->recv_buffer_lock); … … 519 520 return; 520 521 } 521 522 522 523 if (length > data_len) 523 524 length = data_len; 524 525 525 526 log_msg(LOG_DEFAULT, LVL_DEBUG, "data read finalize"); 526 527 rc = async_data_read_finalize(rcallid, socket->recv_buffer, length); … … 528 529 if (length < data_len && rc == EOK) 529 530 rc = EOVERFLOW; 530 531 531 532 log_msg(LOG_DEFAULT, LVL_DEBUG, "read_data_length <- %zu", length); 532 533 IPC_SET_ARG2(answer, 0); … … 535 536 async_answer_3(callid, EOK, IPC_GET_ARG1(answer), 536 537 IPC_GET_ARG2(answer), IPC_GET_ARG3(answer)); 537 538 538 539 socket->recv_buffer_used = 0; 539 540 540 541 fibril_condvar_broadcast(&socket->recv_buffer_cv); 541 542 fibril_mutex_unlock(&socket->recv_buffer_lock); … … 612 613 while (true) { 613 614 log_msg(LOG_DEFAULT, LVL_DEBUG, "[] wait for rcv buffer empty()"); 614 while ( sock->recv_buffer_used != 0 && sock->sock_core != NULL) {615 while ((sock->recv_buffer_used != 0) && (sock->sock_core != NULL)) { 615 616 fibril_condvar_wait(&sock->recv_buffer_cv, 616 617 &sock->recv_buffer_lock); -
uspace/srv/net/udp/std.h
r679ee84 r257feec 40 40 #include <sys/types.h> 41 41 42 #define IP_PROTO_UDP 1742 #define IP_PROTO_UDP 17 43 43 44 44 /** UDP Header */ … … 64 64 /** Protocol */ 65 65 uint8_t protocol; 66 /** TCP length */66 /** UDP length */ 67 67 uint16_t udp_length; 68 68 } udp_phdr_t;
Note:
See TracChangeset
for help on using the changeset viewer.