const char *pname;
char label[64], *u;
-
/* Check whether we can compress this name. */
if (p->name_table && (prev = avahi_hashmap_lookup(p->name_table, name))) {
return d;
}
-int avahi_dns_packet_is_valid(AvahiDnsPacket *p) {
+int avahi_dns_packet_check_valid(AvahiDnsPacket *p) {
uint16_t flags;
assert(p);
- if (p->size < 12)
+ if (p->size < AVAHI_DNS_PACKET_HEADER_SIZE)
return -1;
flags = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_FLAGS);
+
+ if (flags & AVAHI_DNS_FLAG_OPCODE)
+ return -1;
+
+ return 0;
+}
- if (flags & AVAHI_DNS_FLAG_OPCODE || flags & AVAHI_DNS_FLAG_RCODE)
+int avahi_dns_packet_check_valid_multicast(AvahiDnsPacket *p) {
+ uint16_t flags;
+ assert(p);
+
+ if (avahi_dns_packet_check_valid(p) < 0)
+ return -1;
+
+ flags = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_FLAGS);
+
+ if (flags & AVAHI_DNS_FLAG_RCODE)
return -1;
return 0;
}
+
int avahi_dns_packet_is_query(AvahiDnsPacket *p) {
assert(p);
} else
first_label = 0;
- if (!(avahi_escape_label(AVAHI_DNS_PACKET_DATA(p) + idx, n, &ret_name, &l)))
+ if (!(avahi_escape_label((char*) AVAHI_DNS_PACKET_DATA(p) + idx, n, &ret_name, &l)))
return -1;
idx += n;
const void* start;
assert(p);
- assert(ret_cache_flush);
/* avahi_log_debug("consume_record()"); */
/* avahi_log_debug("name = %s, rdlength = %u", name, rdlength); */
- *ret_cache_flush = !!(class & AVAHI_DNS_CACHE_FLUSH);
+ if (ret_cache_flush)
+ *ret_cache_flush = !!(class & AVAHI_DNS_CACHE_FLUSH);
class &= ~AVAHI_DNS_CACHE_FLUSH;
start = avahi_dns_packet_get_rptr(p);
switch (type) {
case AVAHI_DNS_TYPE_PTR:
case AVAHI_DNS_TYPE_CNAME:
+ case AVAHI_DNS_TYPE_NS:
/* avahi_log_debug("ptr"); */
uint16_t type, class;
assert(p);
- assert(ret_unicast_response);
if (avahi_dns_packet_consume_name(p, name, sizeof(name)) < 0 ||
avahi_dns_packet_consume_uint16(p, &type) < 0 ||
avahi_dns_packet_consume_uint16(p, &class) < 0)
return NULL;
- *ret_unicast_response = !!(class & AVAHI_DNS_UNICAST_RESPONSE);
- class &= ~AVAHI_DNS_UNICAST_RESPONSE;
+ if (ret_unicast_response)
+ *ret_unicast_response = !!(class & AVAHI_DNS_UNICAST_RESPONSE);
+ class &= ~AVAHI_DNS_UNICAST_RESPONSE;
+
return avahi_key_new(name, class, type);
}
switch (r->key->type) {
case AVAHI_DNS_TYPE_PTR:
- case AVAHI_DNS_TYPE_CNAME :
-
+ case AVAHI_DNS_TYPE_CNAME:
+ case AVAHI_DNS_TYPE_NS:
+
if (!(avahi_dns_packet_append_name(p, r->data.ptr.name)))
goto fail;