! \brief parses the srv record into a srv_rdata structure * \param msg - pointer to the dns message * \param end - pointer to the end of the message * \param rdata - pointer to the rdata part of the srv answer * \return 0 on error, or a dyn. alloc'ed srv_rdata structure * * SRV rdata format: * 111111 * 0123456789012345 * +----------------+ * | priority | *
| 808 | * +----------------+ |
| 809 | */ |
| 810 | struct srv_rdata* dns_srv_parser( unsigned char* msg, unsigned char* end, |
| 811 | unsigned char* rdata) |
| 812 | { |
| 813 | struct srv_rdata* srv; |
| 814 | int len; |
| 815 | |
| 816 | srv=0; |
| 817 | if ((rdata+6)>=end) goto error; |
| 818 | srv=(struct srv_rdata*)local_malloc(sizeof(struct srv_rdata)); |
| 819 | if (srv==0){ |
| 820 | LM_ERR("out of pkg memory\n"); |
| 821 | goto error; |
| 822 | } |
| 823 | |
| 824 | memcpy((void*)&srv->priority, rdata, 2); |
| 825 | memcpy((void*)&srv->weight, rdata+2, 2); |
| 826 | memcpy((void*)&srv->port, rdata+4, 2); |
| 827 | rdata+=6; |
| 828 | srv->priority=ntohs(srv->priority); |
| 829 | srv->weight=ntohs(srv->weight); |
| 830 | srv->port=ntohs(srv->port); |
| 831 | if ((len=dn_expand(msg, end, rdata, srv->name, MAX_DNS_NAME-1))==-1) |
| 832 | goto error; |
| 833 | /* add terminating 0 ? (warning: len=compressed name len) */ |
| 834 | srv->name_len=strlen(srv->name); |
| 835 | return srv; |
| 836 | error: |
| 837 | if (srv) local_free(srv); |
| 838 | return 0; |
| 839 | } |
| 840 | |
| 841 | |
| 842 | /*! \brief parses the naptr record into a naptr_rdata structure |