Changeset 08a6382 in mainline
- Timestamp:
- 2012-08-12T20:17:31Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e5e73af
- Parents:
- f85ed4b
- Location:
- uspace/srv/net
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/dnsres/dns_msg.c
rf85ed4b r08a6382 35 35 36 36 #include <bitops.h> 37 #include <byteorder.h> 37 38 #include <errno.h> 38 39 #include <stdint.h> … … 87 88 buf[pi] = (uint8_t)lsize; 88 89 90 lsize = 0; 91 pi = di; 92 ++di; 93 89 94 if (c == '\0') 90 95 break; 91 92 pi = di; 96 } else { 97 if (buf != NULL && di < buf_size) 98 buf[di] = c; 93 99 ++di; 94 } else {95 100 ++lsize; 96 if (buf != NULL && di < buf_size)97 buf[di++] = c;98 101 } 99 102 } … … 126 129 return rc; 127 130 131 printf("name_size=%zu\n", name_size); 132 128 133 *act_size = name_size + sizeof(uint16_t) + sizeof(uint16_t); 134 printf("act_size=%zu\n", *act_size); 129 135 if (buf == NULL) 130 136 return EOK; … … 138 144 di += sizeof(uint16_t); 139 145 140 *act_size = di;141 146 return EOK; 142 147 } … … 151 156 int rc; 152 157 153 hdr.id = msg->id;154 155 hdr.opbits = 158 hdr.id = host2uint16_t_be(msg->id); 159 160 hdr.opbits = host2uint16_t_be( 156 161 (msg->qr << OPB_QR) | 157 162 (msg->opcode << OPB_OPCODE_l) | … … 160 165 (msg->rd ? BIT_V(uint16_t, OPB_RD) : 0) | 161 166 (msg->ra ? BIT_V(uint16_t, OPB_RA) : 0) | 162 msg->rcode; 163 164 hdr.qd_count = list_count(&msg->question); 167 msg->rcode 168 ); 169 170 hdr.qd_count = host2uint16_t_be(list_count(&msg->question)); 165 171 hdr.an_count = 0; 166 172 hdr.ns_count = 0; … … 168 174 169 175 size = sizeof(dns_header_t); 176 printf("dns header size=%zu\n", size); 170 177 171 178 list_foreach(msg->question, link) { … … 175 182 return rc; 176 183 184 printf("q_size=%zu\n", q_size); 177 185 size += q_size; 178 186 } … … 193 201 } 194 202 203 printf("-> size=%zu, di=%zu\n", size, di); 195 204 *rdata = data; 196 205 *rsize = size; -
uspace/srv/net/dnsres/query.c
rf85ed4b r08a6382 35 35 36 36 #include <errno.h> 37 #include <mem.h> 37 38 38 39 #include "dns_std.h" … … 53 54 question.qtype = DTYPE_A; 54 55 question.qclass = DC_IN; 56 57 memset(&msg, 0, sizeof(msg)); 55 58 56 59 list_initialize(&msg.question); -
uspace/srv/net/dnsres/transport.c
rf85ed4b r08a6382 35 35 36 36 #include <errno.h> 37 #include <net/in.h> 38 #include <net/inet.h> 39 #include <net/socket.h> 40 #include <stdlib.h> 37 41 38 42 #include "dns_msg.h" … … 40 44 #include "transport.h" 41 45 46 #include <stdio.h> 42 47 int dns_request(dns_message_t *req, dns_message_t **rresp) 43 48 { … … 46 51 void *req_data; 47 52 size_t req_size; 53 struct sockaddr_in addr; 54 int fd; 55 56 addr.sin_family = AF_INET; 57 addr.sin_port = htons(53); 58 addr.sin_addr.s_addr = htonl((192 << 24) | (168 << 16) | (0 << 8) | 1); 59 60 req_data = NULL; 61 fd = -1; 48 62 49 63 rc = dns_message_encode(req, &req_data, &req_size); 50 64 if (rc != EOK) 51 return rc; 65 goto error; 66 67 fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); 68 if (fd < 0) { 69 rc = EIO; 70 goto error; 71 } 72 73 printf("fd=%d req_data=%p, req_size=%zu\n", fd, req_data, req_size); 74 rc = sendto(fd, req_data, req_size, 0, (struct sockaddr *)&addr, 75 sizeof(addr)); 76 if (rc != EOK) 77 goto error; 52 78 53 79 resp = NULL; 54 80 *rresp = resp; 55 81 return EOK; 82 83 error: 84 if (req_data != NULL) 85 free(req_data); 86 if (fd >= 0) 87 closesocket(fd); 88 return rc; 56 89 } 57 90 -
uspace/srv/net/udp/sock.c
rf85ed4b r08a6382 359 359 rc = EOK; 360 360 break; 361 /* case TCP_ENOTEXIST:361 case UDP_ENORES: 362 362 rc = ENOTCONN; 363 363 break; 364 case TCP_ECLOSING:365 rc = E NOTCONN;366 break; 367 case TCP_ERESET:368 rc = E CONNABORTED;369 break; */364 case UDP_EUNSPEC: 365 rc = EINVAL; 366 break; 367 case UDP_ENOROUTE: 368 rc = EIO; 369 break; 370 370 default: 371 371 assert(false);
Note:
See TracChangeset
for help on using the changeset viewer.