/* * netsniff-ng - the packet sniffing beast * Subject to the GPL, version 2. */ #include #include "str.h" #include "xmalloc.h" #include "built_in.h" #include "trafgen_l7.h" #include "trafgen_proto.h" static struct proto_field dns_fields[] = { { .id = DNS_ID, .len = 2, .offset = 0 }, { .id = DNS_QR, .len = 2, .offset = 2, .shift = 15, .mask = 0x8000 }, { .id = DNS_OPCODE, .len = 2, .offset = 2, .shift = 11, .mask = 0x7800 }, { .id = DNS_AA, .len = 2, .offset = 2, .shift = 10, .mask = 0x0400 }, { .id = DNS_TC, .len = 2, .offset = 2, .shift = 9, .mask = 0x0200 }, { .id = DNS_RD, .len = 2, .offset = 2, .shift = 8, .mask = 0x0100 }, { .id = DNS_RA, .len = 2, .offset = 2, .shift = 7, .mask = 0x80 }, { .id = DNS_ZERO, .len = 2, .offset = 2, .shift = 4, .mask = 0x30 }, { .id = DNS_RCODE, .len = 2, .offset = 2, .shift = 0, .mask = 0xf }, { .id = DNS_QD_COUNT, .len = 2, .offset = 4, }, { .id = DNS_AN_COUNT, .len = 2, .offset = 6, }, { .id = DNS_NS_COUNT, .len = 2, .offset = 8, }, { .id = DNS_AR_COUNT, .len = 2, .offset = 10, }, }; static struct proto_field dns_query_fields[] = { { .id = DNS_QUERY_NAME, .len = 0, .offset = 0 }, { .id = DNS_QUERY_TYPE, .len = 2, .offset = 0 }, { .id = DNS_QUERY_CLASS, .len = 2, .offset = 2 }, }; static void dns_query_header_init(struct proto_hdr *hdr) { proto_header_fields_add(hdr, dns_query_fields, array_size(dns_query_fields)); } static void dns_query_header_finish(struct proto_hdr *hdr) { proto_hdr_field_set_default_string(hdr, DNS_QUERY_NAME, "www.netsniff-ng.com"); proto_hdr_field_set_default_be16(hdr, DNS_QUERY_CLASS, 1); proto_hdr_field_set_default_be16(hdr, DNS_QUERY_TYPE, 1); } static const struct proto_ops dns_proto_query_ops = { .header_init = dns_query_header_init, .header_finish = dns_query_header_finish, }; static struct proto_field dns_rrecord_fields[] = { { .id = DNS_RRECORD_NAME, .len = 0, .offset = 0 }, { .id = DNS_RRECORD_TYPE, .len = 2, .offset = 0 }, { .id = DNS_RRECORD_CLASS, .len = 2, .offset = 2 }, { .id = DNS_RRECORD_TTL, .len = 4, .offset = 4 }, { .id = DNS_RRECORD_LEN, .len = 2, .offset = 8 }, { .id = DNS_RRECORD_DATA, .len = 0, .offset = 10 }, }; static void dns_rrecord_header_init(struct proto_hdr *hdr) { proto_header_fields_add(hdr, dns_rrecord_fields, array_size(dns_rrecord_fields)); } static void dns_rrecord_header_finish(struct proto_hdr *hdr) { struct proto_field *data = proto_hdr_field_by_id(hdr, DNS_RRECORD_DATA); proto_hdr_field_set_default_be32(hdr, DNS_RRECORD_TTL, 1); proto_hdr_field_set_default_be16(hdr, DNS_RRECORD_CLASS, 1); proto_hdr_field_set_default_be16(hdr, DNS_RRECORD_LEN, data->len); } static const struct proto_ops dns_proto_rrecord_ops = { .header_init = dns_rrecord_header_init, .header_finish = dns_rrecord_header_finish, }; static void dns_header_init(struct proto_hdr *hdr) { proto_lower_default_add(hdr, PROTO_UDP); proto_header_fields_add(hdr, dns_fields, array_size(dns_fields)); } static void dns_sort_headers(struct proto_hdr *hdr, uint32_t id, int index) { int i; for (i = index; i < hdr->sub_headers_count; i++) { struct proto_hdr *sub_hdr = hdr->sub_headers[i]; if (sub_hdr->id == id && sub_hdr->index != index) { proto_hdr_move_sub_header(hdr, sub_hdr, hdr->sub_headers[index]); index++; } } } static void dns_header_finish(struct proto_hdr *hdr) { size_t ar_count = 0; size_t ns_count = 0; size_t qd_count = 0; size_t an_count = 0; int i; for (i = 0; i < hdr->sub_headers_count; i++) { struct proto_hdr *sub_hdr = hdr->sub_headers[i]; switch (sub_hdr->id) { case DNS_QUERY_HDR: qd_count++; break; case DNS_ANSWER_HDR: an_count++; break; case DNS_AUTH_HDR: ns_count++; break; case DNS_ADD_HDR: ar_count++; break; } } dns_sort_headers(hdr, DNS_QUERY_HDR, 0); dns_sort_headers(hdr, DNS_ANSWER_HDR, qd_count); dns_sort_headers(hdr, DNS_AUTH_HDR, qd_count + an_count); dns_sort_headers(hdr, DNS_ADD_HDR, qd_count + an_count + ns_count); proto_hdr_field_set_default_be16(hdr, DNS_QD_COUNT, qd_count); proto_hdr_field_set_default_be16(hdr, DNS_AN_COUNT, an_count); proto_hdr_field_set_default_be16(hdr, DNS_NS_COUNT, ns_count); proto_hdr_field_set_default_be16(hdr, DNS_AR_COUNT, ar_count); if (an_count) proto_hdr_field_set_default_be16(hdr, DNS_QR, 1); } static void dns_push_sub_header(struct proto_hdr *hdr, struct proto_hdr *sub_hdr) { switch (sub_hdr->id) { case DNS_QUERY_HDR: sub_hdr->ops = &dns_proto_query_ops; break; case DNS_ANSWER_HDR: case DNS_AUTH_HDR: case DNS_ADD_HDR: sub_hdr->ops = &dns_proto_rrecord_ops; break; default: bug(); } } static const struct proto_ops dns_proto_ops = { .id = PROTO_DNS, .layer = PROTO_L7, .header_init = dns_header_init, .header_finish = dns_header_finish, .push_sub_header = dns_push_sub_header, }; void protos_l7_init(void) { proto_ops_register(&dns_proto_ops); } pan='2' class='oid'>e34bac726d27056081d0250c0e173e4b155aa340 (diff)parent868c97a846a73e937d835b09b8c885a69df50ec8 (diff)
Merge tag 'docs-4.10' of git://git.lwn.net/linuxHEADmaster
Pull documentation update from Jonathan Corbet: "These are the documentation changes for 4.10. It's another busy cycle for the docs tree, as the sphinx conversion continues. Highlights include: - Further work on PDF output, which remains a bit of a pain but should be more solid now. - Five more DocBook template files converted to Sphinx. Only 27 to go... Lots of plain-text files have also been converted and integrated. - Images in binary formats have been replaced with more source-friendly versions. - Various bits of organizational work, including the renaming of various files discussed at the kernel summit. - New documentation for the device_link mechanism. ... and, of course, lots of typo fixes and small updates" * tag 'docs-4.10' of git://git.lwn.net/linux: (193 commits) dma-buf: Extract dma-buf.rst Update Documentation/00-INDEX docs: 00-INDEX: document directories/files with no docs docs: 00-INDEX: remove non-existing entries docs: 00-INDEX: add missing entries for documentation files/dirs docs: 00-INDEX: consolidate process/ and admin-guide/ description scripts: add a script to check if Documentation/00-INDEX is sane Docs: change sh -> awk in REPORTING-BUGS Documentation/core-api/device_link: Add initial documentation core-api: remove an unexpected unident ppc/idle: Add documentation for powersave=off Doc: Correct typo, "Introdution" => "Introduction" Documentation/atomic_ops.txt: convert to ReST markup Documentation/local_ops.txt: convert to ReST markup Documentation/assoc_array.txt: convert to ReST markup docs-rst: parse-headers.pl: cleanup the documentation docs-rst: fix media cleandocs target docs-rst: media/Makefile: reorganize the rules docs-rst: media: build SVG from graphviz files docs-rst: replace bayer.png by a SVG image ...
Diffstat (limited to 'arch/powerpc/kvm/e500_emulate.c')