|
Packit |
e9ba0d |
/* -*- mode: c; c-file-style: "openbsd" -*- */
|
|
Packit |
e9ba0d |
/*
|
|
Packit |
e9ba0d |
* Copyright (c) 2015 Vincent Bernat <bernat@luffy.cx>
|
|
Packit |
e9ba0d |
*
|
|
Packit |
e9ba0d |
* Permission to use, copy, modify, and/or distribute this software for any
|
|
Packit |
e9ba0d |
* purpose with or without fee is hereby granted, provided that the above
|
|
Packit |
e9ba0d |
* copyright notice and this permission notice appear in all copies.
|
|
Packit |
e9ba0d |
*
|
|
Packit |
e9ba0d |
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
Packit |
e9ba0d |
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
Packit |
e9ba0d |
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
Packit |
e9ba0d |
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
Packit |
e9ba0d |
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
Packit |
e9ba0d |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
Packit |
e9ba0d |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
Packit |
e9ba0d |
*/
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
#ifndef _COMMON_H
|
|
Packit |
e9ba0d |
#define _COMMON_H
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
#include "check-compat.h"
|
|
Packit |
e9ba0d |
#include "../src/daemon/lldpd.h"
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
/* See:
|
|
Packit |
e9ba0d |
* http://wiki.wireshark.org/Development/LibpcapFileFormat
|
|
Packit |
e9ba0d |
*/
|
|
Packit |
e9ba0d |
struct pcap_hdr {
|
|
Packit |
e9ba0d |
u_int32_t magic_number; /* magic number */
|
|
Packit |
e9ba0d |
u_int16_t version_major; /* major version number */
|
|
Packit |
e9ba0d |
u_int16_t version_minor; /* minor version number */
|
|
Packit |
e9ba0d |
u_int32_t thiszone; /* GMT to local correction */
|
|
Packit |
e9ba0d |
u_int32_t sigfigs; /* accuracy of timestamps */
|
|
Packit |
e9ba0d |
u_int32_t snaplen; /* max length of captured packets, in octets */
|
|
Packit |
e9ba0d |
u_int32_t network; /* data link type */
|
|
Packit |
e9ba0d |
};
|
|
Packit |
e9ba0d |
struct pcaprec_hdr {
|
|
Packit |
e9ba0d |
u_int32_t ts_sec; /* timestamp seconds */
|
|
Packit |
e9ba0d |
u_int32_t ts_usec; /* timestamp microseconds */
|
|
Packit |
e9ba0d |
u_int32_t incl_len; /* number of octets of packet saved in file */
|
|
Packit |
e9ba0d |
u_int32_t orig_len; /* actual length of packet */
|
|
Packit |
e9ba0d |
};
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
struct packet {
|
|
Packit |
e9ba0d |
TAILQ_ENTRY(packet) next;
|
|
Packit |
e9ba0d |
int size;
|
|
Packit |
e9ba0d |
char data[];
|
|
Packit |
e9ba0d |
};
|
|
Packit |
e9ba0d |
TAILQ_HEAD(pkts_t, packet);
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
extern int dump; /* Dump file descriptor in pcap format */
|
|
Packit |
e9ba0d |
extern char filenameprefix[]; /* Prefix for filename dumping */
|
|
Packit |
e9ba0d |
extern char *filename; /* Filename we are dumping to */
|
|
Packit |
e9ba0d |
extern char macaddress[]; /* MAC address we use to send */
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
extern struct pkts_t pkts; /* List of sent packets */
|
|
Packit |
e9ba0d |
extern struct lldpd_hardware hardware;
|
|
Packit |
e9ba0d |
extern struct lldpd_chassis chassis;
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
int pcap_send(struct lldpd *, struct lldpd_hardware *, char *, size_t);
|
|
Packit |
e9ba0d |
void pcap_setup();
|
|
Packit |
e9ba0d |
void pcap_teardown();
|
|
Packit |
e9ba0d |
|
|
Packit |
e9ba0d |
#endif
|