/* * netsniff-ng - the packet sniffing beast * Subject to the GPL, version 2. */ #include #include "die.h" #include "csum.h" #include "built_in.h" #include "trafgen_l2.h" #include "trafgen_l3.h" #include "trafgen_proto.h" #include "trafgen_conf.h" static struct proto_field ipv4_fields[] = { { .id = IP4_VER, .len = 1, .offset = 0, .shift = 4, .mask = 0xf0 }, { .id = IP4_IHL, .len = 1, .offset = 0, .shift = 0, .mask = 0x0f }, { .id = IP4_DSCP, .len = 1, .offset = 1, .shift = 2, .mask = 0xfc }, { .id = IP4_ECN, .len = 1, .offset = 1, .shift = 0, .mask = 0x03 }, { .id = IP4_TOS, .len = 1, .offset = 1 }, { .id = IP4_LEN, .len = 2, .offset = 2 }, { .id = IP4_ID, .len = 2, .offset = 4 }, { .id = IP4_FLAGS, .len = 2, .offset = 6, .shift = 13, .mask = 0xe000 }, { .id = IP4_MF, .len = 2, .offset = 6, .shift = 13, .mask = 0x2000 }, { .id = IP4_DF, .len = 2, .offset = 6, .shift = 14, .mask = 0x4000 }, { .id = IP4_FRAG_OFFS, .len = 2, .offset = 6, .shift = 0, .mask = 0x1fff }, { .id = IP4_TTL, .len = 1, .offset = 8 }, { .id = IP4_PROTO, .len = 1, .offset = 9 }, { .id = IP4_CSUM, .len = 2, .offset = 10 }, { .id = IP4_SADDR, .len = 4, .offset = 12 }, { .id = IP4_DADDR, .len = 4, .offset = 16 }, }; static void ipv4_header_init(struct proto_hdr *hdr) { proto_lower_default_add(hdr, PROTO_ETH); proto_header_fields_add(hdr, ipv4_fields, array_size(ipv4_fields)); proto_field_set_default_u8(hdr, IP4_VER, 4); proto_field_set_default_u8(hdr, IP4_IHL, 5); proto_field_set_default_dev_ipv4(hdr, IP4_SADDR); } static void ipv4_packet_finish(struct proto_hdr *hdr) { struct packet *pkt = current_packet(); uint16_t total_len; total_len = pkt->len - hdr->pkt_offset; proto_field_set_default_be16(hdr, IP4_LEN, total_len); if (!proto_field_is_set(hdr, IP4_CSUM)) { uint16_t csum; csum = htons(calc_csum(&pkt->payload[hdr->pkt_offset], hdr->len)); proto_field_set_u16(hdr, IP4_CSUM, bswap_16(csum)); } } static void ipv4_set_next_proto(struct proto_hdr *hdr, enum proto_id pid) { uint8_t ip_proto; switch(pid) { case PROTO_IP4: ip_proto = IPPROTO_IPIP; break; case PROTO_IP6: ip_proto = IPPROTO_IPV6; break; case PROTO_ICMP4: ip_proto = IPPROTO_ICMP; break; case PROTO_UDP: ip_proto = IPPROTO_UDP; break; case PROTO_TCP: ip_proto = IPPROTO_TCP; break; default: bug(); } proto_field_set_default_u8(hdr, IP4_PROTO, ip_proto); } static struct proto_hdr ipv4_hdr = { .id = PROTO_IP4, .layer = PROTO_L3, .header_init = ipv4_header_init, .packet_finish = ipv4_packet_finish, .set_next_proto = ipv4_set_next_proto, }; static struct proto_field ipv6_fields[] = { { .id = IP6_VER, .len = 4, .offset = 0, .shift = 28, .mask = 0xf0000000 }, { .id = IP6_CLASS, .len = 4, .offset = 0, .shift = 20, .mask = 0x0ff00000 }, { .id = IP6_FLOW_LBL, .len = 4, .offset = 0, .shift = 0, .mask = 0x000fffff }, { .id = IP6_LEN, .len = 2, .offset = 4 }, { .id = IP6_NEXT_HDR, .len = 1, .offset = 6 }, { .id = IP6_HOP_LIMIT, .len = 1, .offset = 7 }, { .id = IP6_SADDR, .len = 16, .offset = 8 }, { .id = IP6_DADDR, .len = 16, .offset = 24 }, }; static void ipv6_header_init(struct proto_hdr *hdr) { proto_lower_default_add(hdr, PROTO_ETH); proto_header_fields_add(hdr, ipv6_fields, array_size(ipv6_fields)); proto_field_set_default_be32(hdr, IP6_VER, 6); proto_field_set_default_dev_ipv6(hdr, IP6_SADDR); } #define IPV6_HDR_LEN 40 static void ipv6_packet_finish(struct proto_hdr *hdr) { struct packet *pkt = current_packet(); uint16_t total_len = pkt->len - hdr->pkt_offset - IPV6_HDR_LEN; proto_field_set_default_be16(hdr, IP6_LEN, total_len); } static void ipv6_set_next_proto(struct proto_hdr *hdr, enum proto_id pid) { uint8_t ip_proto; switch(pid) { case PROTO_ICMP6: ip_proto = IPPROTO_ICMPV6; break; case PROTO_UDP: ip_proto = IPPROTO_UDP; break; case PROTO_TCP: ip_proto = IPPROTO_TCP; break; default: bug(); } proto_field_set_default_u8(hdr, IP6_NEXT_HDR, ip_proto); } static struct proto_hdr ipv6_hdr = { .id = PROTO_IP6, .layer = PROTO_L3, .header_init = ipv6_header_init, .packet_finish = ipv6_packet_finish, .set_next_proto = ipv6_set_next_proto, }; void protos_l3_init(void) { proto_header_register(&ipv4_hdr); proto_header_register(&ipv6_hdr); } ption value='0' selected='selected'>unified
authorLinus Torvalds <torvalds@linux-foundation.org>2016-12-12 21:58:13 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2016-12-12 21:58:13 -0800
commite7aa8c2eb11ba69b1b69099c3c7bd6be3087b0ba (patch)
treef63906f41699c8e38af9d12b063e2ceab0286ef2 /Documentation/memory-devices/ti-emif.txt
parente34bac726d27056081d0250c0e173e4b155aa340 (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 'Documentation/memory-devices/ti-emif.txt')