suricata
util-print.h
Go to the documentation of this file.
1 /* Copyright (C) 2007-2010 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 /**
19  * \file
20  *
21  * \author Victor Julien <victor@inliniac.net>
22  */
23 
24 #ifndef SURICATA_UTIL_PRINT_H
25 #define SURICATA_UTIL_PRINT_H
26 
27 #define PrintBufferData(buf, buf_offset_ptr, buf_size, ...) do { \
28  int cw = snprintf((buf) + *(buf_offset_ptr), \
29  (buf_size) - *(buf_offset_ptr), \
30  __VA_ARGS__); \
31  if (cw >= 0) { \
32  if ( (*(buf_offset_ptr) + cw) >= buf_size) { \
33  SCLogDebug("Truncating data write since it exceeded buffer " \
34  "limit of - %"PRIu32"\n", buf_size); \
35  *(buf_offset_ptr) = buf_size - 1; \
36  } else { \
37  *(buf_offset_ptr) += cw; \
38  } \
39  } \
40  } while (0)
41 
42 void PrintBufferRawLineHex(char *, int *,int, const uint8_t *, uint32_t);
43 void PrintRawUriFp(FILE *, uint8_t *, uint32_t);
44 void PrintRawUriBuf(char *, uint32_t *, uint32_t,
45  uint8_t *, uint32_t);
46 void PrintRawJsonFp(FILE *, uint8_t *, uint32_t);
47 void PrintRawDataFp(FILE *, const uint8_t *, uint32_t);
48 void PrintRawDataToBuffer(uint8_t *dst_buf, uint32_t *dst_buf_offset_ptr, uint32_t dst_buf_size,
49  const uint8_t *src_buf, uint32_t src_buf_len);
50 void PrintStringsToBuffer(uint8_t *dst_buf, uint32_t *dst_buf_offset_ptr, uint32_t dst_buf_size,
51  const uint8_t *src_buf, const uint32_t src_buf_len);
52 void PrintRawLineHexBuf(char *, uint32_t, const uint8_t *, uint32_t );
53 const char *PrintInet(int , const void *, char *, socklen_t);
54 void PrintHexString(char *str, size_t size, uint8_t *buf, size_t buf_len);
55 
56 #endif /* SURICATA_UTIL_PRINT_H */
PrintRawDataToBuffer
void PrintRawDataToBuffer(uint8_t *dst_buf, uint32_t *dst_buf_offset_ptr, uint32_t dst_buf_size, const uint8_t *src_buf, uint32_t src_buf_len)
Definition: util-print.c:172
PrintRawLineHexBuf
void PrintRawLineHexBuf(char *, uint32_t, const uint8_t *, uint32_t)
print a buffer as hex on a single line into retbuf buffer
Definition: util-print.c:61
PrintStringsToBuffer
void PrintStringsToBuffer(uint8_t *dst_buf, uint32_t *dst_buf_offset_ptr, uint32_t dst_buf_size, const uint8_t *src_buf, const uint32_t src_buf_len)
Definition: util-print.c:220
PrintRawDataFp
void PrintRawDataFp(FILE *, const uint8_t *, uint32_t)
Definition: util-print.c:135
PrintRawJsonFp
void PrintRawJsonFp(FILE *, uint8_t *, uint32_t)
Definition: util-print.c:69
PrintBufferRawLineHex
void PrintBufferRawLineHex(char *, int *, int, const uint8_t *, uint32_t)
print a buffer as hex on a single line
Definition: util-print.c:44
str
#define str(s)
Definition: suricata-common.h:291
PrintRawUriBuf
void PrintRawUriBuf(char *, uint32_t *, uint32_t, uint8_t *, uint32_t)
Definition: util-print.c:114
PrintHexString
void PrintHexString(char *str, size_t size, uint8_t *buf, size_t buf_len)
Definition: util-print.c:286
PrintInet
const char * PrintInet(int, const void *, char *, socklen_t)
Definition: util-print.c:262
PrintRawUriFp
void PrintRawUriFp(FILE *, uint8_t *, uint32_t)
Definition: util-print.c:90