Skip to content

Commit

Permalink
pcap: Move declarations to a separate header
Browse files Browse the repository at this point in the history
Signed-off-by: Siddharth Chandrasekaran <[email protected]>
  • Loading branch information
Siddharth Chandrasekaran committed Feb 20, 2024
1 parent 231bc79 commit 7750be2
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 11 deletions.
1 change: 1 addition & 0 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def try_vendor_sources(src_dir, src_files, vendor_dir):

# Optional when PACKET_TRACE is enabled
"src/osdp_pcap.c",
"src/osdp_pcap.h",
"utils/include/utils/pcap_gen.h",
"utils/src/pcap_gen.c",
]
Expand Down
11 changes: 0 additions & 11 deletions src/osdp_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,17 +385,6 @@ static inline void cp_keyset_complete(struct osdp_pd *pd, bool restart_sc) { }
void cp_keyset_complete(struct osdp_pd *pd, bool restart_sc);
#endif

#if defined(CONFIG_OSDP_PACKET_TRACE) || defined(CONFIG_OSDP_DATA_TRACE)
void osdp_packet_capture_init(struct osdp_pd *pd);
void osdp_packet_capture_finish(struct osdp_pd *pd);
void osdp_capture_packet(struct osdp_pd *pd, uint8_t *buf, int len);
#else
static inline void osdp_packet_capture_init(struct osdp_pd *pd) { }
static inline void osdp_packet_capture_finish(struct osdp_pd *pd) { }
static inline void osdp_capture_packet(struct osdp_pd *pd,
uint8_t *buf, int len) { }
#endif

void osdp_keyset_complete(struct osdp_pd *pd);

/* from osdp_phy.c */
Expand Down
1 change: 1 addition & 0 deletions src/osdp_cp.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include "osdp_common.h"
#include "osdp_file.h"
#include "osdp_pcap.h"

#define CMD_POLL_LEN 1
#define CMD_LSTAT_LEN 1
Expand Down
41 changes: 41 additions & 0 deletions src/osdp_pcap.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2024 Siddharth Chandrasekaran <[email protected]>
*
* SPDX-License-Identifier: Apache-2.0
*/

#ifndef _OSDP_PCAP_H_
#define _OSDP_PCAP_H_

#include "osdp_common.h"

#if defined(CONFIG_OSDP_PACKET_TRACE) || defined(CONFIG_OSDP_DATA_TRACE)

void osdp_packet_capture_init(struct osdp_pd *pd);
void osdp_packet_capture_finish(struct osdp_pd *pd);
void osdp_capture_packet(struct osdp_pd *pd, uint8_t *buf, int len);

#else

static inline void osdp_packet_capture_init(struct osdp_pd *pd)
{
ARG_UNUSED(pd);
}

static inline void osdp_packet_capture_finish(struct osdp_pd *pd)
{
ARG_UNUSED(pd);
}

static inline void osdp_capture_packet(struct osdp_pd *pd,
uint8_t *buf, int len)
{
ARG_UNUSED(pd);
ARG_UNUSED(buf);
ARG_UNUSED(len);
}

#endif

#endif /* _OSDP_PCAP_H_ */

1 change: 1 addition & 0 deletions src/osdp_pd.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "osdp_common.h"
#include "osdp_file.h"
#include "osdp_pcap.h"

#ifndef CONFIG_OSDP_STATIC_PD
#include <stdlib.h>
Expand Down
1 change: 1 addition & 0 deletions src/osdp_phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

#include "osdp_common.h"
#include "osdp_pcap.h"

#define OSDP_PKT_MARK 0xFF
#define OSDP_PKT_SOM 0x53
Expand Down

0 comments on commit 7750be2

Please sign in to comment.