mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-09-30 19:47:43 +03:00
cStyleCasts
This commit is contained in:
@@ -209,8 +209,8 @@ struct FiveTuple {
|
||||
dstAddr = iphdr->ip_dst.s_addr;
|
||||
|
||||
// UDP/TCP ports
|
||||
const struct udphdr *uh = (const struct udphdr *)
|
||||
(((const char *)iphdr) + (iphdr->ip_hl * 4));
|
||||
const struct udphdr *uh = reinterpret_cast<const struct udphdr *>
|
||||
((reinterpret_cast<const char *>(iphdr)) + (iphdr->ip_hl * 4));
|
||||
srcPort = uh->uh_sport;
|
||||
dstPort = uh->uh_dport;
|
||||
}
|
||||
@@ -239,7 +239,7 @@ static
|
||||
int onMatch(unsigned int id, unsigned long long from, unsigned long long to,
|
||||
unsigned int flags, void *ctx) {
|
||||
// Our context points to a size_t storing the match count
|
||||
size_t *matches = (size_t *)ctx;
|
||||
size_t *matches = static_cast<size_t *>(ctx);
|
||||
(*matches)++;
|
||||
return 0; // continue matching
|
||||
}
|
||||
@@ -340,9 +340,9 @@ public:
|
||||
}
|
||||
|
||||
// Valid TCP or UDP packet
|
||||
const struct ip *iphdr = (const struct ip *)(pktData
|
||||
const struct ip *iphdr = reinterpret_cast<const struct ip *>(pktData
|
||||
+ sizeof(struct ether_header));
|
||||
const char *payload = (const char *)pktData + offset;
|
||||
const char *payload = reinterpret_cast<const char *>(pktData) + offset;
|
||||
|
||||
size_t id = stream_map.insert(std::make_pair(FiveTuple(iphdr),
|
||||
stream_map.size())).first->second;
|
||||
@@ -798,7 +798,7 @@ int main(int argc, char **argv) {
|
||||
static
|
||||
bool payloadOffset(const unsigned char *pkt_data, unsigned int *offset,
|
||||
unsigned int *length) {
|
||||
const ip *iph = (const ip *)(pkt_data + sizeof(ether_header));
|
||||
const ip *iph = reinterpret_cast<const ip *>(pkt_data + sizeof(ether_header));
|
||||
const tcphdr *th = nullptr;
|
||||
|
||||
// Ignore packets that aren't IPv4
|
||||
@@ -817,7 +817,7 @@ bool payloadOffset(const unsigned char *pkt_data, unsigned int *offset,
|
||||
|
||||
switch (iph->ip_p) {
|
||||
case IPPROTO_TCP:
|
||||
th = (const tcphdr *)((const char *)iph + ihlen);
|
||||
th = reinterpret_cast<const tcphdr *>(reinterpret_cast<const char *>(iph) + ihlen);
|
||||
thlen = th->th_off * 4;
|
||||
break;
|
||||
case IPPROTO_UDP:
|
||||
|
Reference in New Issue
Block a user