2015-04-06 14:32:37 +02:00
|
|
|
/*
|
|
|
|
This file is part of libcapwap.
|
|
|
|
|
|
|
|
libcapwap is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
libcapwap is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
*@file
|
2018-02-23 09:06:22 +01:00
|
|
|
*@brief Prototypes of cw_format-functions
|
2016-03-12 09:28:35 +01:00
|
|
|
*@defgroup FORMAT FORMAT
|
2015-05-02 10:45:16 +02:00
|
|
|
*@{
|
2015-04-06 14:32:37 +02:00
|
|
|
*/
|
|
|
|
|
2016-03-12 09:28:35 +01:00
|
|
|
#ifndef __FORMAT_H
|
|
|
|
#define __FORMAT_H
|
2015-04-06 14:32:37 +02:00
|
|
|
|
2018-03-04 16:59:20 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stddef.h>
|
2015-04-19 23:27:44 +02:00
|
|
|
|
2018-03-05 20:39:15 +01:00
|
|
|
#include "sock.h"
|
|
|
|
|
2018-03-04 16:59:20 +01:00
|
|
|
int format_hex_bytes(char *dst, const char *format, const char *delim,
|
2018-02-23 09:06:22 +01:00
|
|
|
const uint8_t * src, int len);
|
2015-05-04 07:39:13 +02:00
|
|
|
|
2018-03-02 13:36:03 +01:00
|
|
|
char *format_s_hex_bytes(char *dst, const char *format, const char *delim,
|
|
|
|
const uint8_t * src, int len);
|
|
|
|
|
|
|
|
|
2016-04-10 15:57:26 +02:00
|
|
|
|
2018-02-23 09:06:22 +01:00
|
|
|
#define format_bin2hex(src,len) (format_s_hex_bytes((char[(len) * 2 + 1]) {0}, "%02X", "", src, len))
|
2016-04-10 15:57:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-03-06 18:28:31 +01:00
|
|
|
int cw_format_scan_hex_bytes(uint8_t *dst,const char *s, int len);
|
2015-04-06 14:32:37 +02:00
|
|
|
|
2018-03-06 18:28:31 +01:00
|
|
|
struct avltree;
|
2015-04-06 14:32:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Format bytes as a hex string. Hexadecimal letters are lower-case.
|
|
|
|
* @param dst destination buffer
|
|
|
|
* @param bytes bytes to format
|
|
|
|
* @param len number of bytes to format
|
|
|
|
* @return number of characters written to the destination buffer
|
|
|
|
*
|
|
|
|
* Make sure, the destination buffer can hold at least len * 2 characters + the trailing
|
|
|
|
* zero for strings.
|
|
|
|
*/
|
2016-03-12 09:28:35 +01:00
|
|
|
#define format_hexl(dst,bytes,len)\
|
|
|
|
format_hex_bytes(dst,"%02x","",bytes,len)
|
2015-04-06 14:32:37 +02:00
|
|
|
|
|
|
|
/**
|
2016-03-12 09:28:35 +01:00
|
|
|
* Format bytes as hex string. Same as #format_hexl, but
|
2015-04-06 14:32:37 +02:00
|
|
|
* hexadecimal letters are upper-case.
|
|
|
|
*/
|
2016-03-12 09:28:35 +01:00
|
|
|
#define format_hexu(dst,bytes,len)\
|
|
|
|
format_hex_bytes(dst,"%02X","",bytes,len)
|
2015-04-06 14:32:37 +02:00
|
|
|
|
|
|
|
/**
|
2016-03-12 09:28:35 +01:00
|
|
|
* Alias for #format_hexl.
|
2015-04-06 14:32:37 +02:00
|
|
|
*/
|
2016-03-12 09:28:35 +01:00
|
|
|
#define format_hex format_hexl
|
2015-04-06 14:32:37 +02:00
|
|
|
|
2015-04-12 19:19:29 +02:00
|
|
|
/**
|
|
|
|
* Format MAC Address.
|
2018-02-23 09:06:22 +01:00
|
|
|
*/
|
2016-03-12 09:28:35 +01:00
|
|
|
#define format_mac(dst,src,len)\
|
|
|
|
format_hex_bytes(dst,"%02x",":",src,len)
|
2015-04-11 19:00:51 +02:00
|
|
|
|
2018-03-02 13:36:03 +01:00
|
|
|
int format_hdr_flags(char *dst, uint8_t * th);
|
2015-05-02 10:45:16 +02:00
|
|
|
|
2016-03-24 22:42:34 +01:00
|
|
|
|
2018-03-07 08:57:04 +01:00
|
|
|
int format_is_utf8(const unsigned char *str, size_t len);
|
2015-05-02 10:45:16 +02:00
|
|
|
|
2016-03-24 22:42:34 +01:00
|
|
|
int format_dot11_fc(char *dst, uint16_t fc);
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-03-04 16:59:20 +01:00
|
|
|
|
|
|
|
|
|
|
|
struct cw_FormatDumpSettings {
|
2018-03-05 07:18:02 +01:00
|
|
|
int row_len;
|
|
|
|
int marker_distance;
|
|
|
|
char marker_char;
|
2018-03-04 16:59:20 +01:00
|
|
|
int ascii;
|
2018-03-05 07:18:02 +01:00
|
|
|
|
|
|
|
int inv_len;
|
|
|
|
char inv_char;
|
2018-03-04 16:59:20 +01:00
|
|
|
|
|
|
|
const char * dump_prefix;
|
2018-03-07 13:13:58 +01:00
|
|
|
const char * dump_suffix;
|
2018-03-05 07:18:02 +01:00
|
|
|
const char * ascii_prefix;
|
|
|
|
const char *newline;
|
2018-03-04 16:59:20 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
char *cw_format_dump(const uint8_t * data, int len,
|
|
|
|
struct cw_FormatDumpSettings *settings);
|
|
|
|
|
2018-03-05 07:18:02 +01:00
|
|
|
void cw_format_get_dump_defaults(struct cw_FormatDumpSettings * settings);
|
2018-03-05 20:39:15 +01:00
|
|
|
int cw_format_pkt_hdr(char *dst, int incomming, uint8_t * packet, int len,
|
|
|
|
struct sockaddr *from);
|
2018-03-07 08:57:04 +01:00
|
|
|
int cw_format_version(char *s, const uint8_t * version, int len);
|
2018-03-05 07:18:02 +01:00
|
|
|
|
2015-05-02 10:45:16 +02:00
|
|
|
/**@}*/
|
|
|
|
|
2015-04-06 14:32:37 +02:00
|
|
|
#endif
|