11 void Link_Send(int IfNum, const void *Src, const void *Dst, uint16_t Proto,
12 int BufCount, size_t BufLens[], const void *Bufs[])
14 size_t total_len = 6+6+2;
15 for( int i = 0; i < BufCount; i ++ )
16 total_len += BufLens[i];
17 uint8_t *data = malloc(total_len);
20 memcpy(pos, Dst, 6); pos += 6;
21 memcpy(pos, Src, 6); pos += 6;
22 *(uint16_t*)pos = htons(Proto); pos += 2;
24 for( int i = 0; i < BufCount; i ++ )
26 memcpy(pos, Bufs[i], BufLens[i]);
30 Net_Send(IfNum, total_len, data);
35 bool Link_Pkt_Check(size_t len, const void *data, size_t *ofs_out,
36 const void *Src, const void *Dst, uint16_t Proto)
38 const uint8_t *data8 = data;
39 TEST_ASSERT_REL(len, >=, 6+6+2);
41 if(Dst) TEST_ASSERT( memcmp(data8+0, Dst, 6) == 0 );
42 if(Src) TEST_ASSERT( memcmp(data8+6, Src, 6) == 0 );
44 TEST_ASSERT_REL( ntohs(*(uint16_t*)(data8+12)), ==, Proto );