Iam looking for a simple route add program

my current routeadd program ends up :

socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 3
ioctl(3, SIOCADDRT, 0xbfd703a0) = -1 ENETUNREACH (Network is
unreachable)


==============================================
int kernel_add_route (struct prefix_ipv4 *dest, struct in_addr *gate,
struct in_addr *mask ,int flags, char* device)
//, int rt_mtu, int rt_window, int rt_irtt)
{
int ret;
int sock;
struct rtentry rtentry;
struct sockaddr_in sin_dest, sin_mask, sin_gate;
// struct sockaddr sin_dest, sin_mask, sin_gate;


memset (&rtentry, 0, sizeof (struct rtentry));

/*
memset (&sin_dest, 0, sizeof (struct sockaddr_in));
sin_dest.sin_family = AF_INET;
// sin_dest.sin_len = sizeof (struct sockaddr_in);
sin_dest.sin_addr = *dest;
*/
/* Make destination. */
memset (&sin_dest, 0, sizeof (struct sockaddr_in));
sin_dest.sin_family = AF_INET;
sin_dest.sin_addr = dest->prefix;

if (gate)
{
memset (&sin_gate, 0, sizeof (struct sockaddr_in));
sin_gate.sin_family = AF_INET;
// sin_gate.sin_len = sizeof (struct sockaddr_in);
sin_gate.sin_addr = *gate;
}


memset (&sin_mask, 0, sizeof (struct sockaddr_in));
sin_mask.sin_family = AF_INET;
// sin_mask.sin_len = sizeof (struct sockaddr_in);
masklen2ip (dest->prefixlen, &sin_mask.sin_addr);
// sin_mask.sin_addr = *mask;

// Set destination address, mask and gateway.
memcpy (&rtentry.rt_dst, &sin_dest, sizeof (struct sockaddr_in));
if (gate)
memcpy (&rtentry.rt_gateway, &sin_gate, sizeof (struct
sockaddr_in));

memcpy (&rtentry.rt_genmask, &sin_mask, sizeof (struct sockaddr_in));


/* Routing entry flag set. */
if (dest->prefixlen == 32)
rtentry.rt_flags |= RTF_HOST;

if (gate && gate->s_addr != INADDR_ANY)
rtentry.rt_flags |= RTF_GATEWAY;

rtentry.rt_flags = RTF_UP | RTF_GATEWAY | RTF_HOST ;

rtentry.rt_dev = "eth1";

/* Additional flags */
rtentry.rt_flags |= flags;

/* Open socket for ioctl. */
sock = socket (AF_INET, SOCK_DGRAM, 0);
if (sock < 0)
{
printf ("can't make socket\n");
return -1;
}

/* Send message by ioctl(). */
ret = ioctl (sock, SIOCADDRT, &rtentry);
if (ret < 0)
{
switch (errno)
{
case EEXIST:
close (sock);
return -1;
break;
case ENETUNREACH:
close (sock);
return -2;
break;
case EPERM:
close (sock);
return -3;
break;
}

close (sock);
printf ("write : %s (%d)", strerror (errno), errno);
return 1;
}
close (sock);

return ret;
}


int main()
{

prefix_ipv4 _d;

_d.family = AF_INET;
_d.prefixlen = 32;


// Destination
strcpy(_Dest,"192.168.52.199");
int result = inet_aton(_Dest, &_d.prefix);
if ( result )
_d.prefix.s_addr = ntohl(_d.prefix.s_addr);


// Gateway
strcpy(_Gate, "192.168.52.197");
result = inet_aton(_Gate, &_gateAddr);
if ( result )
_gateAddr.s_addr = ntohl(_gateAddr.s_addr);


// Mask
strcpy(_Mask, "255.255.255.0");
result = inet_aton(_Mask, &_maskAddr);
if ( result )
_maskAddr.s_addr = ntohl(_maskAddr.s_addr);

kernel_add_route (&_d, &_gateAddr , &_maskAddr ,0, "eth1");
return 1;
}