From 0cf05856d096a019fd035b63a28ba7ff3c581ff7 Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Thu, 3 Feb 2011 20:05:40 +0100 Subject: [PATCH] Fix Packet usage. This patch suppresses remaining direct access to pkt and pktlen in the Packet structure. --- src/alert-syslog.c | 2 +- src/alert-unified2-alert.c | 10 +++++----- src/decode-raw.c | 6 +++--- src/decode-tcp.h | 4 ++-- src/detect-tag.c | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/alert-syslog.c b/src/alert-syslog.c index 5c5e5119d5..bbe167c80a 100644 --- a/src/alert-syslog.c +++ b/src/alert-syslog.c @@ -370,7 +370,7 @@ TmEcode AlertSyslogDecoderEvent(ThreadVars *tv, Packet *p, void *data, pa->class_msg, pa->prio); strlcpy(alert, temp_buf_hdr, sizeof(alert)); - PrintRawLineHexBuf(temp_buf_pkt, sizeof(temp_buf_pkt), p->pkt, p->pktlen < 32 ? p->pktlen : 32); + PrintRawLineHexBuf(temp_buf_pkt, sizeof(temp_buf_pkt), GET_PKT_DATA(p), GET_PKT_LEN(p) < 32 ? GET_PKT_LEN(p) : 32); strlcat(alert, temp_buf_pkt, sizeof(alert)); if (p->pcap_cnt != 0) { diff --git a/src/alert-unified2-alert.c b/src/alert-unified2-alert.c index 2d97f2e945..5fff3594b1 100644 --- a/src/alert-unified2-alert.c +++ b/src/alert-unified2-alert.c @@ -783,7 +783,7 @@ static int Unified2Test01 (void) { p->alerts.alerts[p->alerts.cnt-1].sid = 1; p->alerts.alerts[p->alerts.cnt-1].gid = 1; p->alerts.alerts[p->alerts.cnt-1].rev = 1; - p->pktlen = sizeof(raw_ipv4_tcp); + SET_PKT_LEN(p, sizeof(raw_ipv4_tcp)); FlowInitConfig(FLOW_QUIET); @@ -866,7 +866,7 @@ static int Unified2Test02 (void) { p->alerts.alerts[p->alerts.cnt-1].sid = 1; p->alerts.alerts[p->alerts.cnt-1].gid = 1; p->alerts.alerts[p->alerts.cnt-1].rev = 1; - p->pktlen = sizeof(raw_ipv6_tcp); + SET_PKT_LEN(p, sizeof(raw_ipv6_tcp)); FlowInitConfig(FLOW_QUIET); @@ -955,7 +955,7 @@ static int Unified2Test03 (void) { p->alerts.alerts[p->alerts.cnt-1].sid = 1; p->alerts.alerts[p->alerts.cnt-1].gid = 1; p->alerts.alerts[p->alerts.cnt-1].rev = 1; - p->pktlen = sizeof(raw_gre); + SET_PKT_LEN(p, sizeof(raw_gre)); FlowInitConfig(FLOW_QUIET); @@ -1038,7 +1038,7 @@ static int Unified2Test04 (void) { p->alerts.alerts[p->alerts.cnt-1].sid = 1; p->alerts.alerts[p->alerts.cnt-1].gid = 1; p->alerts.alerts[p->alerts.cnt-1].rev = 1; - p->pktlen = sizeof(raw_ppp); + SET_PKT_LEN(p, sizeof(raw_ppp)); FlowInitConfig(FLOW_QUIET); @@ -1119,7 +1119,7 @@ static int Unified2Test05 (void) { p->alerts.alerts[p->alerts.cnt-1].sid = 1; p->alerts.alerts[p->alerts.cnt-1].gid = 1; p->alerts.alerts[p->alerts.cnt-1].rev = 1; - p->pktlen = sizeof(raw_ipv4_tcp); + SET_PKT_LEN(p, sizeof(raw_ipv4_tcp)); FlowInitConfig(FLOW_QUIET); diff --git a/src/decode-raw.c b/src/decode-raw.c index 7ae682bb10..ccd4103c4c 100644 --- a/src/decode-raw.c +++ b/src/decode-raw.c @@ -94,7 +94,7 @@ static int DecodeRawTest01 (void) { FlowInitConfig(FLOW_QUIET); - DecodeRaw(&tv, &dtv, p, raw_ip, p->pktlen, NULL); + DecodeRaw(&tv, &dtv, p, raw_ip, GET_PKT_LEN(p), NULL); if (p->ip6h == NULL) { printf("expected a valid ipv6 header but it was NULL: "); FlowShutdown(); @@ -140,7 +140,7 @@ static int DecodeRawTest02 (void) { FlowInitConfig(FLOW_QUIET); - DecodeRaw(&tv, &dtv, p, raw_ip, p->pktlen, NULL); + DecodeRaw(&tv, &dtv, p, raw_ip, GET_PKT_LEN(p), NULL); FlowShutdown(); if (p->ip4h == NULL) { printf("expected a valid ipv4 header but it was NULL: "); @@ -186,7 +186,7 @@ static int DecodeRawTest03 (void) { FlowInitConfig(FLOW_QUIET); - DecodeRaw(&tv, &dtv, p, raw_ip, p->pktlen, NULL); + DecodeRaw(&tv, &dtv, p, raw_ip, GET_PKT_LEN(p), NULL); if (DECODER_ISSET_EVENT(p,IPRAW_INVALID_IPV)) { FlowShutdown(); SCFree(p); diff --git a/src/decode-tcp.h b/src/decode-tcp.h index c0b370d1b0..6cbe7ca79c 100644 --- a/src/decode-tcp.h +++ b/src/decode-tcp.h @@ -172,9 +172,9 @@ static inline uint16_t TCPV6CalculateChecksum(uint16_t *, uint16_t *, uint16_t); * \brief Calculates the checksum for the TCP packet * * \param shdr Pointer to source address field from the IP packet. Used as a - * part of the psuedoheader for computing the checksum + * part of the pseudoheader for computing the checksum * \param pkt Pointer to the start of the TCP packet - * \param hlen Total length of the TCP packet(header + payload) + * \param tlen Total length of the TCP packet(header + payload) * * \retval csum Checksum for the TCP packet */ diff --git a/src/detect-tag.c b/src/detect-tag.c index 9aaefce860..9d3cfb5d5f 100644 --- a/src/detect-tag.c +++ b/src/detect-tag.c @@ -744,7 +744,7 @@ int DetectTagTestPacket03 (void) { int i = 0; for (; i < num_packets; i++) { SigMatchSignatures(&th_v, de_ctx, det_ctx, p[i]); - sum += p[i]->pktlen; + sum += GET_PKT_LEN(p[i]); //printf("Sum %"PRIu32"\n", sum); if (UTHCheckPacketMatchResults(p[i], sid, (uint32_t *)&results[i][0], numsigs) == 0) goto cleanup; @@ -860,7 +860,7 @@ int DetectTagTestPacket04 (void) { p[i]->flow = &f; p[i]->flow->protoctx = &ssn; SigMatchSignatures(&th_v, de_ctx, det_ctx, p[i]); - sum += p[i]->pktlen; + sum += GET_PKT_LEN(p[i]); //printf("Sum %"PRIu32"\n", sum); if (UTHCheckPacketMatchResults(p[i], sid, (uint32_t *)&results[i][0], numsigs) == 0) goto cleanup;