分类: LINUX
2010-03-08 15:38:53
close(sockfd6);
/***************************
*deleteIP
****************************/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
//#include
#include
#include
#include
#include
#include
#include
struct in6_ifreq
{
struct in6_addr ifr6_addr;
unsigned int ifr6_prefixlen;
unsigned int ifr6_ifindex;
};
int main(int argc, char* argv[] )
{
int sockfd6;
struct ifreq ifr;
struct in6_ifreq ifreq6;
int ret;
sockfd6 = socket(AF_INET6, SOCK_DGRAM, 0);
//
strcpy(ifr.ifr_name, "eth1");//:)
ret = ioctl(sockfd6, SIOCGIFINDEX, &ifr);
if(ret <0)
{
printf("%d\n",__LINE__);
}
//
inet_pton(AF_INET6, argv[1], &ifreq6.ifr6_addr);
ifreq6.ifr6_prefixlen = 64;//:)
ifreq6.ifr6_ifindex = ifr.ifr_ifindex;
ret = ioctl(sockfd6,SIOCDIFADDR, &ifreq6);
if(ret <0)
{
perror("deletip: ");
printf("%d\n",__LINE__);
}
//
close(sockfd6);
}