forked from dect/dedected
1
0
Fork 0

Compare commits

...

5 Commits

Author SHA1 Message Date
Martin Hauke e8cfb775e7 HACK: Use "0xDE" instead of "0xDEC" for the major number
Workaround the issues that the com_on_air_cs.ko kernel module could not be loaded:

insmod com_on_air_cs.ko
-> insmod: ERROR: could not insert module com_on_air_cs.ko: Invalid parameters

dmesg
-> CHRDEV "com_on_air_cs" major requested (3564) is greater than the maximum (511)

CHRDEV_MAJOR_MAX is set to "512" in the kernel
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/include/linux/fs.h
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/fs/char_dev.c

com_on_air_cs uses 0xDEC (int 3564) which is greater than this maximum.
 -> Workaround: Use 0xDE (int  222) instead.

This already conflicts with a reserved (but probably not widely used) allocation:
https://www.kernel.org/doc/Documentation/admin-guide/devices.txt

Real fix:
* Use Dynamic Major Number allocation instead of assigning a static one.
2023-12-16 14:49:30 +01:00
Martin Hauke 75d82e718b dectshark: Link against -lncursesw instead of -lcurses
Fixes compile issues on openSUSE systems.
2023-12-16 13:15:42 +01:00
Martin Hauke 338b611564 pcapstein: Fix conflicting types for 'shutdown'
pcapstein.c:174:6: error: conflicting types for 'shutdown'; have 'void()'
  174 | void shutdown()
      |      ^~~~~~~~
In file included from /usr/include/pcap/socket.h:58,
                 from /usr/include/pcap/pcap.h:130:
/usr/include/sys/socket.h:324:12: note: previous declaration of 'shutdown' with type 'int(int,  int)'
  324 | extern int shutdown (int __fd, int __how) __THROW;
      |            ^~~~~~~~
2023-12-16 13:12:47 +01:00
Martin Hauke fb6b4944ad com-on-air_cs-linux: Use ioremap instead of ioremap_nocache on kernels >= 5.6
ioremap_nocache was deprecated for a long time finally got dropped with kernel 5.6
4bdc0d676a
2023-12-16 12:59:07 +01:00
Martin Hauke 16309c0396 com-on-air_cs-linux: Use timespec64 instead of timespec on kernels >= 5.6
struct timespec is deprecated since it overflows in 2038 on 32-bit
architectures.

https://lwn.net/Articles/643234/
2023-12-16 12:55:34 +01:00
10 changed files with 28 additions and 12 deletions

View File

@ -32,7 +32,7 @@ reload:
node: $(NODE)
$(NODE):
mknod $@ --mode 660 c 3564 0 ### 3564 == 0xDEC
mknod $@ --mode 660 c 222 0 ### 222 == 0xDE
# chgrp dect $(NODE)
read: node coa_read

View File

@ -20,6 +20,7 @@
#include <linux/crc32.h>
#include <linux/kfifo.h>
#include <linux/poll.h>
#include <linux/version.h>
#include <pcmcia/cistpl.h>
#include <pcmcia/ciscode.h>
@ -406,7 +407,11 @@ com_on_air_irq_handler(int irq, void *dev_id)
uint8_t dip_irq = 0;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
jiffies_to_timespec64(jiffies, &dev->irq_timestamp);
#else
jiffies_to_timespec(jiffies, &dev->irq_timestamp);
#endif
dev->irq_count++;
switch(dev->operation_mode & COA_MODEMASK)
@ -480,7 +485,7 @@ static int com_on_air_probe (struct pcmcia_device *link)
dev->links[0] = link;
dev->memsize[0] = resource_size(link->resource[2]);
dev->membase[0] = ioremap_nocache(link->resource[2]->start, resource_size(link->resource[2]));
dev->membase[0] = ioremap(link->resource[2]->start, resource_size(link->resource[2]));
if (!dev->membase[0])
{
@ -740,7 +745,7 @@ static int __init init_com_on_air_cs(void)
goto init_out_3;
}
ret = register_chrdev(0xDEC, COA_DEVICE_NAME, &coa_fops);
ret = register_chrdev(0xDE, COA_DEVICE_NAME, &coa_fops);
if (ret < 0)
{
printk("couldn't register_chrdev()\n");
@ -768,7 +773,7 @@ static int __init init_com_on_air_cs(void)
init_out_0:
kfifo_free(&dev->rx_fifo);
init_out_1:
unregister_chrdev(0xDEC, COA_DEVICE_NAME);
unregister_chrdev(0xDE, COA_DEVICE_NAME);
init_out_2:
pcmcia_unregister_driver(&coa_driver);
init_out_3:
@ -782,7 +787,7 @@ static void __exit exit_com_on_air_cs(void)
if (!dev) return;
unregister_chrdev(0xDEC, COA_DEVICE_NAME);
unregister_chrdev(0xDE, COA_DEVICE_NAME);
pcmcia_unregister_driver(&coa_driver);

View File

@ -16,6 +16,7 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/version.h>
struct coa_info
{
@ -24,7 +25,11 @@ struct coa_info
int irq;
int irq_count;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
struct timespec64 irq_timestamp;
#else
struct timespec irq_timestamp;
#endif
struct pcmcia_device *links[2];

View File

@ -29,6 +29,8 @@
#include "dect.h"
#include "com_on_air.h"
#include <linux/version.h>
struct sniffer_cfg
{
int snifftype;
@ -57,7 +59,11 @@ struct sniffed_packet
unsigned char channel;
unsigned char slot;
unsigned char frameflags;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
struct timespec64 timestamp;
#else
struct timespec timestamp;
#endif
unsigned char data[53];
};

View File

@ -136,7 +136,7 @@ int main(int argc, char *argv[])
write_global_header(pcap);
//sniff-loop
while (0xDEC + 't')
while (0xDE + 't')
{
struct sniffed_packet buf;
while (sizeof(struct sniffed_packet) == (ret = read(d, &buf, (sizeof(struct sniffed_packet)))))

View File

@ -1001,7 +1001,7 @@ void mainloop(void)
int ret;
while (0xDEC + 'T')
while (0xDE + 'T')
{
tv.tv_sec = 1;
tv.tv_usec = 0;

View File

@ -1,6 +1,6 @@
CPPFLAGS=-Wall -O2 -I../..
dectshark: dectshark.o gui.o foundinfo.o scanmode_gui.o syncmode_gui.o packetparser.o packetsaver.o
g++ $(CPPFLAGS) dectshark.o gui.o scanmode_gui.o syncmode_gui.o foundinfo.o packetparser.o packetsaver.o -o dectshark -lcurses -lpthread -lpcap
g++ $(CPPFLAGS) dectshark.o gui.o scanmode_gui.o syncmode_gui.o foundinfo.o packetparser.o packetsaver.o -o dectshark -lncursesw -lpthread -lpcap
clean:
rm *.o *~ dectshark

View File

@ -259,7 +259,7 @@ void *scanthread(void *threadid)
}
while(0xDEC + 'T') // ;)
while(0xDE + 'T') // ;)
{
dect_found found;

View File

@ -263,7 +263,7 @@ void *syncthread(void *threadid)
psaver.openfilerfpi(RFPI);
while (0xDEC + 'T')
while (0xDE + 'T')
{
tv.tv_sec = 1;
tv.tv_usec = 0;

View File

@ -171,7 +171,7 @@ void play()
fprintf(stderr, "pcap error: %s\n", errbuf);
}
void shutdown()
void _shutdown()
{
pcap_close(fi.p);
close(fi.fpp);
@ -187,6 +187,6 @@ int main(int argc, char ** argv)
}
init(argv[1]);
play();
shutdown();
_shutdown();
return 0;
}