Changeset 08a6382 in mainline for uspace/srv/net/dnsres/transport.c
- Timestamp:
- 2012-08-12T20:17:31Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e5e73af
- Parents:
- f85ed4b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.