Changeset 330df83 in mainline
- Timestamp:
- 2013-07-19T20:42:57Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f4cbf9dd
- Parents:
- 8a8a08d1 (diff), cd18cd1 (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:
-
- 46 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/arm32/src/mach/beaglebone/beaglebone.c
r8a8a08d1 r330df83 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
r8a8a08d1 r330df83 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/bdsh/cmds/modules/cat/cat.c
r8a8a08d1 r330df83 63 63 static bool should_quit = false; 64 64 static bool dash_represents_stdin = false; 65 static unsigned int lineno = 0; 66 static bool number = false; 67 static bool last_char_was_newline = false; 65 68 66 69 static console_ctrl_t *console = NULL; … … 75 78 { "hex", no_argument, 0, 'x' }, 76 79 { "stdin", no_argument, 0, 's' }, 80 { "number", no_argument, 0, 'n' }, 77 81 { 0, 0, 0, 0 } 78 82 }; … … 95 99 " -m, --more Pause after each screen full\n" 96 100 " -x, --hex Print bytes as hex values\n" 97 " -s --stdin Treat `-' in file list as standard input\n" 101 " -s, --stdin Treat `-' in file list as standard input\n" 102 " -n, --number Number all output lines\n" 98 103 "Currently, %s is under development, some options don't work.\n", 99 104 cmdname, cmdname); … … 153 158 static void paged_char(wchar_t c) 154 159 { 160 if (last_char_was_newline && number) { 161 lineno++; 162 printf("%6u ", lineno); 163 } 155 164 putchar(c); 165 last_char_was_newline = c == '\n'; 156 166 if (paging_enabled) { 157 167 chars_remaining--; … … 306 316 should_quit = false; 307 317 console = console_init(stdin, stdout); 318 number = false; 319 lineno = 0; 320 /* This enables printing of the first number. */ 321 last_char_was_newline = true; 322 308 323 309 324 argc = cli_count_args(argv); 310 325 311 326 for (c = 0, optind = 0, opt_ind = 0; c != -1;) { 312 c = getopt_long(argc, argv, "xhvmH:t:b:s ", long_options, &opt_ind);327 c = getopt_long(argc, argv, "xhvmH:t:b:s:n", long_options, &opt_ind); 313 328 switch (c) { 314 329 case 'h': … … 347 362 dash_represents_stdin = true; 348 363 break; 364 case 'n': 365 number = true; 366 break; 349 367 } 350 368 } -
uspace/app/dnsres/dnsres.c
r8a8a08d1 r330df83 36 36 #include <inet/addr.h> 37 37 #include <inet/dnsr.h> 38 #include <net/socket_codes.h> 38 39 #include <stdio.h> 39 40 #include <stdlib.h> 40 41 41 #define NAME "dnsres"42 #define NAME "dnsres" 42 43 43 44 static void print_syntax(void) 44 45 { 45 printf(" syntax: " NAME " <host-name>\n");46 printf("Syntax: %s [-4|-6] <host-name>\n", NAME); 46 47 } 47 48 48 49 int main(int argc, char *argv[]) 49 50 { 50 int rc; 51 dnsr_hostinfo_t *hinfo; 52 char *hname; 53 char *saddr; 54 55 if (argc != 2) { 51 if ((argc < 2) || (argc > 3)) { 56 52 print_syntax(); 57 53 return 1; 58 54 } 59 60 hname = argv[1]; 61 62 rc = dnsr_name2host(hname, &hinfo); 55 56 uint16_t af; 57 char *hname; 58 59 if (str_cmp(argv[1], "-4") == 0) { 60 if (argc < 3) { 61 print_syntax(); 62 return 1; 63 } 64 65 af = AF_INET; 66 hname = argv[2]; 67 } else if (str_cmp(argv[1], "-6") == 0) { 68 if (argc < 3) { 69 print_syntax(); 70 return 1; 71 } 72 73 af = AF_INET6; 74 hname = argv[2]; 75 } else { 76 af = 0; 77 hname = argv[1]; 78 } 79 80 dnsr_hostinfo_t *hinfo; 81 int rc = dnsr_name2host(hname, &hinfo, af); 63 82 if (rc != EOK) { 64 printf( NAME ": Error resolving '%s'.\n", argv[1]);65 return 1;83 printf("%s: Error resolving '%s'.\n", NAME, hname); 84 return rc; 66 85 } 67 86 87 char *saddr; 68 88 rc = inet_addr_format(&hinfo->addr, &saddr); 69 89 if (rc != EOK) { 70 90 dnsr_hostinfo_destroy(hinfo); 71 printf( NAME ": Out of memory.\n");72 return 1;91 printf("%s: Error formatting address.\n", NAME); 92 return rc; 73 93 } 74 94 75 95 printf("Host name: %s\n", hname); 96 76 97 if (str_cmp(hname, hinfo->cname) != 0) 77 98 printf("Canonical name: %s\n", hinfo->cname); 99 78 100 printf("Address: %s\n", saddr); 79 101 80 102 dnsr_hostinfo_destroy(hinfo); 81 103 free(saddr); 82 104 83 105 return 0; 84 106 } -
uspace/app/nettest1/nettest1.c
r8a8a08d1 r330df83 335 335 /* Interpret as a host name */ 336 336 dnsr_hostinfo_t *hinfo = NULL; 337 rc = dnsr_name2host(addr_s, &hinfo );337 rc = dnsr_name2host(addr_s, &hinfo, family); 338 338 339 339 if (rc != EOK) { -
uspace/app/nettest2/nettest2.c
r8a8a08d1 r330df83 271 271 /* Interpret as a host name */ 272 272 dnsr_hostinfo_t *hinfo = NULL; 273 rc = dnsr_name2host(addr_s, &hinfo );273 rc = dnsr_name2host(addr_s, &hinfo, family); 274 274 275 275 if (rc != EOK) { -
uspace/app/nettest3/nettest3.c
r8a8a08d1 r330df83 78 78 if (rc != EOK) { 79 79 /* Try interpreting as a host name */ 80 rc = dnsr_name2host(argv[1], &hinfo );80 rc = dnsr_name2host(argv[1], &hinfo, AF_INET); 81 81 if (rc != EOK) { 82 82 printf("Error resolving host '%s'.\n", argv[1]); -
uspace/app/nterm/conn.c
r8a8a08d1 r330df83 84 84 /* Interpret as a host name */ 85 85 dnsr_hostinfo_t *hinfo = NULL; 86 rc = dnsr_name2host(addr_s, &hinfo );86 rc = dnsr_name2host(addr_s, &hinfo, 0); 87 87 88 88 if (rc != EOK) { -
uspace/app/ping/ping.c
r8a8a08d1 r330df83 212 212 if (rc != EOK) { 213 213 /* Try interpreting as a host name */ 214 rc = dnsr_name2host(argv[argi], &hinfo );214 rc = dnsr_name2host(argv[argi], &hinfo, AF_INET); 215 215 if (rc != EOK) { 216 216 printf(NAME ": Error resolving host '%s'.\n", argv[argi]); -
uspace/app/ping6/ping6.c
r8a8a08d1 r330df83 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 … … 212 212 if (rc != EOK) { 213 213 /* Try interpreting as a host name */ 214 rc = dnsr_name2host(argv[argi], &hinfo );214 rc = dnsr_name2host(argv[argi], &hinfo, AF_INET6); 215 215 if (rc != EOK) { 216 216 printf(NAME ": Error resolving host '%s'.\n", argv[argi]); -
uspace/lib/c/generic/dnsr.c
r8a8a08d1 r330df83 67 67 } 68 68 69 int dnsr_name2host(const char *name, dnsr_hostinfo_t **rinfo )69 int dnsr_name2host(const char *name, dnsr_hostinfo_t **rinfo, uint16_t af) 70 70 { 71 71 dnsr_hostinfo_t *info = calloc(1, sizeof(dnsr_hostinfo_t)); … … 76 76 77 77 ipc_call_t answer; 78 aid_t req = async_send_0(exch, DNSR_NAME2HOST, &answer); 78 aid_t req = async_send_1(exch, DNSR_NAME2HOST, (sysarg_t) af, 79 &answer); 79 80 80 81 int rc = async_data_write_start(exch, name, str_size(name)); -
uspace/lib/c/generic/inet/addr.c
r8a8a08d1 r330df83 260 260 } 261 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 } 275 } 276 262 277 int inet_naddr_compare_mask(const inet_naddr_t *naddr, const inet_addr_t *addr) 263 278 { -
uspace/lib/c/generic/net/socket_parse.c
r8a8a08d1 r330df83 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
r8a8a08d1 r330df83 97 97 extern int inet_addr_is_any(const inet_addr_t *); 98 98 99 extern int inet_naddr_compare(const inet_naddr_t *, const inet_addr_t *); 99 100 extern int inet_naddr_compare_mask(const inet_naddr_t *, const inet_addr_t *); 100 101 -
uspace/lib/c/include/inet/dnsr.h
r8a8a08d1 r330df83 51 51 52 52 extern int dnsr_init(void); 53 extern int dnsr_name2host(const char *, dnsr_hostinfo_t ** );53 extern int dnsr_name2host(const char *, dnsr_hostinfo_t **, uint16_t); 54 54 extern void dnsr_hostinfo_destroy(dnsr_hostinfo_t *); 55 55 extern int dnsr_get_srvaddr(inet_addr_t *); -
uspace/srv/net/dnsrsrv/dns_msg.c
r8a8a08d1 r330df83 296 296 uint32_t dns_uint32_t_decode(uint8_t *buf, size_t buf_size) 297 297 { 298 uint32_t w;299 298 assert(buf_size >= 4); 300 301 w = ((uint32_t) buf[0] << 24) +299 300 uint32_t w = ((uint32_t) buf[0] << 24) + 302 301 ((uint32_t) buf[1] << 16) + 303 302 ((uint32_t) buf[2] << 8) + 304 303 buf[3]; 305 304 306 305 return w; 306 } 307 308 /** Decode unaligned big-endian 128-bit integer */ 309 void dns_addr128_t_decode(uint8_t *buf, size_t buf_size, addr128_t addr) 310 { 311 assert(buf_size >= 16); 312 313 addr128_t_be2host(buf, addr); 307 314 } 308 315 … … 400 407 int rc; 401 408 402 rr = calloc(1, sizeof 409 rr = calloc(1, sizeof(dns_rr_t)); 403 410 if (rr == NULL) 404 411 return ENOMEM; … … 427 434 428 435 rr->rtype = dns_uint16_t_decode(bp, bsz); 429 bp += sizeof(uint16_t); bsz -= sizeof(uint16_t); 436 bp += sizeof(uint16_t); 437 bsz -= sizeof(uint16_t); 430 438 431 439 rr->rclass = dns_uint16_t_decode(bp, bsz); 432 bp += sizeof(uint16_t); bsz -= sizeof(uint16_t); 440 bp += sizeof(uint16_t); 441 bsz -= sizeof(uint16_t); 433 442 434 443 rr->ttl = dns_uint32_t_decode(bp, bsz); 435 bp += sizeof(uint32_t); bsz -= sizeof(uint32_t); 444 bp += sizeof(uint32_t); 445 bsz -= sizeof(uint32_t); 436 446 437 447 rdlength = dns_uint16_t_decode(bp, bsz); 438 bp += sizeof(uint16_t); bsz -= sizeof(uint16_t); 448 bp += sizeof(uint16_t); 449 bsz -= sizeof(uint16_t); 439 450 440 451 if (rdlength > bsz) { -
uspace/srv/net/dnsrsrv/dns_msg.h
r8a8a08d1 r330df83 40 40 #include <stdbool.h> 41 41 #include <stdint.h> 42 #include <inet/addr.h> 42 43 #include "dns_std.h" 43 44 #include "dns_type.h" … … 49 50 extern int dns_name_decode(dns_pdu_t *, size_t, char **, size_t *); 50 51 extern uint32_t dns_uint32_t_decode(uint8_t *, size_t); 52 extern void dns_addr128_t_decode(uint8_t *, size_t, addr128_t); 53 51 54 52 55 #endif -
uspace/srv/net/dnsrsrv/dns_std.h
r8a8a08d1 r330df83 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/dnsrsrv/dnsrsrv.c
r8a8a08d1 r330df83 89 89 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_get_srvaddr_srv()"); 90 90 91 uint16_t af = IPC_GET_ARG1(*icall); 92 91 93 char *name; 92 94 int rc = async_data_write_accept((void **) &name, true, 0, … … 98 100 99 101 dns_host_info_t *hinfo; 100 rc = dns_name2host(name, &hinfo );102 rc = dns_name2host(name, &hinfo, af); 101 103 if (rc != EOK) { 102 104 async_answer_0(iid, rc); -
uspace/srv/net/dnsrsrv/query.c
r8a8a08d1 r330df83 39 39 #include <stdlib.h> 40 40 #include <str.h> 41 41 #include <net/socket_codes.h> 42 42 #include "dns_msg.h" 43 43 #include "dns_std.h" … … 48 48 static uint16_t msg_id; 49 49 50 int dns_name2host(const char *name, dns_host_info_t **rinfo) 50 static int dns_name_query(const char *name, dns_qtype_t qtype, 51 dns_host_info_t *info) 51 52 { 52 dns_message_t *msg; 53 dns_message_t *amsg; 54 dns_question_t *question; 55 dns_host_info_t *info; 56 char *sname, *cname; 57 size_t eoff; 58 int rc; 59 60 question = calloc(1, sizeof(dns_question_t)); 61 if (question == NULL) 62 return ENOMEM; 63 64 question->qname = (char *)name; 65 question->qtype = DTYPE_A; 53 /* Start with the caller-provided name */ 54 char *sname = str_dup(name); 55 if (sname == NULL) 56 return ENOMEM; 57 58 char *qname = str_dup(name); 59 if (qname == NULL) { 60 free(sname); 61 return ENOMEM; 62 } 63 64 dns_question_t *question = calloc(1, sizeof(dns_question_t)); 65 if (question == NULL) { 66 free(qname); 67 free(sname); 68 return ENOMEM; 69 } 70 71 question->qname = qname; 72 question->qtype = qtype; 66 73 question->qclass = DC_IN; 67 68 msg = dns_message_new(); 69 if (msg == NULL) 70 return ENOMEM; 71 72 list_append(&question->msg, &msg->question); 73 74 75 dns_message_t *msg = dns_message_new(); 76 if (msg == NULL) { 77 free(question); 78 free(qname); 79 free(sname); 80 return ENOMEM; 81 } 82 74 83 msg->id = msg_id++; 75 84 msg->qr = QR_QUERY; … … 79 88 msg->rd = true; 80 89 msg->ra = false; 81 82 rc = dns_request(msg, &amsg); 90 91 list_append(&question->msg, &msg->question); 92 93 dns_message_t *amsg; 94 int rc = dns_request(msg, &amsg); 83 95 if (rc != EOK) { 96 dns_message_destroy(msg); 97 free(sname); 84 98 return rc; 85 99 } 86 87 /* Start with the caller-provided name */ 88 sname = str_dup(name); 89 100 90 101 list_foreach(amsg->answer, link) { 91 102 dns_rr_t *rr = list_get_instance(link, dns_rr_t, msg); 92 103 93 104 log_msg(LOG_DEFAULT, LVL_DEBUG, " - '%s' %u/%u, dsize %zu", 94 rr->name, rr->rtype, rr->rclass, rr->rdata_size); 95 96 if (rr->rtype == DTYPE_CNAME && rr->rclass == DC_IN && 97 str_cmp(rr->name, sname) == 0) { 105 rr->name, rr->rtype, rr->rclass, rr->rdata_size); 106 107 if ((rr->rtype == DTYPE_CNAME) && (rr->rclass == DC_IN) && 108 (str_cmp(rr->name, sname) == 0)) { 109 98 110 log_msg(LOG_DEFAULT, LVL_DEBUG, "decode cname (%p, %zu, %zu)", 99 111 amsg->pdu.data, amsg->pdu.size, rr->roff); 112 113 char *cname; 114 size_t eoff; 100 115 rc = dns_name_decode(&amsg->pdu, rr->roff, &cname, &eoff); 101 116 if (rc != EOK) { 102 log_msg(LOG_DEFAULT, LVL_DEBUG, 103 "error decoding cname"); 104 assert(rc == EINVAL || rc == ENOMEM); 117 assert((rc == EINVAL) || (rc == ENOMEM)); 118 119 log_msg(LOG_DEFAULT, LVL_DEBUG, "error decoding cname"); 120 105 121 dns_message_destroy(msg); 106 122 dns_message_destroy(amsg); 123 free(sname); 124 107 125 return rc; 108 126 } 109 127 110 128 log_msg(LOG_DEFAULT, LVL_DEBUG, "name = '%s' " 111 129 "cname = '%s'", sname, cname); 112 130 131 /* Continue looking for the more canonical name */ 113 132 free(sname); 114 /* Continue looking for the more canonical name */115 133 sname = cname; 116 134 } 117 118 if ( rr->rtype == DTYPE_A && rr->rclass == DC_IN&&119 rr->rdata_size == sizeof(uint32_t) &&120 str_cmp(rr->name, sname) == 0) {121 122 info = calloc(1, sizeof(dns_host_info_t));123 if (info == NULL) {135 136 if ((qtype == DTYPE_A) && (rr->rtype == DTYPE_A) && 137 (rr->rclass == DC_IN) && (rr->rdata_size == sizeof(addr32_t)) && 138 (str_cmp(rr->name, sname) == 0)) { 139 140 info->cname = str_dup(rr->name); 141 if (info->cname == NULL) { 124 142 dns_message_destroy(msg); 125 143 dns_message_destroy(amsg); 144 free(sname); 145 126 146 return ENOMEM; 127 147 } 128 129 info->cname = str_dup(rr->name); 148 130 149 inet_addr_set(dns_uint32_t_decode(rr->rdata, rr->rdata_size), 131 150 &info->addr); … … 133 152 dns_message_destroy(msg); 134 153 dns_message_destroy(amsg); 135 *rinfo = info; 154 free(sname); 155 136 156 return EOK; 137 157 } 138 } 139 158 159 if ((qtype == DTYPE_AAAA) && (rr->rtype == DTYPE_AAAA) && 160 (rr->rclass == DC_IN) && (rr->rdata_size == sizeof(addr128_t)) && 161 (str_cmp(rr->name, sname) == 0)) { 162 163 info->cname = str_dup(rr->name); 164 if (info->cname == NULL) { 165 dns_message_destroy(msg); 166 dns_message_destroy(amsg); 167 free(sname); 168 169 return ENOMEM; 170 } 171 172 addr128_t addr; 173 dns_addr128_t_decode(rr->rdata, rr->rdata_size, addr); 174 175 inet_addr_set6(addr, &info->addr); 176 177 dns_message_destroy(msg); 178 dns_message_destroy(amsg); 179 free(sname); 180 181 return EOK; 182 } 183 } 184 185 log_msg(LOG_DEFAULT, LVL_DEBUG, "'%s' not resolved, fail", sname); 186 140 187 dns_message_destroy(msg); 141 188 dns_message_destroy(amsg); 142 log_msg(LOG_DEFAULT, LVL_DEBUG, "'%s' not resolved, fail",sname);143 189 free(sname); 190 144 191 return EIO; 192 } 193 194 int dns_name2host(const char *name, dns_host_info_t **rinfo, uint16_t af) 195 { 196 dns_host_info_t *info = calloc(1, sizeof(dns_host_info_t)); 197 if (info == NULL) 198 return ENOMEM; 199 200 int rc; 201 202 switch (af) { 203 case AF_NONE: 204 rc = dns_name_query(name, DTYPE_AAAA, info); 205 206 if (rc != EOK) 207 rc = dns_name_query(name, DTYPE_A, info); 208 209 break; 210 case AF_INET: 211 rc = dns_name_query(name, DTYPE_A, info); 212 break; 213 case AF_INET6: 214 rc = dns_name_query(name, DTYPE_AAAA, info); 215 break; 216 default: 217 rc = EINVAL; 218 } 219 220 if (rc == EOK) 221 *rinfo = info; 222 else 223 free(info); 224 225 return rc; 145 226 } 146 227 -
uspace/srv/net/dnsrsrv/query.h
r8a8a08d1 r330df83 39 39 #include "dns_type.h" 40 40 41 extern int dns_name2host(const char *, dns_host_info_t ** );41 extern int dns_name2host(const char *, dns_host_info_t **, uint16_t); 42 42 extern void dns_hostinfo_destroy(dns_host_info_t *); 43 43 -
uspace/srv/net/ethip/pdu.c
r8a8a08d1 r330df83 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/addrobj.c
r8a8a08d1 r330df83 119 119 inet_addrobj_t, addr_list); 120 120 121 if (inet_naddr_compare_mask(&naddr->naddr, addr)) { 122 fibril_mutex_unlock(&addr_list_lock); 123 log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_addrobj_find: found %p", 124 naddr); 125 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; 126 138 } 127 139 } -
uspace/srv/net/inetsrv/icmp.c
r8a8a08d1 r330df83 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
r8a8a08d1 r330df83 78 78 inet_dgram_t rdgram; 79 79 80 rdgram.src = dgram->dest;80 inet_get_srcaddr(&dgram->src, 0, &rdgram.src); 81 81 rdgram.dest = dgram->src; 82 82 rdgram.tos = 0; … … 84 84 rdgram.size = size; 85 85 86 icmpv6_p seudo_headerphdr;86 icmpv6_phdr_t phdr; 87 87 88 88 host2addr128_t_be(dest_v6, phdr.src_addr); … … 94 94 uint16_t cs_phdr = 95 95 inet_checksum_calc(INET_CHECKSUM_INIT, &phdr, 96 sizeof(icmpv6_p seudo_header));96 sizeof(icmpv6_phdr_t)); 97 97 98 98 uint16_t cs_all = inet_checksum_calc(cs_phdr, reply, size); … … 150 150 case ICMPV6_NEIGHBOUR_SOLICITATION: 151 151 case ICMPV6_NEIGHBOUR_ADVERTISEMENT: 152 #ifdef ACCEPT_RA153 152 case ICMPV6_ROUTER_ADVERTISEMENT: 154 #endif155 153 return ndp_received(dgram); 156 154 default: … … 186 184 dgram.size = rsize; 187 185 188 icmpv6_p seudo_headerphdr;186 icmpv6_phdr_t phdr; 189 187 190 188 host2addr128_t_be(sdu->src, phdr.src_addr); … … 196 194 uint16_t cs_phdr = 197 195 inet_checksum_calc(INET_CHECKSUM_INIT, &phdr, 198 sizeof(icmpv6_p seudo_header));196 sizeof(icmpv6_phdr_t)); 199 197 200 198 uint16_t cs_all = inet_checksum_calc(cs_phdr, rdata, rsize); -
uspace/srv/net/inetsrv/icmpv6_std.h
r8a8a08d1 r330df83 104 104 /** Next header */ 105 105 uint8_t next; 106 } icmpv6_p seudo_header;106 } icmpv6_phdr_t; 107 107 108 108 /** NDP neighbour body */ -
uspace/srv/net/inetsrv/inet_link.c
r8a8a08d1 r330df83 51 51 static bool first_link = true; 52 52 static bool first_link6 = true; 53 54 static FIBRIL_MUTEX_INITIALIZE(ip_ident_lock); 55 static uint16_t ip_ident = 0; 53 56 54 57 static int inet_link_open(service_id_t); … … 335 338 } 336 339 337 /** Send IPv4 datagram over Internet link */ 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 */ 338 355 int inet_link_send_dgram(inet_link_t *ilink, addr32_t lsrc, addr32_t ldest, 339 356 inet_dgram_t *dgram, uint8_t proto, uint8_t ttl, int df) … … 366 383 packet.proto = proto; 367 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 368 391 packet.df = df; 369 392 packet.data = dgram->data; 370 393 packet.size = dgram->size; 371 394 395 int rc; 372 396 size_t offs = 0; 373 int rc;374 397 375 398 do { … … 392 415 } 393 416 394 /** Send IPv6 datagram over Internet link */ 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 */ 395 430 int inet_link_send_dgram6(inet_link_t *ilink, addr48_t ldest, 396 431 inet_dgram_t *dgram, uint8_t proto, uint8_t ttl, int df) … … 421 456 packet.proto = proto; 422 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 423 464 packet.df = df; 424 465 packet.data = dgram->data; -
uspace/srv/net/inetsrv/inet_std.h
r8a8a08d1 r330df83 40 40 #include <sys/types.h> 41 41 42 #define IP6_NEXT_FRAGMENT 44 43 42 44 /** IPv4 Datagram header (fixed part) */ 43 45 typedef struct { … … 48 50 /** Total Length */ 49 51 uint16_t tot_len; 50 /** Identifi cation*/52 /** Identifier */ 51 53 uint16_t id; 52 54 /** Flags, Fragment Offset */ … … 90 92 }; 91 93 94 /** Bits in ip6_header_fragment_t.offsmf */ 95 enum flags_offsmt_bits { 96 /** More fragments */ 97 OF_FLAG_M = 0, 98 /** Fragment offset, highest bit */ 99 OF_FRAGOFF_h = 15, 100 /** Fragment offset, lowest bit */ 101 OF_FRAGOFF_l = 3 102 }; 103 92 104 /** IPv6 Datagram header (fixed part) */ 93 105 typedef struct { … … 114 126 /** Reserved */ 115 127 uint8_t reserved; 116 /** Fragment Offset, Flags*/117 uint16_t foff_flags;118 /** Identifi cation*/128 /** Fragmentation offset, reserved and M flag */ 129 uint16_t offsmf; 130 /** Identifier */ 119 131 uint32_t id; 120 132 } ip6_header_fragment_t; -
uspace/srv/net/inetsrv/inetsrv.c
r8a8a08d1 r330df83 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
r8a8a08d1 r330df83 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; -
uspace/srv/net/inetsrv/ndp.c
r8a8a08d1 r330df83 38 38 #include <mem.h> 39 39 #include <malloc.h> 40 #include <io/log.h> 40 41 #include <net/socket_codes.h> 41 42 #include "ntrans.h" … … 54 55 {0xff, 0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x01, 0xff, 0, 0, 0}; 55 56 57 /** Compute solicited node MAC multicast address from target IPv6 address 58 * 59 * @param ip_addr Target IPv6 address 60 * @param mac_addr Solicited MAC address to be assigned 61 * 62 */ 56 63 static void ndp_solicited_node_mac(addr128_t ip_addr, addr48_t mac_addr) 57 64 { … … 60 67 } 61 68 69 /** Compute solicited node IPv6 multicast address from target IPv6 address 70 * 71 * @param ip_addr Target IPv6 address 72 * @param ip_solicited Solicited IPv6 address to be assigned 73 * 74 */ 62 75 static void ndp_solicited_node_ip(addr128_t ip_addr, 63 76 addr128_t ip_solicited) … … 88 101 int ndp_received(inet_dgram_t *dgram) 89 102 { 103 log_msg(LOG_DEFAULT, LVL_DEBUG, "ndp_received()"); 104 90 105 ndp_packet_t packet; 91 106 int rc = ndp_pdu_decode(dgram, &packet); … … 100 115 101 116 inet_addrobj_t *laddr; 117 118 log_msg(LOG_DEFAULT, LVL_DEBUG, "NDP PDU decoded; opcode: %d", 119 packet.opcode); 102 120 103 121 switch (packet.opcode) { … … 138 156 } 139 157 158 /** Translate IPv6 to MAC address 159 * 160 * @param src Source IPv6 address 161 * @param dest Destination IPv6 address 162 * @param mac Target MAC address to be assigned 163 * @param link Network interface 164 * 165 * @return EOK on success 166 * @return ENOENT when NDP translation failed 167 * 168 */ 140 169 int ndp_translate(addr128_t src_addr, addr128_t ip_addr, addr48_t mac_addr, 141 170 inet_link_t *ilink) -
uspace/srv/net/inetsrv/ndp.h
r8a8a08d1 r330df83 35 35 */ 36 36 37 #ifndef ETH_NDP_H_38 #define ETH_NDP_H_37 #ifndef NDP_H_ 38 #define NDP_H_ 39 39 40 40 #include <sys/types.h> -
uspace/srv/net/inetsrv/ntrans.c
r8a8a08d1 r330df83 47 47 static FIBRIL_CONDVAR_INITIALIZE(ntrans_cv); 48 48 49 /** Look for address in translation table 50 * 51 * @param ip_addr IPv6 address 52 * 53 * @return inet_ntrans_t with the address on success 54 * @return NULL if nothing found 55 */ 49 56 static inet_ntrans_t *ntrans_find(addr128_t ip_addr) 50 57 { … … 60 67 } 61 68 69 /** Add entry to translation table 70 * 71 * @param ip_addr IPv6 address of the new entry 72 * @param mac_addr MAC address of the new entry 73 * 74 * @return EOK on success 75 * @return ENOMEM if not enough memory 76 * 77 */ 62 78 int ntrans_add(addr128_t ip_addr, addr48_t mac_addr) 63 79 { … … 86 102 } 87 103 104 /** Remove entry from translation table 105 * 106 * @param ip_addr IPv6 address of the entry to be removed 107 * 108 * @return EOK on success 109 * @return ENOENT when no such address found 110 * 111 */ 88 112 int ntrans_remove(addr128_t ip_addr) 89 113 { … … 104 128 } 105 129 130 /** Translate IPv6 address to MAC address using the translation table 131 * 132 * @param ip_addr IPv6 address to be translated 133 * @param mac_addr MAC address to be assigned 134 * 135 * @return EOK on success 136 * @return ENOENT when no such address found 137 * 138 */ 106 139 int ntrans_lookup(addr128_t ip_addr, addr48_t mac_addr) 107 140 { … … 118 151 } 119 152 153 /** Wait on translation table CV for some time 154 * 155 * @param timeout Timeout in microseconds 156 * 157 * @return EOK if woken up by another fibril 158 * @return ETIMEDOUT if timed out 159 * 160 */ 120 161 int ntrans_wait_timeout(suseconds_t timeout) 121 162 { -
uspace/srv/net/inetsrv/pdu.c
r8a8a08d1 r330df83 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 * … … 107 104 */ 108 105 int inet_pdu_encode(inet_packet_t *packet, addr32_t src, addr32_t dest, 109 size_t offs, size_t mtu, void **rdata, size_t *rsize, size_t *roffs)106 size_t offs, size_t mtu, void **rdata, size_t *rsize, size_t *roffs) 110 107 { 111 108 /* Upper bound for fragment offset field */ … … 117 114 118 115 size_t hdr_size = sizeof(ip_header_t); 119 120 size_t data_offs = ROUND_UP(hdr_size, 4); 121 116 if (hdr_size >= mtu) 117 return EINVAL; 118 119 assert(hdr_size % 4 == 0); 122 120 assert(offs % FRAG_OFFS_UNIT == 0); 123 121 assert(offs / FRAG_OFFS_UNIT < fragoff_limit); … … 125 123 /* Value for the fragment offset field */ 126 124 uint16_t foff = offs / FRAG_OFFS_UNIT; 127 128 if (hdr_size >= mtu)129 return EINVAL;130 125 131 126 /* Amount of space in the PDU available for payload */ … … 152 147 return ENOMEM; 153 148 154 /* Allocate identifier */155 fibril_mutex_lock(&ip_ident_lock);156 uint16_t ident = ++ip_ident;157 fibril_mutex_unlock(&ip_ident_lock);158 159 149 /* Encode header fields */ 160 150 ip_header_t *hdr = (ip_header_t *) data; … … 164 154 hdr->tos = packet->tos; 165 155 hdr->tot_len = host2uint16_t_be(size); 166 hdr->id = host2uint16_t_be( ident);156 hdr->id = host2uint16_t_be(packet->ident); 167 157 hdr->flags_foff = host2uint16_t_be(flags_foff); 168 158 hdr->ttl = packet->ttl; … … 178 168 179 169 /* Copy payload */ 180 memcpy((uint8_t *) data + data_offs, packet->data + offs, xfer_size);170 memcpy((uint8_t *) data + hdr_size, packet->data + offs, xfer_size); 181 171 182 172 *rdata = data; … … 202 192 * @param rdata Place to store pointer to allocated data buffer 203 193 * @param rsize Place to store size of allocated data buffer 204 * @param roffs Place to store offset of remaning data194 * @param roffs Place to store offset of remaning data 205 195 * 206 196 */ … … 208 198 size_t offs, size_t mtu, void **rdata, size_t *rsize, size_t *roffs) 209 199 { 200 /* IPv6 mandates a minimal MTU of 1280 bytes */ 201 if (mtu < 1280) 202 return ELIMIT; 203 210 204 /* Upper bound for fragment offset field */ 211 size_t fragoff_limit = 1 << ( FF_FRAGOFF_h - FF_FRAGOFF_l);205 size_t fragoff_limit = 1 << (OF_FRAGOFF_h - OF_FRAGOFF_l); 212 206 213 207 /* Verify that total size of datagram is within reasonable bounds */ … … 215 209 return ELIMIT; 216 210 217 size_t hdr_size = sizeof(ip6_header_t); 218 219 size_t data_offs = ROUND_UP(hdr_size, 4); 220 211 /* Determine whether we need the Fragment extension header */ 212 bool fragment; 213 if (offs == 0) 214 fragment = (packet->size + sizeof(ip6_header_t) > mtu); 215 else 216 fragment = true; 217 218 size_t hdr_size; 219 if (fragment) 220 hdr_size = sizeof(ip6_header_t) + sizeof(ip6_header_fragment_t); 221 else 222 hdr_size = sizeof(ip6_header_t); 223 224 if (hdr_size >= mtu) 225 return EINVAL; 226 227 assert(sizeof(ip6_header_t) % 8 == 0); 228 assert(hdr_size % 8 == 0); 221 229 assert(offs % FRAG_OFFS_UNIT == 0); 222 230 assert(offs / FRAG_OFFS_UNIT < fragoff_limit); 223 231 224 #if 0225 // FIXME TODO fragmentation226 227 232 /* Value for the fragment offset field */ 228 233 uint16_t foff = offs / FRAG_OFFS_UNIT; 229 #endif230 231 if (hdr_size >= mtu)232 return EINVAL;233 234 234 235 /* Amount of space in the PDU available for payload */ … … 245 246 size_t rem_offs = offs + xfer_size; 246 247 247 #if 0248 // FIXME TODO fragmentation249 250 248 /* Flags */ 251 uint16_t flags_foff = 252 (packet->df ? BIT_V(uint16_t, FF_FLAG_DF) : 0) + 253 (rem_offs < packet->size ? BIT_V(uint16_t, FF_FLAG_MF) : 0) + 254 (foff << FF_FRAGOFF_l); 255 #endif 249 uint16_t offsmf = 250 (rem_offs < packet->size ? BIT_V(uint16_t, OF_FLAG_M) : 0) + 251 (foff << OF_FRAGOFF_l); 256 252 257 253 void *data = calloc(size, 1); … … 259 255 return ENOMEM; 260 256 261 #if 0262 // FIXME TODO fragmentation263 264 /* Allocate identifier */265 fibril_mutex_lock(&ip_ident_lock);266 uint16_t ident = ++ip_ident;267 fibril_mutex_unlock(&ip_ident_lock);268 #endif269 270 257 /* Encode header fields */ 271 258 ip6_header_t *hdr6 = (ip6_header_t *) data; … … 273 260 hdr6->ver_tc = (6 << (VI_VERSION_l)); 274 261 memset(hdr6->tc_fl, 0, 3); 275 hdr6->payload_len = host2uint16_t_be(packet->size);276 hdr6->next = packet->proto;277 262 hdr6->hop_limit = packet->ttl; 278 263 … … 280 265 host2addr128_t_be(dest, hdr6->dest_addr); 281 266 267 /* Optionally encode Fragment extension header fields */ 268 if (fragment) { 269 assert(offsmf != 0); 270 271 hdr6->payload_len = host2uint16_t_be(packet->size + 272 sizeof(ip6_header_fragment_t)); 273 hdr6->next = IP6_NEXT_FRAGMENT; 274 275 ip6_header_fragment_t *hdr6f = (ip6_header_fragment_t *) 276 (hdr6 + 1); 277 278 hdr6f->next = packet->proto; 279 hdr6f->reserved = 0; 280 hdr6f->offsmf = host2uint16_t_be(offsmf); 281 hdr6f->id = host2uint32_t_be(packet->ident); 282 } else { 283 assert(offsmf == 0); 284 285 hdr6->payload_len = host2uint16_t_be(packet->size); 286 hdr6->next = packet->proto; 287 } 288 282 289 /* Copy payload */ 283 memcpy((uint8_t *) data + data_offs, packet->data + offs, xfer_size);290 memcpy((uint8_t *) data + hdr_size, packet->data + offs, xfer_size); 284 291 285 292 *rdata = data; … … 290 297 } 291 298 299 /** Decode IPv4 datagram 300 * 301 * @param data Serialized IPv4 datagram 302 * @param size Length of serialized IPv4 datagram 303 * @param packet IP datagram structure to be filled 304 * 305 * @return EOK on success 306 * @return EINVAL if the datagram is invalid or damaged 307 * @return ENOMEM if not enough memory 308 * 309 */ 292 310 int inet_pdu_decode(void *data, size_t size, inet_packet_t *packet) 293 311 { … … 353 371 } 354 372 373 /** Decode IPv6 datagram 374 * 375 * @param data Serialized IPv6 datagram 376 * @param size Length of serialized IPv6 datagram 377 * @param packet IP datagram structure to be filled 378 * 379 * @return EOK on success 380 * @return EINVAL if the datagram is invalid or damaged 381 * @return ENOMEM if not enough memory 382 * 383 */ 355 384 int inet_pdu_decode6(void *data, size_t size, inet_packet_t *packet) 356 385 { … … 373 402 size_t payload_len = uint16_t_be2host(hdr6->payload_len); 374 403 if (payload_len + sizeof(ip6_header_t) > size) { 375 log_msg(LOG_DEFAULT, LVL_DEBUG, " TotalLength = %zu > PDU size = %zu",404 log_msg(LOG_DEFAULT, LVL_DEBUG, "Payload Length = %zu > PDU size = %zu", 376 405 payload_len + sizeof(ip6_header_t), size); 377 406 return EINVAL; 378 407 } 379 408 380 #if 0 381 // FIXME TODO fragmentation 382 383 uint16_t ident = uint16_t_be2host(hdr->id); 384 uint16_t flags_foff = uint16_t_be2host(hdr->flags_foff); 385 uint16_t foff = BIT_RANGE_EXTRACT(uint16_t, FF_FRAGOFF_h, FF_FRAGOFF_l, 386 flags_foff); 387 #endif 388 389 /* XXX Checksum */ 409 uint32_t ident; 410 uint16_t offsmf; 411 uint16_t foff; 412 uint16_t next; 413 size_t data_offs = sizeof(ip6_header_t); 414 415 /* Fragment extension header */ 416 if (hdr6->next == IP6_NEXT_FRAGMENT) { 417 ip6_header_fragment_t *hdr6f = (ip6_header_fragment_t *) 418 (hdr6 + 1); 419 420 ident = uint32_t_be2host(hdr6f->id); 421 offsmf = uint16_t_be2host(hdr6f->offsmf); 422 foff = BIT_RANGE_EXTRACT(uint16_t, OF_FRAGOFF_h, OF_FRAGOFF_l, 423 offsmf); 424 next = hdr6f->next; 425 data_offs += sizeof(ip6_header_fragment_t); 426 payload_len -= sizeof(ip6_header_fragment_t); 427 } else { 428 ident = 0; 429 offsmf = 0; 430 foff = 0; 431 next = hdr6->next; 432 } 390 433 391 434 addr128_t src; … … 399 442 400 443 packet->tos = 0; 401 packet->proto = hdr6->next;444 packet->proto = next; 402 445 packet->ttl = hdr6->hop_limit; 403 404 #if 0405 // FIXME TODO fragmentation406 407 446 packet->ident = ident; 408 packet->df = (flags_foff & BIT_V(uint16_t, FF_FLAG_DF)) != 0; 409 packet->mf = (flags_foff & BIT_V(uint16_t, FF_FLAG_MF)) != 0; 447 448 packet->df = 1; 449 packet->mf = (offsmf & BIT_V(uint16_t, OF_FLAG_M)) != 0; 410 450 packet->offs = foff * FRAG_OFFS_UNIT; 411 412 /* XXX IP options */413 size_t data_offs = sizeof(uint32_t) *414 BIT_RANGE_EXTRACT(uint8_t, VI_IHL_h, VI_IHL_l, hdr->ver_ihl);415 #endif416 417 packet->ident = 0;418 packet->df = 0;419 packet->mf = 0;420 packet->offs = 0;421 451 422 452 packet->size = payload_len; … … 427 457 } 428 458 429 memcpy(packet->data, (uint8_t *) data + sizeof(ip6_header_t), packet->size);459 memcpy(packet->data, (uint8_t *) data + data_offs, packet->size); 430 460 431 461 return EOK; 432 462 } 433 463 464 /** Encode NDP packet 465 * 466 * @param ndp NDP packet structure to be serialized 467 * @param dgram IPv6 datagram structure to be filled 468 * 469 * @return EOK on success 470 * 471 */ 434 472 int ndp_pdu_encode(ndp_packet_t *ndp, inet_dgram_t *dgram) 435 473 { … … 464 502 addr48(ndp->sender_hw_addr, message->mac); 465 503 466 icmpv6_p seudo_headerphdr;504 icmpv6_phdr_t phdr; 467 505 468 506 host2addr128_t_be(ndp->sender_proto_addr, phdr.src_addr); … … 474 512 uint16_t cs_phdr = 475 513 inet_checksum_calc(INET_CHECKSUM_INIT, &phdr, 476 sizeof(icmpv6_p seudo_header));514 sizeof(icmpv6_phdr_t)); 477 515 478 516 uint16_t cs_all = inet_checksum_calc(cs_phdr, dgram->data, … … 484 522 } 485 523 524 /** Decode NDP packet 525 * 526 * @param dgram Incoming IPv6 datagram encapsulating NDP packet 527 * @param ndp NDP packet structure to be filled 528 * 529 * @return EOK on success 530 * @return EINVAL if the Datagram is invalid 531 * 532 */ 486 533 int ndp_pdu_decode(inet_dgram_t *dgram, ndp_packet_t *ndp) 487 534 { -
uspace/srv/net/inetsrv/reass.c
r8a8a08d1 r330df83 164 164 return NULL; 165 165 166 li nk_initialize(&rdg->map_link);166 list_append(&rdg->map_link, &reass_dgram_map); 167 167 list_initialize(&rdg->frags); 168 168 -
uspace/srv/net/tcp/conn.c
r8a8a08d1 r330df83 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
r8a8a08d1 r330df83 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
r8a8a08d1 r330df83 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
r8a8a08d1 r330df83 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
r8a8a08d1 r330df83 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
r8a8a08d1 r330df83 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
r8a8a08d1 r330df83 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
r8a8a08d1 r330df83 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
r8a8a08d1 r330df83 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
r8a8a08d1 r330df83 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
r8a8a08d1 r330df83 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.