Changeset f85ed4b in mainline
- Timestamp:
- 2012-08-12T17:51:26Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 08a6382
- Parents:
- adae30d
- Location:
- uspace/srv/net/dnsres
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/dnsres/dns_msg.c
radae30d rf85ed4b 45 45 #define NAME "dnsres" 46 46 47 #include <stdio.h> 47 48 static int dns_name_encode(char *name, uint8_t *buf, size_t buf_size, 48 49 size_t *act_size) … … 55 56 pi = 0; 56 57 di = 1; 57 58 off = 0; 59 60 printf("dns_name_encode(name='%s', buf=%p, buf_size=%zu, act_size=%p\n", 61 name, buf, buf_size, act_size); 58 62 lsize = 0; 59 63 while (true) { 64 printf("off=%zu\n", off); 60 65 c = str_decode(name, &off, STR_NO_LIMIT); 66 printf("c=%d\n", (int)c); 61 67 if (c > 127) { 62 68 /* Non-ASCII character */ 69 printf("non-ascii character\n"); 63 70 return EINVAL; 64 71 } … … 66 73 if (c == '.' || c == '\0') { 67 74 /* Empty string, starting with period or two consecutive periods. */ 68 if (lsize == 0) 75 if (lsize == 0) { 76 printf("empty token\n"); 69 77 return EINVAL; 78 } 70 79 71 80 if (lsize > DNS_LABEL_MAX_SIZE) { 72 81 /* Label too long */ 82 printf("label too long\n"); 73 83 return EINVAL; 74 84 } … … 83 93 ++di; 84 94 } else { 95 ++lsize; 85 96 if (buf != NULL && di < buf_size) 86 97 buf[di++] = c; … … 116 127 117 128 *act_size = name_size + sizeof(uint16_t) + sizeof(uint16_t); 129 if (buf == NULL) 130 return EOK; 131 118 132 di = name_size; 119 133 -
uspace/srv/net/dnsres/dns_type.h
radae30d rf85ed4b 69 69 /** Unencoded DNS message question section */ 70 70 typedef struct { 71 link_t *msg;71 link_t msg; 72 72 /** Domain name in text format (dot notation) */ 73 73 char *qname; -
uspace/srv/net/dnsres/dnsres.c
radae30d rf85ed4b 39 39 #include "dns_msg.h" 40 40 #include "dns_std.h" 41 #include "query.h" 41 42 42 43 #define NAME "dnsres" … … 44 45 int main(int argc, char *argv[]) 45 46 { 47 dns_host_info_t hinfo; 48 int rc; 49 46 50 printf("%s: DNS Resolution Service\n", NAME); 51 rc = dns_name2host("helenos.org", &hinfo); 52 printf("dns_name2host() -> rc = %d\n", rc); 53 47 54 return 0; 48 55 } -
uspace/srv/net/dnsres/query.c
radae30d rf85ed4b 39 39 #include "dns_type.h" 40 40 #include "query.h" 41 #include "transport.h" 41 42 42 43 static uint16_t msg_id; 43 44 44 int dns_name2host(c har *name, dns_host_info_t *info)45 int dns_name2host(const char *name, dns_host_info_t *info) 45 46 { 46 47 dns_message_t msg; 48 dns_message_t *amsg; 47 49 dns_question_t question; 50 int rc; 48 51 49 question.qname = name;52 question.qname = (char *)name; 50 53 question.qtype = DTYPE_A; 51 54 question.qclass = DC_IN; 52 55 53 56 list_initialize(&msg.question); 54 list_append( question.msg, &msg.question);57 list_append(&question.msg, &msg.question); 55 58 56 59 msg.id = msg_id++; … … 62 65 msg.ra = false; 63 66 67 rc = dns_request(&msg, &amsg); 68 if (rc != EOK) 69 return rc; 70 64 71 return EOK; 65 72 } -
uspace/srv/net/dnsres/query.h
radae30d rf85ed4b 39 39 #include "dns_type.h" 40 40 41 extern int dns_name2host(c har *, dns_host_info_t *);41 extern int dns_name2host(const char *, dns_host_info_t *); 42 42 43 43 #endif
Note:
See TracChangeset
for help on using the changeset viewer.