made a minor change in making a new socket device
This commit is contained in:
parent
e8d5784756
commit
60cff400ac
@ -67,7 +67,7 @@ static void* mmgr_alloc (stio_mmgr_t* mmgr, stio_size_t size)
|
|||||||
{
|
{
|
||||||
void* x;
|
void* x;
|
||||||
|
|
||||||
if (((mmgr_stat_t*)mmgr->ctx)->total_count > 100)
|
if (((mmgr_stat_t*)mmgr->ctx)->total_count > 300)
|
||||||
{
|
{
|
||||||
printf ("CRITICAL ERROR ---> too many heap chunks...\n");
|
printf ("CRITICAL ERROR ---> too many heap chunks...\n");
|
||||||
return STIO_NULL;
|
return STIO_NULL;
|
||||||
@ -451,6 +451,13 @@ static int icmp_sck_on_read (stio_dev_sck_t* dev, const void* data, stio_iolen_t
|
|||||||
{
|
{
|
||||||
/* TODO: consider IP options... */
|
/* TODO: consider IP options... */
|
||||||
iphdr = (stio_iphdr_t*)data;
|
iphdr = (stio_iphdr_t*)data;
|
||||||
|
|
||||||
|
if (iphdr->ihl * 4 + STIO_SIZEOF(*icmphdr) > dlen)
|
||||||
|
{
|
||||||
|
printf ("INVALID ICMP PACKET.. WRONG IHL...%d\n", (int)iphdr->ihl * 4);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
icmphdr = (stio_icmphdr_t*)((stio_uint8_t*)data + (iphdr->ihl * 4));
|
icmphdr = (stio_icmphdr_t*)((stio_uint8_t*)data + (iphdr->ihl * 4));
|
||||||
|
|
||||||
/* TODO: check srcaddr against target */
|
/* TODO: check srcaddr against target */
|
||||||
@ -466,6 +473,7 @@ static int icmp_sck_on_read (stio_dev_sck_t* dev, const void* data, stio_iolen_t
|
|||||||
printf ("GARBAGE ICMP PACKET...LEN %d SEQ %d,%d\n", (int)dlen, (int)icmpxtn->icmp_seq, (int)stio_ntoh16(icmphdr->u.echo.seq));
|
printf ("GARBAGE ICMP PACKET...LEN %d SEQ %d,%d\n", (int)dlen, (int)icmpxtn->icmp_seq, (int)stio_ntoh16(icmphdr->u.echo.seq));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,7 +324,8 @@ static struct sck_type_map_t sck_type_map[] =
|
|||||||
/* STIO_DEV_SCK_DGRAM */
|
/* STIO_DEV_SCK_DGRAM */
|
||||||
{ AF_LINK, SOCK_DGRAM, STIO_CONST_HTON16(STIO_ETHHDR_PROTO_ARP), 0 },
|
{ AF_LINK, SOCK_DGRAM, STIO_CONST_HTON16(STIO_ETHHDR_PROTO_ARP), 0 },
|
||||||
#else
|
#else
|
||||||
# error UNSUPPORTED DATA LINK ADDRESS
|
{ -1, 0, 0, 0 },
|
||||||
|
{ -1, 0, 0, 0 },
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* STIO_DEV_SCK_ICMP4 - IP protocol field is 1 byte only. no byte order conversion is needed */
|
/* STIO_DEV_SCK_ICMP4 - IP protocol field is 1 byte only. no byte order conversion is needed */
|
||||||
@ -414,6 +415,12 @@ static int dev_sck_make (stio_dev_t* dev, void* ctx)
|
|||||||
|
|
||||||
STIO_ASSERT (arg->type >= 0 && arg->type < STIO_COUNTOF(sck_type_map));
|
STIO_ASSERT (arg->type >= 0 && arg->type < STIO_COUNTOF(sck_type_map));
|
||||||
|
|
||||||
|
if (sck_type_map[arg->type].domain <= -1)
|
||||||
|
{
|
||||||
|
dev->stio->errnum = STIO_ENOIMPL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
rdev->sck = stio_openasyncsck (dev->stio, sck_type_map[arg->type].domain, sck_type_map[arg->type].type, sck_type_map[arg->type].proto);
|
rdev->sck = stio_openasyncsck (dev->stio, sck_type_map[arg->type].domain, sck_type_map[arg->type].type, sck_type_map[arg->type].proto);
|
||||||
if (rdev->sck == STIO_SCKHND_INVALID) goto oops;
|
if (rdev->sck == STIO_SCKHND_INVALID) goto oops;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user