Okay so I wasn;'t sure if where to get help since the first thread seem to go off on topics but I wanted to get help still so i tried simpliying the code to a test portion.
Code:
#include<stdio.h>
#include<stdlib.h>
#define TRUE 1
typedef unsigned char Uint8;
typedef unsigned int Uint32;
typedef struct Ethfrm_t Ethfrm_t;
typedef int (*FIPF)(Uint8 *, Uint32);
typedef struct FIPfrm_t
{struct FIP_Hdr* Hdr;
} __attribute__ ((packed))FIPfrm_t;
typedef struct FIP_Hdr
{
Uint32 Code:16;
Uint32 Resv1:8;
Uint32 Subcode:8;
Uint32 DescLen;
Uint32 DescList;
} FIP_Hdr;
FIPF FIPFunc[4][2];
int FIPDiscSolicit(Uint8 *DescListPtr, Uint32 DescListLen)
{
printf("hello your in DiscSol\n");
return (TRUE);
}
void FIPFuncInit(int i){
FIPFunc[0][0] = &FIPDiscSolicit;
}
FIP_Hdr * FIPHdrProcessing(FIP_Hdr *hdr)
{
Uint32 DescListLen;
Uint8 *DescListPtr;
DescListLen = (Uint32) hdr->DescLen;
DescListPtr = (Uint8*)&(hdr->DescList);
printf("testing subcode %d and %d \n",DescListLen,DescListPtr);
int status = (FIPFunc[(Uint32) hdr->Code-1] [(Uint32) hdr->Subcode-1])(DescListPtr, DescListLen);
return hdr;
}
unsigned char buffer[1500];
int main( void )
{
FIPfrm_t* FIPptr = malloc(sizeof(*FIPptr));
FIPptr = (struct FIPfrm_t *)(&buffer);
FIPptr->Hdr = (struct FIP_Hdr *)(&buffer[14]);
FIPptr->Hdr->Code = 1;
FIPptr->Hdr->Subcode =1;
FIPptr->Hdr = FIPHdrProcessing(FIPptr->Hdr);
return 0;
}
I keep getting seg faults when i call on array of function pointers im not really sure whats going on here it should work.