1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-08 05:31:31 +00:00

Constify data arguments in packet building and sending functions.

This commit is contained in:
david
2012-10-06 21:26:29 +00:00
parent 07f9b440f4
commit bc0c6d17b4
2 changed files with 27 additions and 27 deletions

View File

@@ -658,7 +658,7 @@ u8 *build_ip_raw(const struct in_addr *source,
u8 *build_ipv6_raw(const struct in6_addr *source, u8 *build_ipv6_raw(const struct in6_addr *source,
const struct in6_addr *victim, u8 tc, u32 flowlabel, const struct in6_addr *victim, u8 tc, u32 flowlabel,
u8 nextheader, int hoplimit, u8 nextheader, int hoplimit,
char *data, u16 datalen, u32 *outpacketlen) { const char *data, u16 datalen, u32 *outpacketlen) {
u8 *packet; u8 *packet;
assert(source != NULL); assert(source != NULL);
@@ -682,7 +682,7 @@ u8 *build_ipv6_raw(const struct in6_addr *source,
static u8 *build_tcp(u16 sport, u16 dport, u32 seq, u32 ack, u8 reserved, static u8 *build_tcp(u16 sport, u16 dport, u32 seq, u32 ack, u8 reserved,
u8 flags, u16 window, u16 urp, u8 flags, u16 window, u16 urp,
const u8 *tcpopt, int tcpoptlen, const u8 *tcpopt, int tcpoptlen,
char *data, u16 datalen, u32 *packetlen) { const char *data, u16 datalen, u32 *packetlen) {
struct tcp_hdr *tcp; struct tcp_hdr *tcp;
u8 *packet; u8 *packet;
@@ -741,7 +741,7 @@ u8 *build_tcp_raw(const struct in_addr *source,
const struct in_addr *victim, int ttl, u16 ipid, u8 tos, const struct in_addr *victim, int ttl, u16 ipid, u8 tos,
bool df, const u8 *ipopt, int ipoptlen, u16 sport, u16 dport, bool df, const u8 *ipopt, int ipoptlen, u16 sport, u16 dport,
u32 seq, u32 ack, u8 reserved, u8 flags, u16 window, u32 seq, u32 ack, u8 reserved, u8 flags, u16 window,
u16 urp, const u8 *tcpopt, int tcpoptlen, char *data, u16 urp, const u8 *tcpopt, int tcpoptlen, const char *data,
u16 datalen, u32 *packetlen) { u16 datalen, u32 *packetlen) {
struct tcp_hdr *tcp; struct tcp_hdr *tcp;
u32 tcplen; u32 tcplen;
@@ -767,7 +767,7 @@ u8 *build_tcp_raw_ipv6(const struct in6_addr *source,
const struct in6_addr *victim, u8 tc, u32 flowlabel, const struct in6_addr *victim, u8 tc, u32 flowlabel,
u8 hoplimit, u16 sport, u16 dport, u32 seq, u32 ack, u8 hoplimit, u16 sport, u16 dport, u32 seq, u32 ack,
u8 reserved, u8 flags, u16 window, u16 urp, u8 reserved, u8 flags, u16 window, u16 urp,
const u8 *tcpopt, int tcpoptlen, char *data, const u8 *tcpopt, int tcpoptlen, const char *data,
u16 datalen, u32 *packetlen) { u16 datalen, u32 *packetlen) {
struct tcp_hdr *tcp; struct tcp_hdr *tcp;
u32 tcplen; u32 tcplen;
@@ -789,7 +789,7 @@ int send_tcp_raw(int sd, const struct eth_nfo *eth,
const struct in_addr *victim, int ttl, bool df, const struct in_addr *victim, int ttl, bool df,
u8 *ipops, int ipoptlen, u16 sport, u16 dport, u32 seq, u8 *ipops, int ipoptlen, u16 sport, u16 dport, u32 seq,
u32 ack, u8 reserved, u8 flags, u16 window, u16 urp, u32 ack, u8 reserved, u8 flags, u16 window, u16 urp,
u8 *options, int optlen, char *data, u16 datalen) { u8 *options, int optlen, const char *data, u16 datalen) {
struct sockaddr_storage dst; struct sockaddr_storage dst;
struct sockaddr_in *dst_in; struct sockaddr_in *dst_in;
unsigned int packetlen; unsigned int packetlen;
@@ -821,7 +821,7 @@ int send_tcp_raw_decoys(int sd, const struct eth_nfo *eth,
u16 sport, u16 dport, u16 sport, u16 dport,
u32 seq, u32 ack, u8 reserved, u8 flags, u32 seq, u32 ack, u8 reserved, u8 flags,
u16 window, u16 urp, u8 *options, int optlen, u16 window, u16 urp, u8 *options, int optlen,
char *data, u16 datalen) { const char *data, u16 datalen) {
int decoy; int decoy;
for (decoy = 0; decoy < o.numdecoys; decoy++) for (decoy = 0; decoy < o.numdecoys; decoy++)
@@ -895,7 +895,7 @@ u8 *build_udp_raw(const struct in_addr *source, const struct in_addr *victim,
u8 *build_udp_raw_ipv6(const struct in6_addr *source, u8 *build_udp_raw_ipv6(const struct in6_addr *source,
const struct in6_addr *victim, u8 tc, u32 flowlabel, const struct in6_addr *victim, u8 tc, u32 flowlabel,
u8 hoplimit, u16 sport, u16 dport, u8 hoplimit, u16 sport, u16 dport,
char *data, u16 datalen, u32 *packetlen) { const char *data, u16 datalen, u32 *packetlen) {
struct udp_hdr *udp; struct udp_hdr *udp;
u32 udplen; u32 udplen;
u8 *ipv6; u8 *ipv6;
@@ -913,7 +913,7 @@ int send_udp_raw(int sd, const struct eth_nfo *eth,
struct in_addr *source, const struct in_addr *victim, struct in_addr *source, const struct in_addr *victim,
int ttl, u16 ipid, int ttl, u16 ipid,
u8 *ipopt, int ipoptlen, u8 *ipopt, int ipoptlen,
u16 sport, u16 dport, char *data, u16 datalen) { u16 sport, u16 dport, const char *data, u16 datalen) {
struct sockaddr_storage dst; struct sockaddr_storage dst;
struct sockaddr_in *dst_in; struct sockaddr_in *dst_in;
unsigned int packetlen; unsigned int packetlen;
@@ -939,7 +939,7 @@ int send_udp_raw_decoys(int sd, const struct eth_nfo *eth,
const struct in_addr *victim, const struct in_addr *victim,
int ttl, u16 ipid, int ttl, u16 ipid,
u8 *ipops, int ipoptlen, u8 *ipops, int ipoptlen,
u16 sport, u16 dport, char *data, u16 datalen) { u16 sport, u16 dport, const char *data, u16 datalen) {
int decoy; int decoy;
for (decoy = 0; decoy < o.numdecoys; decoy++) for (decoy = 0; decoy < o.numdecoys; decoy++)
@@ -999,7 +999,7 @@ u8 *build_sctp_raw(const struct in_addr *source,
const struct in_addr *victim, int ttl, u16 ipid, const struct in_addr *victim, int ttl, u16 ipid,
u8 tos, bool df, u8 *ipopt, int ipoptlen, u16 sport, u8 tos, bool df, u8 *ipopt, int ipoptlen, u16 sport,
u16 dport, u32 vtag, char *chunks, int chunkslen, u16 dport, u32 vtag, char *chunks, int chunkslen,
char *data, u16 datalen, u32 *packetlen) { const char *data, u16 datalen, u32 *packetlen) {
u8 *ip, *sctp; u8 *ip, *sctp;
u32 sctplen; u32 sctplen;
@@ -1014,7 +1014,7 @@ u8 *build_sctp_raw(const struct in_addr *source,
u8 *build_sctp_raw_ipv6(const struct in6_addr *source, u8 *build_sctp_raw_ipv6(const struct in6_addr *source,
const struct in6_addr *victim, u8 tc, u32 flowlabel, const struct in6_addr *victim, u8 tc, u32 flowlabel,
u8 hoplimit, u16 sport, u16 dport, u32 vtag, u8 hoplimit, u16 sport, u16 dport, u32 vtag,
char *chunks, int chunkslen, char *data, u16 datalen, char *chunks, int chunkslen, const char *data, u16 datalen,
u32 *packetlen) { u32 *packetlen) {
u8 *ipv6, *sctp; u8 *ipv6, *sctp;
u32 sctplen; u32 sctplen;
@@ -1038,7 +1038,7 @@ u8 *build_sctp_raw_ipv6(const struct in6_addr *source,
u8 *build_icmp_raw(const struct in_addr *source, u8 *build_icmp_raw(const struct in_addr *source,
const struct in_addr *victim, int ttl, u16 ipid, const struct in_addr *victim, int ttl, u16 ipid,
u8 tos, bool df, u8 *ipopt, int ipoptlen, u16 seq, u8 tos, bool df, u8 *ipopt, int ipoptlen, u16 seq,
unsigned short id, u8 ptype, u8 pcode, char *data, unsigned short id, u8 ptype, u8 pcode, const char *data,
u16 datalen, u32 *packetlen) { u16 datalen, u32 *packetlen) {
struct ppkt { struct ppkt {
u8 type; u8 type;
@@ -1105,7 +1105,7 @@ u8 *build_icmp_raw(const struct in_addr *source,
u8 *build_icmpv6_raw(const struct in6_addr *source, u8 *build_icmpv6_raw(const struct in6_addr *source,
const struct in6_addr *victim, u8 tc, u32 flowlabel, const struct in6_addr *victim, u8 tc, u32 flowlabel,
u8 hoplimit, u16 seq, u16 id, u8 ptype, u8 pcode, u8 hoplimit, u16 seq, u16 id, u8 ptype, u8 pcode,
char *data, u16 datalen, u32 *packetlen) { const char *data, u16 datalen, u32 *packetlen) {
char *packet; char *packet;
struct icmpv6_hdr *icmpv6; struct icmpv6_hdr *icmpv6;
union icmpv6_msg *msg; union icmpv6_msg *msg;
@@ -1152,7 +1152,7 @@ u8 *build_icmpv6_raw(const struct in6_addr *source,
u8 *build_igmp_raw(const struct in_addr *source, u8 *build_igmp_raw(const struct in_addr *source,
const struct in_addr *victim, int ttl, u16 ipid, const struct in_addr *victim, int ttl, u16 ipid,
u8 tos, bool df, u8 *ipopt, int ipoptlen, u8 ptype, u8 tos, bool df, u8 *ipopt, int ipoptlen, u8 ptype,
u8 pcode, char *data, u16 datalen, u32 *packetlen) { u8 pcode, const char *data, u16 datalen, u32 *packetlen) {
struct { struct {
u8 igmp_type; u8 igmp_type;
u8 igmp_code; u8 igmp_code;

26
tcpip.h
View File

@@ -299,7 +299,7 @@ u8 *build_ip_raw(const struct in_addr *source, const struct in_addr *victim,
u8 *build_ipv6_raw(const struct in6_addr *source, u8 *build_ipv6_raw(const struct in6_addr *source,
const struct in6_addr *victim, u8 tc, u32 flowlabel, const struct in6_addr *victim, u8 tc, u32 flowlabel,
u8 nextheader, int hoplimit, u8 nextheader, int hoplimit,
char *data, u16 datalen, u32 *outpacketlen); const char *data, u16 datalen, u32 *outpacketlen);
/* Builds a TCP packet (including an IP header) by packing the fields /* Builds a TCP packet (including an IP header) by packing the fields
with the given information. It allocates a new buffer to store the with the given information. It allocates a new buffer to store the
@@ -313,14 +313,14 @@ u8 *build_tcp_raw(const struct in_addr *source, const struct in_addr *victim,
u16 sport, u16 dport, u16 sport, u16 dport,
u32 seq, u32 ack, u8 reserved, u8 flags, u16 window, u16 urp, u32 seq, u32 ack, u8 reserved, u8 flags, u16 window, u16 urp,
const u8 *options, int optlen, const u8 *options, int optlen,
char *data, u16 datalen, const char *data, u16 datalen,
u32 *packetlen); u32 *packetlen);
u8 *build_tcp_raw_ipv6(const struct in6_addr *source, u8 *build_tcp_raw_ipv6(const struct in6_addr *source,
const struct in6_addr *victim, u8 tc, u32 flowlabel, const struct in6_addr *victim, u8 tc, u32 flowlabel,
u8 hoplimit, u16 sport, u16 dport, u32 seq, u32 ack, u8 hoplimit, u16 sport, u16 dport, u32 seq, u32 ack,
u8 reserved, u8 flags, u16 window, u16 urp, u8 reserved, u8 flags, u16 window, u16 urp,
const u8 *tcpopt, int tcpoptlen, char *data, const u8 *tcpopt, int tcpoptlen, const char *data,
u16 datalen, u32 *packetlen); u16 datalen, u32 *packetlen);
/* Build and send a raw tcp packet. If TTL is -1, a partially random /* Build and send a raw tcp packet. If TTL is -1, a partially random
@@ -332,7 +332,7 @@ int send_tcp_raw( int sd, const struct eth_nfo *eth,
u16 sport, u16 dport, u16 sport, u16 dport,
u32 seq, u32 ack, u8 reserved, u8 flags, u16 window, u16 urp, u32 seq, u32 ack, u8 reserved, u8 flags, u16 window, u16 urp,
u8 *options, int optlen, u8 *options, int optlen,
char *data, u16 datalen); const char *data, u16 datalen);
int send_tcp_raw_decoys( int sd, const struct eth_nfo *eth, int send_tcp_raw_decoys( int sd, const struct eth_nfo *eth,
const struct in_addr *victim, const struct in_addr *victim,
@@ -341,7 +341,7 @@ int send_tcp_raw_decoys( int sd, const struct eth_nfo *eth,
u16 sport, u16 dport, u16 sport, u16 dport,
u32 seq, u32 ack, u8 reserved, u8 flags, u16 window, u16 urp, u32 seq, u32 ack, u8 reserved, u8 flags, u16 window, u16 urp,
u8 *options, int optlen, u8 *options, int optlen,
char *data, u16 datalen); const char *data, u16 datalen);
/* Builds a UDP packet (including an IP header) by packing the fields /* Builds a UDP packet (including an IP header) by packing the fields
with the given information. It allocates a new buffer to store the with the given information. It allocates a new buffer to store the
@@ -359,21 +359,21 @@ u8 *build_udp_raw(const struct in_addr *source, const struct in_addr *victim,
u8 *build_udp_raw_ipv6(const struct in6_addr *source, u8 *build_udp_raw_ipv6(const struct in6_addr *source,
const struct in6_addr *victim, u8 tc, u32 flowlabel, const struct in6_addr *victim, u8 tc, u32 flowlabel,
u8 hoplimit, u16 sport, u16 dport, u8 hoplimit, u16 sport, u16 dport,
char *data, u16 datalen, u32 *packetlen); const char *data, u16 datalen, u32 *packetlen);
int send_udp_raw( int sd, const struct eth_nfo *eth, int send_udp_raw( int sd, const struct eth_nfo *eth,
struct in_addr *source, const struct in_addr *victim, struct in_addr *source, const struct in_addr *victim,
int ttl, u16 ipid, int ttl, u16 ipid,
u8* ipopt, int ipoptlen, u8* ipopt, int ipoptlen,
u16 sport, u16 dport, u16 sport, u16 dport,
char *data, u16 datalen); const char *data, u16 datalen);
int send_udp_raw_decoys( int sd, const struct eth_nfo *eth, int send_udp_raw_decoys( int sd, const struct eth_nfo *eth,
const struct in_addr *victim, const struct in_addr *victim,
int ttl, u16 ipid, int ttl, u16 ipid,
u8* ipops, int ip, u8* ipops, int ip,
u16 sport, u16 dport, u16 sport, u16 dport,
char *data, u16 datalen); const char *data, u16 datalen);
/* Builds an SCTP packet (including an IP header) by packing the fields /* Builds an SCTP packet (including an IP header) by packing the fields
with the given information. It allocates a new buffer to store the with the given information. It allocates a new buffer to store the
@@ -386,13 +386,13 @@ u8 *build_sctp_raw(const struct in_addr *source, const struct in_addr *victim,
u8* ipopt, int ipoptlen, u8* ipopt, int ipoptlen,
u16 sport, u16 dport, u16 sport, u16 dport,
u32 vtag, char *chunks, int chunkslen, u32 vtag, char *chunks, int chunkslen,
char *data, u16 datalen, const char *data, u16 datalen,
u32 *packetlen); u32 *packetlen);
u8 *build_sctp_raw_ipv6(const struct in6_addr *source, u8 *build_sctp_raw_ipv6(const struct in6_addr *source,
const struct in6_addr *victim, u8 tc, u32 flowlabel, const struct in6_addr *victim, u8 tc, u32 flowlabel,
u8 hoplimit, u16 sport, u16 dport, u32 vtag, u8 hoplimit, u16 sport, u16 dport, u32 vtag,
char *chunks, int chunkslen, char *data, u16 datalen, char *chunks, int chunkslen, const char *data, u16 datalen,
u32 *packetlen); u32 *packetlen);
/* Builds an ICMP packet (including an IP header) by packing the /* Builds an ICMP packet (including an IP header) by packing the
@@ -407,12 +407,12 @@ u8 *build_icmp_raw(const struct in_addr *source, const struct in_addr *victim,
int ttl, u16 ipid, u8 tos, bool df, int ttl, u16 ipid, u8 tos, bool df,
u8* ipopt, int ipoptlen, u8* ipopt, int ipoptlen,
u16 seq, unsigned short id, u8 ptype, u8 pcode, u16 seq, unsigned short id, u8 ptype, u8 pcode,
char *data, u16 datalen, u32 *packetlen); const char *data, u16 datalen, u32 *packetlen);
u8 *build_icmpv6_raw(const struct in6_addr *source, u8 *build_icmpv6_raw(const struct in6_addr *source,
const struct in6_addr *victim, u8 tc, u32 flowlabel, const struct in6_addr *victim, u8 tc, u32 flowlabel,
u8 hoplimit, u16 seq, u16 id, u8 ptype, u8 pcode, u8 hoplimit, u16 seq, u16 id, u8 ptype, u8 pcode,
char *data, u16 datalen, u32 *packetlen); const char *data, u16 datalen, u32 *packetlen);
/* Builds an IGMP packet (including an IP header) by packing the fields /* Builds an IGMP packet (including an IP header) by packing the fields
with the given information. It allocates a new buffer to store the with the given information. It allocates a new buffer to store the
@@ -425,7 +425,7 @@ u8 *build_igmp_raw(const struct in_addr *source, const struct in_addr *victim,
int ttl, u16 ipid, u8 tos, bool df, int ttl, u16 ipid, u8 tos, bool df,
u8* ipopt, int ipoptlen, u8* ipopt, int ipoptlen,
u8 ptype, u8 pcode, u8 ptype, u8 pcode,
char *data, u16 datalen, u32 *packetlen); const char *data, u16 datalen, u32 *packetlen);
// Returns whether the packet receive time value obtaned from libpcap // Returns whether the packet receive time value obtaned from libpcap