So far my understanding of achieveing this is using NET_FUNCS:
typedef struct net_funcs{
STATUS (*start) (void*); /* driver’s start func */
STATUS (*stop) (void*); /* driver’s stop func */
STATUS (*unload) (void*); /* driver’s unload func */
int (*ioctl) (void*, int, caddr_t); /* driver’s ioctl func */
STATUS (*send) (void* , M_BLK_ID); /* driver’s send func */
STATUS (*mCastAddrAdd) (void*, char*); /* driver’s mcast add func */
STATUS (*mCastAddrDel) (void*, char*); /* driver’s mcast delete func */
STATUS (*mCastAddrGet) (void*, MULTI_TABLE*);/* driver’s mcast get func */
STATUS (*pollSend) (void*, M_BLK_ID); /* driver’s poll send func */
STATUS (*pollRcv) (void*, M_BLK_ID); /* driver’s poll receive func */
STATUS (*addressForm) (M_BLK_ID, M_BLK_ID, M_BLK_ID);/* driver’s addr formation func */
STATUS (*packetDataGet) (M_BLK_ID, M_BLK_ID);/* driver’s pkt data get func */
STATUS (*addrGet) (M_BLK_ID, M_BLK_ID, M_BLK_ID, M_BLK_ID, M_BLK_ID);/* driver’s pkt addr get func */} NET_FUNCS;
I have a pointer to a M_BLK struct called pMblk(of type M_BLK_ID = * M_BLK) that I believe holds the information to our Ethernet package(header and data), this is where my understanding starts to fade, I'm not 100% sure this is where our whole package is stored or is just part of a whole(cluster). Specifically using adderGet (using a same function but for our case its endEtherPacketAddrGet), The way I understand this function is that if you put your structure with all the information from the packet into the param 1, and followed with other pointers I created param 2: pSrc, param 3: pDest, param 4: pESrc, param 5: pEDst, I seems like it would make sense that the information for the senders IP address would be somewhere withing the pSrc Struct. This is where I've really struggled in printing out the information with in this object as a log message, For now I just want to print out the sender IP address, later more info but I havent been able to print anything coherent. I've tried:
printf("pSrc->mData: %d", pSrc->mData); // not actually using print just for the sake of the example
printf("pSrc->mData: %c", pSrc->mData); // not actually using print just for the sake of the example
yielded blank or not useful data, also:
printf("pSrc->mData: %d", &pSrc->mData); // not actually using print just for the sake of the example
printf("pSrc->mData: %c", &pSrc->mData); // not actually using print just for the sake of the example
These are not the only things I've tried I just want to give a feeling of where I am and what I am trying to do, that being said is there a fundamental understanding that I'm off on here because I feel as though I'm close? Is there a different approach to reaching this information, or is it stored in a different member of the structure? Any guidance on this would be greatly appreciated!
solved this using pointer arithmetic:
srcAddr[0] = *(mBlk->m_data + 6);
srcAddr[1] = *(mBlk->m_data + 7);
srcAddr[2] = *(mBlk->m_data + 8);
srcAddr[3] = *(mBlk->m_data + 9);
srcAddr[4] = *(mBlk->m_data + 10);
srcAddr[5] = *(mBlk->m_data + 11);
printf("Source Address: %02x:%02x:%02x:%02x:%02x:%02x\n", srcAddr[0], srcAddr[1], srcAddr[2], srcAddr[3], srcAddr[4], srcAddr[5]);
m_data is a typedef for mBlk->mBlkHdr.mData