13
0
Fork 1

dump EEPROM tool, run dump_eeprom send the resulting eeprom_*.bin to team@dedected.org

git-svn-id: https://dedected.org/svn/trunk@48 8d8ab74c-27aa-4a3d-9bde-523a2bc1f624
This commit is contained in:
mazzoo 2009-01-26 22:07:11 +00:00
parent 02af416aac
commit eacd1ef592
5 changed files with 121 additions and 2 deletions

View File

@ -129,6 +129,28 @@ int coa_ioctl(
sniffer_init(dev);
printk(COA_DEVICE_NAME": sniffer initialized\n");
break;
case COA_MODE_EEPROM:
{
/* copy EEPROM to fifo */
#ifndef pcmcia_read_cis_mem /* not in any of my kernel headers :( */
int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, u_int addr,
u_int len, void *ptr);
#endif
uint8_t id = get_card_id();
uint8_t * eeprom = kmalloc(EEPROM_SIZE, GFP_KERNEL);
if (!eeprom) return -ENOMEM;
kfifo_put(dev->rx_fifo, &id, 1);
pcmcia_read_cis_mem(
dev->p_dev->socket,
1,
0,
EEPROM_SIZE,
eeprom);
kfifo_put(dev->rx_fifo, eeprom, EEPROM_SIZE);
kfree(eeprom);
break;
}
case COA_MODE_JAM:
printk("FIXME: implement COA_MODE_JAM\n");
break;

View File

@ -59,5 +59,4 @@ int get_card_id(void);
#define COA_RADIO_TYPE_III 1
#define COA_RADIO_FREEPAD 2
#endif

View File

@ -23,6 +23,7 @@
#define COA_MODE_PP 0x0200
#define COA_MODE_SNIFF 0x0300
#define COA_MODE_JAM 0x0400
#define COA_MODE_EEPROM 0x0500
#define COA_SUBMODE_SNIFF_SCANFP 0x0001
@ -42,4 +43,6 @@
#define COA_IOCTL_FIRMWARE 0xD007 /* request_firmware() */
#define COA_IOCTL_SETRFPI 0xD008
#define EEPROM_SIZE 2048
#endif

View File

@ -1,5 +1,5 @@
CFLAGS=-Wall -O2 -I..
PROGS=coa_syncsniff pcap2cchan
PROGS=coa_syncsniff pcap2cchan dump_eeprom
PCAP_PROGS=pcapstein dect_cli
all:$(PROGS) $(PCAP_PROGS)

View File

@ -0,0 +1,95 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include "com_on_air_user.h"
#define DEV "/dev/coa"
#define FNAME_FMT "eeprom_%.1x_%.2x_%.2x_%.2x_%.2x_%.2x.bin"
int main(int argc, char ** argv)
{
uint8_t eeprom[EEPROM_SIZE+1];
char fname[99];
int fd;
int ret;
uint16_t val;
int rfpi_off = 0x204;
fd = open(DEV, O_RDWR | O_NONBLOCK);
if (fd < 0)
{
printf("!!! couldn't open(\"%s\"): %s\n",
DEV,
strerror(errno));
exit(1);
}
val = COA_MODE_EEPROM;
if (ioctl(fd, COA_IOCTL_MODE, &val)){
printf("couldn't ioctl(): %s\n",
strerror(errno));
exit(1);
}
ret = read(fd, eeprom, EEPROM_SIZE+1);
if (ret != EEPROM_SIZE+1)
{
printf("!!! read(\"%s\") returned %d\n",
DEV,
ret);
exit(1);
}
ret = close(fd);
if (ret)
{
printf("!!! couldn't close(\"%s\"): %s\n",
DEV,
strerror(errno));
exit(1);
}
if ( (eeprom[0] == 0) || (eeprom[0] == 3) )
rfpi_off = 0x203; /* tpye II cards */
sprintf(fname, FNAME_FMT,
eeprom[0],
eeprom[rfpi_off+0],
eeprom[rfpi_off+1],
eeprom[rfpi_off+2],
eeprom[rfpi_off+3],
eeprom[rfpi_off+4]
);
fd = open(fname, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (fd < 0)
{
printf("!!! couldn't open(\"%s\"): %s\n",
fname,
strerror(errno));
exit(1);
}
ret = write(fd, eeprom, EEPROM_SIZE+1);
if (ret != EEPROM_SIZE+1)
{
printf("!!! write(\"%s\") returned %d\n",
DEV,
ret);
exit(1);
}
ret = close(fd);
if (ret)
{
printf("!!! couldn't close(\"%s\"): %s\n",
fname,
strerror(errno));
exit(1);
}
printf("successfully wrote EEPROM to %s\n", fname);
return 0;
}