adding data to udp probe module

This commit is contained in:
Zakir Durumeric 2013-09-02 17:06:47 -04:00
parent 51da87c605
commit 8c8049dd66

View File

@ -204,6 +204,7 @@ void udp_process_packet(const u_char *packet, UNUSED uint32_t len, fieldset_t *f
fs_add_uint64(fs, "dport", ntohs(udp->dest)); fs_add_uint64(fs, "dport", ntohs(udp->dest));
fs_add_null(fs, "icmp_type"); fs_add_null(fs, "icmp_type");
fs_add_null(fs, "icmp_code"); fs_add_null(fs, "icmp_code");
fs_add_binary(fs, "data", (ntohs(udp->len) - sizeof(struct udphdr)), (void*) &udp[1], 0);
} else if (ip_hdr->protocol == IPPROTO_ICMP) { } else if (ip_hdr->protocol == IPPROTO_ICMP) {
struct icmphdr *icmp = (struct icmphdr *)((char *)ip_hdr + ip_hdr->ihl * 4); struct icmphdr *icmp = (struct icmphdr *)((char *)ip_hdr + ip_hdr->ihl * 4);
fs_add_string(fs, "classification", (char*) "icmp-unreach", 0); fs_add_string(fs, "classification", (char*) "icmp-unreach", 0);
@ -212,6 +213,7 @@ void udp_process_packet(const u_char *packet, UNUSED uint32_t len, fieldset_t *f
fs_add_null(fs, "dport"); fs_add_null(fs, "dport");
fs_add_uint64(fs, "icmp_type", icmp->type); fs_add_uint64(fs, "icmp_type", icmp->type);
fs_add_uint64(fs, "icmp_code", icmp->code); fs_add_uint64(fs, "icmp_code", icmp->code);
fs_add_null(fs, "data");
} else { } else {
fs_add_string(fs, "classification", (char*) "other", 0); fs_add_string(fs, "classification", (char*) "other", 0);
fs_add_uint64(fs, "success", 0); fs_add_uint64(fs, "success", 0);
@ -219,6 +221,7 @@ void udp_process_packet(const u_char *packet, UNUSED uint32_t len, fieldset_t *f
fs_add_null(fs, "dport"); fs_add_null(fs, "dport");
fs_add_null(fs, "icmp_type"); fs_add_null(fs, "icmp_type");
fs_add_null(fs, "icmp_code"); fs_add_null(fs, "icmp_code");
fs_add_null(fs, "data");
} }
} }
@ -278,8 +281,8 @@ static fielddef_t fields[] = {
{.name = "sport", .type = "int", .desc = "UDP source port"}, {.name = "sport", .type = "int", .desc = "UDP source port"},
{.name = "dport", .type = "int", .desc = "UDP destination port"}, {.name = "dport", .type = "int", .desc = "UDP destination port"},
{.name = "icmp_type", .type = "int", .desc = "icmp message type"}, {.name = "icmp_type", .type = "int", .desc = "icmp message type"},
{.name = "icmp_code", .type = "int", .desc = "icmp message sub type code"}//, {.name = "icmp_code", .type = "int", .desc = "icmp message sub type code"},
//{.name = "data", .type="binary", .desc = "UDP payload"} {.name = "data", .type="binary", .desc = "UDP payload"}
}; };
probe_module_t module_udp = { probe_module_t module_udp = {