/* * netsniff-ng - the packet sniffing beast * Copyright 2012 Markus Amend , Deutsche Flugsicherung GmbH * Subject to the GPL, version 2. * * IP Authentication Header described in RFC4302 */ #include #include #include /* for ntohs() */ #include "proto.h" #include "protos.h" #include "dissector_eth.h" #include "built_in.h" #include "pkt_buff.h" struct auth_hdr { uint8_t h_next_header; uint8_t h_payload_len; uint16_t h_reserved; uint32_t h_spi; uint32_t h_snf; } __packed; static void auth_hdr(struct pkt_buff *pkt) { ssize_t hdr_len; size_t i; struct auth_hdr *auth_ops; auth_ops = (struct auth_hdr *) pkt_pull(pkt, sizeof(*auth_ops)); if (auth_ops == NULL) return; hdr_len = (auth_ops->h_payload_len * 4) + 8; tprintf(" [ Authentication Header "); tprintf("NextHdr (%u), ", auth_ops->h_next_header); if (hdr_len > pkt_len(pkt) || hdr_len < 0){ tprintf("HdrLen (%u, %zd Bytes %s), ", auth_ops->h_payload_len, hdr_len, colorize_start_full(black, red) "invalid" colorize_end()); return; } tprintf("HdrLen (%u, %zd Bytes), ",auth_ops->h_payload_len, hdr_len); tprintf("Reserved (0x%x), ", ntohs(auth_ops->h_reserved)); /* TODO * Upgrade for Extended (64-bit) Sequence Number * http://tools.ietf.org/html/rfc4302#section-2.5.1 */ tprintf("SPI (0x%x), ", ntohl(auth_ops->h_spi)); tprintf("SNF (0x%x), ", ntohl(auth_ops->h_snf)); tprintf("ICV 0x"); for (i = sizeof(struct auth_hdr); i < hdr_len; i++) { uint8_t *data = pkt_pull(pkt, 1); if (data == NULL) { tprintf("%sinvalid%s", colorize_start_full(black, red), colorize_end()); break; } tprintf("%02x", *data); } tprintf(" ]\n"); pkt_set_proto(pkt, ð_lay3, auth_ops->h_next_header); } static void auth_hdr_less(struct pkt_buff *pkt) { ssize_t hdr_len; struct auth_hdr *auth_ops; auth_ops = (struct auth_hdr *) pkt_pull(pkt, sizeof(*auth_ops)); if (auth_ops == NULL) return; hdr_len = (auth_ops->h_payload_len * 4) + 8; if (hdr_len > pkt_len(pkt) || hdr_len < 0) return; tprintf(" AH"); pkt_pull(pkt, hdr_len - sizeof(*auth_ops)); pkt_set_proto(pkt, ð_lay3, auth_ops->h_next_header); } struct protocol ip_auth_ops = { .key = 0x33, .print_full = auth_hdr, .print_less = auth_hdr_less, }; option>
diff options
context:
space:
mode:
authorNicolas Iooss <nicolas.iooss_linux@m4x.org>2016-08-28 18:47:12 +0200
committerIlya Dryomov <idryomov@gmail.com>2016-09-05 14:30:35 +0200
commit0f5aa88a7bb28b73253fb42b3df8202142769f39 (patch)
treeb57ebe5ded4d28dd333881950dc29a9e5326e3aa
parentc6935931c1894ff857616ff8549b61236a19148f (diff)
ceph: do not modify fi->frag in need_reset_readdir()
Commit f3c4ebe65ea1 ("ceph: using hash value to compose dentry offset") modified "if (fpos_frag(new_pos) != fi->frag)" to "if (fi->frag |= fpos_frag(new_pos))" in need_reset_readdir(), thus replacing a comparison operator with an assignment one. This looks like a typo which is reported by clang when building the kernel with some warning flags: fs/ceph/dir.c:600:22: error: using the result of an assignment as a condition without parentheses [-Werror,-Wparentheses] } else if (fi->frag |= fpos_frag(new_pos)) { ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~ fs/ceph/dir.c:600:22: note: place parentheses around the assignment to silence this warning } else if (fi->frag |= fpos_frag(new_pos)) { ^ ( ) fs/ceph/dir.c:600:22: note: use '!=' to turn this compound assignment into an inequality comparison } else if (fi->frag |= fpos_frag(new_pos)) { ^~ != Fixes: f3c4ebe65ea1 ("ceph: using hash value to compose dentry offset") Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>