Browse Source

Allow monitoring of own outgoing fprs packets

master
Jeroen Vreeken 9 months ago
parent
commit
f07681d8fd
3 changed files with 18 additions and 4 deletions
  1. +9
    -3
      fprs_monitor.c
  2. +8
    -1
      interface.c
  3. +1
    -0
      interface.h

+ 9
- 3
fprs_monitor.c View File

@ -55,7 +55,7 @@ static int cb(uint8_t to[6], uint8_t from[6], uint16_t eth_type, uint8_t *data,
static void usage(void)
{
printf("Options:\n");
printf("-n [dev]\tNetwork device name (default: \"%s\")\n", netname);
printf("-i [dev]\tNetwork device name (default: \"%s\")\n", netname);
}
@ -63,12 +63,16 @@ int main(int argc, char **argv)
{
int opt;
int fd_int;
bool outgoing = false;
while ((opt = getopt(argc, argv, "n:")) != -1) {
while ((opt = getopt(argc, argv, "i:t")) != -1) {
switch(opt) {
case 'n':
case 'i':
netname = optarg;
break;
case 't':
outgoing = true;
break;
default:
goto err_usage;
}
@ -79,6 +83,8 @@ int main(int argc, char **argv)
printf("Could not open interface: %s\n", strerror(errno));
return -1;
}
interface_tx_outgoing(outgoing);
do {
fd_set fdr;


+ 8
- 1
interface.c View File

@ -32,6 +32,7 @@
#include <linux/if_tun.h>
static int fd;
static bool outgoing = false;
int interface_rx(uint8_t to[ETH_AR_MAC_SIZE], uint8_t from[ETH_AR_MAC_SIZE], uint16_t eth_type, uint8_t *data, size_t len, uint8_t transmission, uint8_t level)
{
@ -95,7 +96,7 @@ static int interface_tx_sock(size_t doff, int (*cb)(uint8_t to[ETH_AR_MAC_SIZE],
if (len > 16) {
// int i;
if (addr.sll_pkttype != PACKET_OUTGOING) {
if (addr.sll_pkttype != PACKET_OUTGOING || outgoing) {
uint16_t eth_type = (data[12] << 8) | data[13];
return cb(data, data + 6, eth_type, data + doff, len - doff, data[14], data[15]);
@ -242,3 +243,9 @@ int interface_init(char *name, uint8_t mac[ETH_AR_MAC_SIZE], bool tap, uint16_t
return fd;
}
int interface_tx_outgoing(bool enable)
{
outgoing = enable;
return 0;
}

+ 1
- 0
interface.h View File

@ -29,5 +29,6 @@ int interface_rx(uint8_t to[ETH_AR_MAC_SIZE], uint8_t from[ETH_AR_MAC_SIZE], uin
int interface_tx_raw(int (*cb)(uint8_t to[ETH_AR_MAC_SIZE], uint8_t from[ETH_AR_MAC_SIZE], uint16_t eth_type, uint8_t *data, size_t len));
int interface_tx(int (*cb)(uint8_t to[ETH_AR_MAC_SIZE], uint8_t from[ETH_AR_MAC_SIZE], uint16_t eth_type, uint8_t *data, size_t len, uint8_t transmission, uint8_t level));
int interface_init(char *name, uint8_t mac[ETH_AR_MAC_SIZE], bool tap, uint16_t filter_type);
int interface_tx_outgoing(bool enable);
#endif /* _INCLUDE_INTERFACE_H_ */

Loading…
Cancel
Save