Opinions?

Possibly move it into atm_calc_hec so that we can verify these crc's as well?

Add in code to check the vpi/vci?

static struct { int last_vpi, last_vci; } crc[16];
perhaps so that we remember the last crc for this vpi/vci pair with this
pti and clp?

Might want to expand the array to 256 to cover the GLP if we want to check
the CRCs as well.

Regards,

Tim.


Index: atm.c
===================================================================
RCS file: /cvsroot/speedtouch/speedtouch/src/atm.c,v
retrieving revision 1.6
diff -u -r1.6 atm.c
--- atm.c       21 Mar 2002 23:35:43 -0000      1.6
+++ atm.c       20 Sep 2002 12:05:54 -0000
@@ -49,6 +49,9 @@
 
 void atm_header_create(unsigned char *header, int vpi, int vci, int pti, int clp)
 {
+       /* We assume that vpi and vci are constant */
+    
+       static int crc[16] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
 
        /*
        * ATM UNI cell header
@@ -77,12 +80,11 @@
        header[1] =  (vpi << 4) | (vci >> 12);
        header[2] =  (vci & 0x00000ff0) >> 4;
        header[3] = ((vci & 0x0000000f) << 4) | (pti << 1) | clp;
-#ifdef DEBUG
-       header[4] =  atm_calc_hec(header);
-#else
-       header[4] = 0xec; /* Arbitrary constant */
-#endif
-       
+
+       if(crc[(pti<<1)|clp] == -1)
+               crc[(pti<<1)|clp] = atm_calc_hec(header);
+
+       header[4] = crc[(pti<<1)|clp];
 }
 
 /*
Index: crc.c
===================================================================
RCS file: /cvsroot/speedtouch/speedtouch/src/crc.c,v
retrieving revision 1.3
diff -u -r1.3 crc.c
--- crc.c       4 Dec 2001 18:11:23 -0000       1.3
+++ crc.c       20 Sep 2002 12:05:54 -0000
@@ -114,7 +114,6 @@
 * Precomputed ATM CRC8 lookup table
 ******************************************************************************/
 
-#ifdef DEBUG
 unsigned char hec_table[256]=
 {
 
@@ -152,7 +151,6 @@
        0xe6, 0xe1, 0xe8, 0xef, 0xfa, 0xfd, 0xf4, 0xf3
 
 };
-#endif
 
 /******************************************************************************
 * Functions
@@ -185,7 +183,6 @@
 
 }
 
-#ifdef DEBUG
 unsigned char atm_calc_hec(unsigned char *header)
 {
 
@@ -199,6 +196,5 @@
        return(hec^ATM_HEADER_COSET_LEADER);
 
 }
-#endif
 
 #endif
Index: crc.h
===================================================================
RCS file: /cvsroot/speedtouch/speedtouch/src/crc.h,v
retrieving revision 1.3
diff -u -r1.3 crc.h
--- crc.h       4 Dec 2001 18:11:23 -0000       1.3
+++ crc.h       20 Sep 2002 12:05:54 -0000
@@ -40,8 +40,6 @@
 ******************************************************************************/
 
 extern unsigned int  aal5_calc_crc(unsigned char *mem, int len, unsigned int initial);
-#ifdef DEBUG
 extern unsigned char atm_calc_hec(unsigned char *header);
-#endif
 
 #endif

-- 
God said, "div D = rho, div B = 0, curl E = - @B/@t, curl H = J + @D/@t," 
and there was light.

     http://tjw.hn.org/      http://www.locofungus.btinternet.co.uk/



Liste de diffusion modem ALCATEL SpeedTouch USB
Pour se désinscrire : mailto:[EMAIL PROTECTED]?subject=unsubscribe

        

Reply via email to