Added code to handle PDR files.

This commit is contained in:
mark 2000-01-28 00:44:19 +00:00
parent 18d2b5ac01
commit ee1b4ace46
2 changed files with 418 additions and 132 deletions

View File

@ -31,7 +31,7 @@
include ../../../config.mk
ifndef CFLAGS
CFLAGS = -O2 -Wall -Wstrict-prototypes -Winline -pipe
CFLAGS = -g -O2 -Wall -Wstrict-prototypes -Winline -pipe
endif
CPPFLAGS = -I../../include -I../include -D__LINUX_WLAN__ -D__I386__
@ -43,7 +43,7 @@ OBJS = prism2dl.o
prism2dl: $(OBJS)
cc -o prism2dl $(OBJS)
cc -g -o prism2dl $(OBJS)
install:
cp -p prism2dl $(INST_EXEDIR)

View File

@ -37,6 +37,8 @@
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <ctype.h>
#include <regex.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/ioctl.h>
@ -107,6 +109,8 @@
#define S3ADDR_CRC (0xff100000UL)
#define S3ADDR_INFO (0xff200000UL)
#define PDAFILE_LINE_MAX 1024
/*================================================================*/
/* Local Macros */
@ -148,6 +152,13 @@ typedef struct s3inforec
} info;
} s3inforec_t;
typedef struct pda
{
UINT8 buf[HFA384x_PDA_LEN_MAX];
hfa384x_pdrec_t *rec[HFA384x_PDA_RECS_MAX];
UINT nrec;
} pda_t;
/*================================================================*/
/* Local Static Definitions */
@ -214,36 +225,21 @@ UINT32 startaddr;
/* fields are stored in HOST byte order. The makepdrlist() function */
/* does the conversion. */
/*----------------------------------------------------------------*/
/* Card PDA */
/* PDA, built from [card|newfile]+[addfile1+addfile2...] */
UINT8 cardpda[HFA384x_PDA_LEN_MAX];
hfa384x_pdrec_t cardpdrec[HFA384x_PDA_RECS_MAX];
UINT ncardpdrec = 0;
/*----------------------------------------------------------------*/
/* Replacement PDA (from file) */
UINT8 newpda[HFA384x_PDA_LEN_MAX];
hfa384x_pdrec_t newpdrec[HFA384x_PDA_RECS_MAX];
UINT nnewpdrec = 0;
/*----------------------------------------------------------------*/
/* Additive PDRs (adds to replacement or card PDA) */
UINT8 addpda[HFA384x_PDA_LEN_MAX];
hfa384x_pdrec_t addpdrec[HFA384x_PDA_RECS_MAX];
UINT naddpdrec = 0;
pda_t pda;
/*================================================================*/
/* Local Function Declarations */
void usage(void);
int load_srecfile(char *fname);
int load_pdrfile( char *fname, int isnew);
int load_cardpda(void);
int makepdrlist( UINT8 *pda, hfa384x_pdrec_t *pdrec, UINT *nrec);
int read_srecfile(char *fname);
int read_pdrfile( char *fname, int isnew);
int read_cardpda(pda_t *pda, char *dev);
int read_filepda(pda_t *pda, char *pdrfname);
int makepdrlist( pda_t *pda);
int do_ioctl( p80211msg_t *msg );
void print_all_pdrs(void);
void print_all_pdrs(pda_t *pda);
int str2macaddr( UINT8 *a, char *s );
/*================================================================*/
@ -267,6 +263,8 @@ int main ( int argc, char **argv )
{
INT result = 0;
int optch;
int i;
int pda_changed = 0; /* has cardpda been altered? */
strcpy( appname, APPNAME );
fullname = argv[0];
@ -290,15 +288,12 @@ int main ( int argc, char **argv )
memset(s3info, 0, sizeof(s3info));
startaddr = 0;
memset(cardpda, 0, sizeof(cardpda));
memset(cardpdrec, 0, sizeof(cardpdrec));
ncardpdrec = 0;
memset(newpda, 0, sizeof(newpda));
memset(newpdrec, 0, sizeof(newpdrec));
nnewpdrec = 0;
memset(addpda, 0, sizeof(addpda));
memset(addpdrec, 0, sizeof(newpdrec));
naddpdrec = 0;
/* clear the pda and add an initial END record */
memset(&pda, 0, sizeof(pda));
pda.rec[0] = (hfa384x_pdrec_t*)pda.buf;
pda.rec[0]->len = host2hfa384x_16(2); /* len in words */ /* len in words */
pda.rec[0]->code = host2hfa384x_16(HFA384x_PDR_END_OF_PDA);
pda.nrec = 1;
/* if no args, print the usage msg */
if ( argc < 2 ) {
@ -334,7 +329,7 @@ int main ( int argc, char **argv )
case 'r':
/* Ram image filename, add to list */
if ( opt_ramloadcnt >= RAMFILES_MAX ) {
fprintf(stderr,APPNAME": too many RAM files on cmd line. Exitting.\n");
fprintf(stderr,APPNAME": too many RAM files on cmd line. Exiting.\n");
exit(1);
}
strncpy(rfname[opt_ramloadcnt], optarg, FILENAME_MAX);
@ -343,7 +338,7 @@ int main ( int argc, char **argv )
case 'f':
/* Flash image filename, add to list */
if ( opt_flashloadcnt >= FLASHFILES_MAX ) {
fprintf(stderr,APPNAME": too many FLASH files on cmd line. Exitting.\n");
fprintf(stderr,APPNAME": too many FLASH files on cmd line. Exiting.\n");
exit(1);
}
strncpy(ffname[opt_flashloadcnt], optarg, FILENAME_MAX);
@ -352,7 +347,7 @@ int main ( int argc, char **argv )
case 'a':
/* Flash image filename, add to list */
if ( opt_addpdrcnt >= ADDPDRFILES_MAX ) {
fprintf(stderr,APPNAME": too many ADDPDR files on cmd line. Exitting.\n");
fprintf(stderr,APPNAME": too many ADDPDR files on cmd line. Exiting.\n");
exit(1);
}
strncpy(addpdrfname[opt_addpdrcnt], optarg, FILENAME_MAX);
@ -361,7 +356,7 @@ int main ( int argc, char **argv )
case 'p':
/* New PDA filename */
if ( opt_newpda ) {
fprintf(stderr,APPNAME": -p specified more than once. Exitting.\n");
fprintf(stderr,APPNAME": -p specified more than once. Exiting.\n");
exit(1);
}
opt_newpda = 1;
@ -370,11 +365,11 @@ int main ( int argc, char **argv )
case 'm':
/* cmdline MAC address */
if ( opt_macaddr ) {
fprintf(stderr,APPNAME": -m specified more than once. Exitting.\n");
fprintf(stderr,APPNAME": -m specified more than once. Exiting.\n");
exit(1);
}
if ( str2macaddr(macaddr, optarg) != 0 ) {
fprintf(stderr,APPNAME": mac address format error. Exitting.\n");
fprintf(stderr,APPNAME": mac address format error. Exiting.\n");
exit(1);
}
opt_macaddr = 1;
@ -382,7 +377,7 @@ int main ( int argc, char **argv )
case 'S':
/* cmdline Serial number */
if ( opt_sernum ) {
fprintf(stderr,APPNAME": -S specified more than once. Exitting.\n");
fprintf(stderr,APPNAME": -S specified more than once. Exiting.\n");
exit(1);
}
strncpy( sernum, optarg, SERNUM_LEN_MAX);
@ -396,10 +391,18 @@ int main ( int argc, char **argv )
}
}
/* check for options that are mutually exclusive */
if ( opt_debug && opt_nowrite ) {
fprintf(stderr,APPNAME": -n and -d are mutually exclusive. Exiting.\n");
exit(1);
}
/*-----------------------------------------------------*/
/* if we made it this far, the options must be pretty much OK */
if ( optind >= argc ) {
/* save the interface name */
if ( optind >= argc && !opt_debug ) {
/* we're missing the interface argument */
fprintf(stderr, APPNAME": missing argument - interface\n");
fprintf(stderr, APPNAME": missing argument - devname\n");
usage();
return -1;
} else {
@ -407,7 +410,84 @@ int main ( int argc, char **argv )
strncpy( devname, argv[optind], sizeof(devname) );
}
/* Check mode and validate args */
/*-----------------------------------------------------*/
/* Build the PDA we're going to use. */
pda_changed = 0;
if ( !opt_newpda && !opt_debug ) { /* read pda from card */
if (read_cardpda(&pda, devname)) {
fprintf(stderr,"loac_cardpda failed, exiting.\n");
exit(1);
}
if ( opt_status && opt_addpdrcnt) { /* print pda */
printf( "Card PDA prior to file generated "
"modifications:\n");
print_all_pdrs(&pda);
}
} else { /* read pda from file */
pda_changed = 1;
read_filepda(&pda, newpdafname);
if (opt_status) {
printf( "File PDA prior to file generated "
"modifications:\n");
print_all_pdrs(&pda);
}
}
if ( opt_addpdrcnt ) { /* read the "add pdas" and merge them*/
pda_changed = 1;
for ( i = 0; i < opt_addpdrcnt; i++) {
read_filepda(&pda, addpdrfname[i]);
}
}
if ( opt_status && opt_addpdrcnt ) {
printf("PDA after \"-a\" file generated modifications:\n");
print_all_pdrs(&pda);
/* Read and print the CIS? */
exit(0);
}
/*-----------------------------------------------------*/
/* Read the flash files */
if ( opt_flashloadcnt ) {
/* For each file */
/* Read the S3 file */
/* Validate the identity and compat ranges */
/* Make the image chunks */
/* Do any plugging */
}
/* Read the ram files */
if ( opt_flashloadcnt ) {
/* For each file */
/* Validate the identity and compat ranges */
/* Make the image chunks */
/* Do any plugging */
}
/*-----------------------------------------------------*/
/* Start loading */
if ( opt_newpda || opt_flashloadcnt ) {
/* Send aux enable BEGIN message */
/* Send flash d/l BEGIN message */
}
if ( pda_changed ) { /* load a new PDA, if necessary */
/* Program the PDA */
}
if ( opt_flashloadcnt ) { /* load the flash chunks */
/* For each chunk */
/* program chunk */
}
if ( opt_newpda || opt_flashloadcnt ) {
/* Send flash d/l END message */
/* Will result flashed code rebooting. */
}
#if 0
if (opt_dumppda) {
switch (opt_dumppda)
@ -429,16 +509,16 @@ int main ( int argc, char **argv )
/* Read files */
/*
if ( opt_newpda ) {
load_pdrfile(pdafilename, 1);
read_pdrfile(pdafilename, 1);
}
if ( opt_addpdrs ) {
load_pdrfile(pdrfilename, 0);
read_pdrfile(pdrfilename, 0);
}
*/
if ( opt_tfile ) {
result = load_srecfile(tfilename);
result = read_srecfile(tfilename);
if ( result ) {
fprintf(stderr, APPNAME": failed to load srec file, terminating\n");
fprintf(stderr, APPNAME": failed to read srec file, terminating\n");
return result;
}
}
@ -447,10 +527,6 @@ int main ( int argc, char **argv )
#if 0
/* Read on card PDA */
if ( (opt_tfile || opt_dumppda) && !opt_newpda ) {
if (load_cardpda()) {
fprintf(stderr,"loac_cardpda failed, exiting.\n");
exit(1);
}
}
/* Display the PDA */
if ( opt_dumppda ) {
@ -475,20 +551,47 @@ int main ( int argc, char **argv )
* 0 - success
* ~0 - failure (probably an errno)
----------------------------------------------------------------*/
void print_all_pdrs(void)
void print_all_pdrs(pda_t *pda)
{
int i;
int j;
printf("PDA from card %s:\n", devname);
printf( "idx code len data\n"
"---------------------------------------------------\n");
/* 000 0x0000 000 0000 0000 0000 0000... */
for ( i = 0; i < ncardpdrec; i++) {
printf("%03d 0x%04x %03d ", i,
cardpdrec[i].code,
cardpdrec[i].len);
for ( j = 0; j < cardpdrec[i].len; j++) {
printf("%04x ", ((UINT16*)(cardpdrec[i].data))[j]);
int i;
int j;
UINT16 *datap;
UINT8 *offp;
int end;
int nwords;
printf("Current PDA:\n");
printf( " offset len code data\n"
" ---------------------------------------------------\n");
/* 00000000 000 0x0000 0000 0000 0000 0000 0000.... */
/* 0000 0000 0000 0000 0000.... */
for ( i = 0; i < pda->nrec; i++) {
offp = (UINT8*)(pda->rec[i]);
printf(" %08d %03d 0x%04x ",
offp - pda->buf,
hfa384x2host_16(pda->rec[i]->len),
hfa384x2host_16(pda->rec[i]->code));
datap = (UINT16*)&(pda->rec[i]->data.end_of_pda);
nwords = hfa384x2host_16(pda->rec[i]->len) - 1;
for ( j = 0; j < nwords; j++) {
printf("%04x ", datap[j] );
if ( (j % 8) == 7 && j < nwords - 1 ) {
printf("\n ");
}
}
printf("\n");
}
if (opt_verbose) {
printf("Raw PDA:\n");
datap = (UINT16*)pda->buf;
end = (((UINT8*)pda->rec[pda->nrec - 1]) - pda->buf + 6) / 2;
printf(" ");
for ( i = 0; i < end; i++ ) {
printf("%04x ", datap[i]);
if ( i % 8 == 7 ) {
printf("\n ");
}
}
printf("\n");
}
@ -496,11 +599,26 @@ void print_all_pdrs(void)
}
/*----------------------------------------------------------------
* load_cardpda
* read_filepda
*
* Sends the command for the driver to read the pda from the card
* named in the device variable. Upon success, the card pda is
* stored in the "cardpda" variables.
* Reads a collection of PDRs from a file and merges them into the
* current PDA data set maintained within this program. The
* PDA data set may be empty or not.
*
* ASSUMED FILE FORMAT:
* pdrline := <sep><hexnum><pdrline>[<sep>]
* hexnum := [0x][[:hexdigit:]]{1-4}
* sep := [,[:space:]][[:space:]]*
* COMMENTS:
* ANY DETECTED CHARACTER that doesn't match
* [[:space:][:hexdigit:],x] indicates the start of a comment
* that extends to EOL. Note the 'x', it never starts an element
* so we really don't have to worry about it.
* REMOVE RECORDS:
* PDR items in the file that have a length of 1 indicate that
* the given PDR should be removed from the PDA. If that
* same item appears later in the file (or in a subsequent
* file) then it will be added again.
*
* Arguments: none
*
@ -508,7 +626,151 @@ void print_all_pdrs(void)
* 0 - success
* ~0 - failure (probably an errno)
----------------------------------------------------------------*/
int load_cardpda(void)
int read_filepda(pda_t *pda, char *pdrfname)
{
int result = 0;
FILE *pdrfile;
UINT16 pdword[HFA384x_PDA_LEN_MAX / sizeof(UINT16)];
UINT nwords = 0;
char linebuf[PDAFILE_LINE_MAX];
char *currp = NULL;
char *nextp = NULL;
regex_t regex;
regmatch_t regmatch;
char ebuf[100];
int i = 0;
int j = 0;
UINT8 *delpdastart;
UINT8 *mvpdastart;
UINT16 pdrlen;
UINT16 pdrcode;
UINT mvlen;
/* Open the file */
pdrfile = fopen(pdrfname, "r");
if ( pdrfile == NULL ) {
result=errno;
perror(APPNAME);
return result;
}
printf("Processing PDR file: %s\n", pdrfname);
/* Read all the words, skipping over the comments etc. */
memset(linebuf, 0, PDAFILE_LINE_MAX);
result = regcomp( &regex, "[,[:blank:]][[:blank:]]*", 0);
if ( result != 0 ) {
regerror( result, &regex, ebuf, sizeof(ebuf));
fprintf(stderr, APPNAME": failed to compile pda regexp err=%s.\n", ebuf);
exit(1);
}
while ( fgets(linebuf, PDAFILE_LINE_MAX, pdrfile) != NULL) {
currp = linebuf;
nextp = NULL;
pdword[nwords] = strtoul( currp, &nextp, 16);
if ( currp == nextp ) { /* is there noting valid? */
continue;
} else {
pdword[nwords] = host2hfa384x_16(pdword[nwords]);
nwords++;
currp = nextp;
}
while ( regexec(&regex, currp, 1, &regmatch, 0) == 0 ) {
currp += regmatch.rm_eo;
if ( !isxdigit(*currp) ) {
/* Assume comment and move to next line */
memset(linebuf, 0, PDAFILE_LINE_MAX);
break;
}
pdword[nwords] = strtoul( currp, &nextp, 16);
pdword[nwords] = host2hfa384x_16(pdword[nwords]);
/* printf("pdword=%04x currp=\"%s\"\n", pdword[nwords], currp); */
nwords++;
currp = nextp;
}
memset(linebuf, 0, PDAFILE_LINE_MAX);
}
/* Now, merge into the pda */
/* note that all the words are in hfa384x order */
i = 0;
while ( i < nwords ) { /* For each PDR in the new list */
pdrlen = hfa384x2host_16(pdword[i]); /* in words */
pdrcode = hfa384x2host_16(pdword[i+1]);
for ( j = 0; j < pda->nrec; j++) { /* Find matching code in PDA */
if ( pdrcode == hfa384x2host_16(pda->rec[j]->code) ) {
break;
}
}
if ( pdrlen == 1 && j < pda->nrec ) { /* Remove the pdr from the PDA */
if (opt_verbose) {
printf(" Removing PDR: code=%04x, len=%d\n",
pdrcode, pdrlen);
}
delpdastart = (UINT8*)(pda->rec[j]);
mvpdastart = delpdastart +
((hfa384x2host_16(pda->rec[j]->len) + 1) *
sizeof(UINT16));
mvlen = HFA384x_PDA_LEN_MAX - (mvpdastart - pda->buf);
memmove( delpdastart, mvpdastart, mvlen);
pda->nrec = 0;
makepdrlist(pda);
} else if ( j < pda->nrec ) { /* Replace the pdr in the PDA */
if (opt_verbose) {
printf(" Replacing PDR: code=%04x, len=%d\n",
pdrcode, pdrlen);
}
if ( pdrlen == hfa384x2host_16(pda->rec[j]->len) ) {
/* just overwrite */
memcpy( pda->rec[j],
&(pdword[i]),
(pdrlen + 1)*sizeof(UINT16));
} else {
fprintf( stderr, APPNAME
": replacing pdrs where newlen!=oldlen not "
"supported.\n");
exit(1);
}
} else { /* Add the pdr to the PDA */
UINT8 *endp = (UINT8*)(pda->rec[pda->nrec - 1]);
if (opt_verbose) {
printf(" Adding PDR: code=%04x, len=%d\n",
pdrcode, pdrlen);
}
/* overwrite the existing end record and add a new one */
memcpy( endp, &(pdword[i]), (pdrlen + 1)*sizeof(UINT16));
pda->rec[pda->nrec] = (hfa384x_pdrec_t*)
(endp +
((pdrlen+1) * sizeof(UINT16)));
pda->rec[pda->nrec]->len = host2hfa384x_16(2);
pda->rec[pda->nrec]->code = host2hfa384x_16(HFA384x_PDR_END_OF_PDA);
pda->rec[pda->nrec]->data.end_of_pda.crc = 0;
pda->nrec++;
}
i += pdrlen + 1;
}
return result;
}
/*----------------------------------------------------------------
* read_cardpda
*
* Sends the command for the driver to read the pda from the card
* named in the device variable. Upon success, the card pda is
* stored in the "cardpda" variables. Note that the pda structure
* is considered 'well formed' after this function. That means
* that the nrecs is valid, the rec array has been set up, and there's
* a valid PDAEND record in the raw PDA data.
*
* Arguments: none
*
* Returns:
* 0 - success
* ~0 - failure (probably an errno)
----------------------------------------------------------------*/
int read_cardpda(pda_t *pda, char *dev)
{
int result = 0;
p80211msg_p2req_readpda_t msg;
@ -516,7 +778,7 @@ int load_cardpda(void)
/* set up the msg */
msg.msgcode = DIDmsg_p2req_readpda;
msg.msglen = sizeof(msg);
strcpy(msg.devname, devname);
strcpy(msg.devname, dev);
msg.pda.did = DIDmsg_p2req_readpda_pda;
msg.pda.len = HFA384x_PDA_LEN_MAX;
msg.pda.status = P80211ENUM_msgitem_status_no_value;
@ -525,11 +787,11 @@ int load_cardpda(void)
msg.resultcode.status = P80211ENUM_msgitem_status_no_value;
if ( do_ioctl((p80211msg_t*)&msg) != 0 ) {
/* do_ioctl prints an erro if appropriate */
/* do_ioctl prints an errno if appropriate */
result = -1;
} else if ( msg.resultcode.data == P80211ENUM_resultcode_success ) {
memcpy(cardpda, msg.pda.data, HFA384x_PDA_LEN_MAX);
result = makepdrlist(cardpda, cardpdrec, &ncardpdrec);
memcpy(pda->buf, msg.pda.data, HFA384x_PDA_LEN_MAX);
result = makepdrlist(pda);
}
return result;
}
@ -554,53 +816,35 @@ int load_cardpda(void)
* 0 - success
* ~0 - failure (probably an errno)
----------------------------------------------------------------*/
int makepdrlist( UINT8 *pda, hfa384x_pdrec_t *pdrec, UINT *nrec)
int makepdrlist( pda_t *pda)
{
int result = 0;
UINT16 *pda16 = (UINT16*)pda;
UINT16 *pda16 = (UINT16*)pda->buf;
int curroff; /* in 'words' */
*nrec = 0;
pda->nrec = 0;
curroff = 0;
while ( hfa384x2host_16(pda16[curroff + 1]) != HFA384x_PDR_END_OF_PDA){
pdrec[*nrec].len = hfa384x2host_16(pda16[curroff]);
pdrec[*nrec].code = hfa384x2host_16(pda16[curroff+1]);
pdrec[*nrec].data = (union pdr*)
(pda + (curroff*2) + (2*sizeof(UINT16)));
(*nrec)++;
while ( curroff < (HFA384x_PDA_LEN_MAX / 2) &&
hfa384x2host_16(pda16[curroff + 1]) != HFA384x_PDR_END_OF_PDA ) {
pda->rec[pda->nrec] = (hfa384x_pdrec_t*)&(pda16[curroff]);
(pda->nrec)++;
curroff += hfa384x2host_16(pda16[curroff]) + 1;
}
if ( curroff >= (HFA384x_PDA_LEN_MAX / 2) ) {
fprintf(stderr, APPNAME
": no end record found in PDR data, exiting.\n");
exit(1);
}
if (hfa384x2host_16(pda16[curroff + 1]) == HFA384x_PDR_END_OF_PDA ) {
pda->rec[pda->nrec] = (hfa384x_pdrec_t*)&(pda16[curroff]);
(pda->nrec)++;
}
return result;
}
/*----------------------------------------------------------------
* load_pdrfile
*
* Reads the given pdr file and fills the array specified.
* This function can be called repeatedly (once for each of a set
* of files). This function performs
* no validation of the data except for the grossest of record
* line format checks. Don't forget that these will be DOS files...
* CR/LF at the end of each line.
*
* Arguments:
* fname name of the pdr file to load
* isnew boolean indicating which arrays to load pdrs into
*
* Returns:
* 0 - success
* ~0 - failure (probably an errno)
----------------------------------------------------------------*/
int load_pdrfile( char *fname, int isnew)
{
int result = 0;
return result;
}
/*----------------------------------------------------------------
* load_srecfile
* read_srecfile
*
* Reads the given srecord file and loads the records into the
* s3xxx arrays. This function can be called repeatedly (once for
@ -650,7 +894,7 @@ int load_pdrfile( char *fname, int isnew)
* 0 - success
* ~0 - failure (probably an errno)
----------------------------------------------------------------*/
int load_srecfile(char *fname)
int read_srecfile(char *fname)
{
FILE* f;
int result = 0;
@ -681,7 +925,7 @@ int load_srecfile(char *fname)
buf[12] = '\0';
startaddr = strtoul(buf+4, NULL, 16);
if (opt_verbose) {
printf( "S7 start addr, line=%d "
printf( " S7 start addr, line=%d "
" addr=0x%08lx\n",
line,
startaddr);
@ -723,7 +967,7 @@ int load_srecfile(char *fname)
s3plug[ns3plug].len = __swab32(s3plug[ns3plug].len);
if (opt_verbose) {
printf( "S3 plugrec, line=%d "
printf( " S3 plugrec, line=%d "
"itemcode=0x%04lx addr=0x%08lx len=%ld\n",
line,
s3plug[ns3plug].itemcode,
@ -750,7 +994,7 @@ int load_srecfile(char *fname)
s3crc[ns3crc].dowrite =__swab32(s3crc[ns3crc].dowrite);
if (opt_verbose) {
printf( "S3 crcrec, line=%d "
printf( " S3 crcrec, line=%d "
"addr=0x%08lx len=%ld write=0x%08x\n",
line,
s3crc[ns3crc].address,
@ -778,7 +1022,7 @@ int load_srecfile(char *fname)
tmpinfo[i] = __swab16(tmpinfo[i]);
}
if (opt_verbose) {
printf( "S3 inforec, line=%d "
printf( " S3 inforec, line=%d "
"len=0x%04x type=0x%04x\n",
line,
s3info[ns3info].len,
@ -794,7 +1038,7 @@ int load_srecfile(char *fname)
break;
default: /* Data record */
if (opt_verbose) {
printf("S3 datarec, line=%04d addr=0x%08lx datalen=%03ld\n",
printf(" S3 datarec, line=%04d addr=0x%08lx datalen=%03ld\n",
line, tmprec.address, tmprec.datalen);
}
s3data[ns3data].address = tmprec.address;
@ -872,24 +1116,66 @@ int do_ioctl( p80211msg_t *msg )
void usage(void)
{
printf("\n%s : 802.11 frame dump utility\n", appname);
printf(" usage: %s [option ...] interface\n\n", appname);
printf(" where valid options are:\n");
printf(" usage: %s [option ...] devname\n\n", appname);
printf(" where valid options are:\n\n"
" options: (pnemonics in parentheses)\n"
" GENERAL OPTIONS:\n"
" -v (verbose) Show more status info during operation.\n"
" -V (Version) Show version and exit\n"
" -n (nowrite) Do all processing, including card PDA read, \n"
" but do not write to card.\n"
" -d (debug) Do all processing, excluding card PDA read, \n"
" but do not write to card. A valid interface \n"
" name is _not_ required for this mode.\n"
" -s (status) Show CIS, PDA from card and exit\n"
"\n"
" IMAGEFILE OPTIONS:\n"
" -r <file> (ram) Load SREC file to card RAM. This option may\n"
" be specified multiple times.\n"
" -f <file> (flash) Load SREC file to card FLASH. This option may\n"
" be specified multiple times.\n"
"\n"
" PDA OPTIONS:\n"
" -a <file> (addpdr) Add the PDRs from file to the PDA from card. This\n"
" option may be specified multiple times.\n"
" -p <file> (pda) Replace the card PDA with the contents of file.\n"
" -m <addr> (macaddr) Overwrite the MAC address PDR with the given \n"
" value. <addr> ::= xx:xx:xx:xx:xx:xx, where \n"
" xx is a two digit hex number.\n"
" -S <str> (Sernum) Overwrite the serial number PDR with the given\n"
" string. String must be <= 12 characters, any\n"
" extra will be truncated.\n"
"\n"
" argument:\n"
" devname Linux device name (e.g. eth0, wlan0)\n"
"\n"
"EXAMPLES:\n"
" Review card status:\n"
" prism2dl -s wlan0\n"
"\n"
" Load a new PDA:\n"
" prism2dl -p pdafile.txt wlan0\n"
" or\n"
" prism2dl -p pdafile.txt -a pda1.txt -a pda2.txt wlan0\n"
"\n"
" Note that the f/w images will most likely contain bogus plug info after\n"
" rewriting the PDA by itself. It is generally recommended to reload the \n"
" primage and secondary images at the same time as modifying the PDA.\n"
"\n"
" Load a FLASH image _and_ PDA:\n"
" prism2dl -p pdafile.txt -f CIS.hex -f primary.hex -f secondary.hex wlan0\n"
"\n"
" Load a RAM image:\n"
" prism2dl -a pda1.txt -r tertiary.hex\n"
"\n"
"Note: PDA records are additive starting with the records from the card\n"
" OR the records from the -p specified file. -a specified file(s)\n"
" overwrite, append, or remove records one at a time. If multiple\n"
" files are specified using the -a option, the files are processed\n"
" from left to right. This implies that a record removed from the\n"
" current working PDA may then be added again by a record that\n"
" appears after the \"remove\" record in the file set.\n\n");
printf(" -s[n] default: show PDA from card\n");
printf(" n==1: show PDA from card\n");
printf(" n==2: show PDRs from file (see -a, -p).\n");
printf(" n==3: show combined PDR set from card and file.\n");
printf(" -t <file> tertiary image to load\n");
printf(" -a <file> file containing PDRs to add/overwrite PDRs on card.\n");
printf(" -p <file> file containing new PDA to overwrite PDA on card.\n");
printf(" -n show image and PDR processing, but do not load.\n");
printf(" -v verbose operation.\n");
printf(" -V display the program version and exit.\n\n");
printf(" Note: this program doesn't do a whole lot of cmdline argument validation\n");
printf(" so be careful when setting them.\n\n");
}