Tags » Ipv6

Professional Resume of Neil D. Morris

Neil D. Morris

  • Greater Denver Area, US CO
  • +1(970)449-2800
  • neil@neildmorris.me

INFORMATION SYSTEMS EXPERT : TECHNOLOGY EXECUTIVE : SERVANT LEADER

Summary

Highly motivated, passionate technology leader with a servant-leader approach, specializing in infrastructure and communications systems, enterprise systems, software development, security, and architectural principles. 1,054 more words

Agile Development

IoT Presentation for Auburn ACM Student Chapter

Last Tuesday (3/17/15), I gave a presentation for the Auburn chapter of ACM. As a believer in Open Source and Open Knowledge, here is my presentation and my slides. 50 more words

IoT

CHECKING IPV6 ADDRESS IS TENTATIVE AND DADFAILED


$ip -6 addr show dev eth0
    ...
    inet6 100:100::100:100/64 scope global tentative dadfailed
       valid_lft forever preferred_lft forever
    ...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <ifaddrs.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <signal.h>
#include <net/route.h>
#include <linux/rtnetlink.h>
#include <unistd.h>

/* Compile: gcc -g -o dad_test dad_test.c */

void using_getifaddrs()
{
    struct ifaddrs *p_saddrs,*p_taddrs;

    getifaddrs(&p_saddrs);
    p_taddrs = p_saddrs;

    while (p_taddrs)
    {
        if (p_taddrs->ifa_addr && (p_taddrs->ifa_addr->sa_family == AF_INET6))
        {
            struct sockaddr_in6 *ps_addr = (struct sockaddr_in6 *)(p_taddrs->ifa_addr);
            char c_addr = {0};
            inet_ntop(AF_INET6, &ps_addr->sin6_addr, c_addr, INET6_ADDRSTRLEN);
            if(0 == strcasecmp (c_addr, "100:100::100:100"))
            {
                printf("0x%x 0x%x 0x%x\n",IFA_F_DADFAILED, IFA_F_TENTATIVE, p_taddrs->ifa_flags);
                if(p_taddrs->ifa_flags & IFA_F_DADFAILED)
                {
                    printf("100:100::100:100 is dadfailed\n");
                }
                if(p_taddrs->ifa_flags & IFA_F_TENTATIVE)
                {
                    printf("100:100::100:100 is tentative\n");
                }

            }

        }
        p_taddrs = p_taddrs->ifa_next;
    }

    freeifaddrs(p_saddrs);
}

void parsemsg(struct nlmsghdr *p_nlmsghdr, int n_nlmsglen)
{

    for(; NLMSG_OK(p_nlmsghdr, n_nlmsglen); p_nlmsghdr = NLMSG_NEXT(p_nlmsghdr, n_nlmsglen))
    {
        unsigned char b_addr = 0;
        struct ifaddrmsg *p_ifaddrmsg;
        struct rtattr *p_rtattr;
        int n_ifaddrmsglen;

        p_ifaddrmsg = (struct ifaddrmsg *) NLMSG_DATA(p_nlmsghdr);
        p_rtattr = (struct rtattr *) IFA_RTA(p_ifaddrmsg);
        n_ifaddrmsglen = IFA_PAYLOAD(p_nlmsghdr);

        for(;RTA_OK(p_rtattr, n_ifaddrmsglen); p_rtattr = RTA_NEXT(p_rtattr, n_ifaddrmsglen)) {

            switch(p_rtattr->rta_type)
            {
                case IFA_ADDRESS:
                    {
                        char c_addr = {0};
                        inet_ntop(AF_INET6, RTA_DATA(p_rtattr), c_addr, INET6_ADDRSTRLEN);
                        if(0 == strcasecmp (c_addr, "100:100::100:100"))
                        {
                            if(p_ifaddrmsg->ifa_family == AF_INET6)
                            {
                                b_addr = 1;
                            }
                        }
                        break;
                    }
                case IFA_LOCAL:
                case IFA_BROADCAST:
                case IFA_ANYCAST:
                case IFA_MULTICAST:
                case IFA_LABEL:
                case IFA_CACHEINFO:
                default:
                    break;
            }
        }

        if(b_addr == 1)
        {
            if (p_ifaddrmsg->ifa_flags & IFA_F_TENTATIVE)
            {
                printf ("Duplicate Address Detection (DAD) is running, ordinary traffic not allowed yet\n");
            }
            if (p_ifaddrmsg->ifa_flags & IFA_F_DADFAILED)
            {
                printf ("Duplicate Address Detection (DAD) failed\n");
            }
            if ((p_ifaddrmsg->ifa_flags & IFA_F_PERMANENT) &&
                (!(p_ifaddrmsg->ifa_flags & IFA_F_TENTATIVE)) &&
                (!(p_ifaddrmsg->ifa_flags & IFA_F_DADFAILED)))
            {
                printf ("Duplicate Address Detection (DAD) passed Address Permanent\n");
            }
        }
    }

    return;
}

void recvaddrs(int n_fd, __u32 n_seq, __u32 n_pid)
{
    char c_buffer = {0};
    struct nlmsghdr *p_nlmsghdr;
    int n_nlmsglen;

    while(1)
    {
        int n_ret;

        bzero(c_buffer, sizeof(c_buffer));
        n_ret = recv(n_fd, c_buffer, sizeof(c_buffer), 0);
        if(n_ret < 0)
        {
            perror ("recv(): ");
            return;
        }

        p_nlmsghdr = (struct nlmsghdr *) c_buffer;
        n_nlmsglen = n_ret;

        if (n_nlmsglen < sizeof (struct nlmsghdr))
        {
            printf ("received an uncomplete netlink packet\n");
            return;
        }
        if((p_nlmsghdr->nlmsg_seq != n_seq) || (p_nlmsghdr->nlmsg_pid != n_pid))
        {
            continue;
        }
        if (p_nlmsghdr->nlmsg_type == NLMSG_DONE)
        {
            break;
        }

        parsemsg(p_nlmsghdr, n_nlmsglen);
    }

}

void using_netlinksocket()
{
    int n_fd;
    n_fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);

    if (n_fd < 0)
    {
        return;
    }
    struct sockaddr_nl s_nladdr;
    memset(&s_nladdr, 0, sizeof(s_nladdr));
    s_nladdr.nl_family = AF_NETLINK;

    int n_seq = 0;
    struct
    {
        struct nlmsghdr m_nlmsghdr;
        struct rtgenmsg m_rtgenmsg;
    } s_req;

    s_req.m_nlmsghdr.nlmsg_len = sizeof(s_req);
    s_req.m_nlmsghdr.nlmsg_type = RTM_GETADDR;
    s_req.m_nlmsghdr.nlmsg_flags = NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST|NLM_F_DUMP;
    s_req.m_nlmsghdr.nlmsg_pid = getpid();
    s_req.m_nlmsghdr.nlmsg_seq = ++n_seq;
    s_req.m_rtgenmsg.rtgen_family = AF_UNSPEC;

    if (sendto(n_fd, (void*)&s_req, sizeof(s_req), 0, (struct sockaddr*)&s_nladdr, sizeof(s_nladdr)) < 0) {
        close(n_fd);
        return;
    }

    recvaddrs(n_fd, n_seq, getpid());
    close(n_fd);
    return;
}

int main()
{
    using_getifaddrs();
    using_netlinksocket();

    return 0;

}
C Programming

IPv6 Support in Microsoft Products and Services, should I disable IPv6 ? No...

IPv6 Support in Microsoft Products and Services (table):

https://technet.microsoft.com/en-us/network/hh994905.aspx

Microsoft is recommending to keep IPv6 enabled. You can read more about it in this article, which I highly suggest reading it: 381 more words

System And Network Admins

IPv6 Enabled On servers

Backy LLC is pleased to announce that we have enabled IPv6 on the following servers

Serv3

Serv4

Serv6

If you wish to obtain an IPv6 IP address for your website and are an existing customer please open a support ticket by visiting our customer portal at… 31 more words

Web Hosting

Setting up dual stack on mikrotik RB750G

About a year ago I sat in on a session all about IPv6. This was right around the time everyone was afraid the internet was going to collapse in on itself due to the lack of IPv4 address left. 273 more words

Ipv6

IPv6 - changë thë NËT

In the age of fast growing technology, it becomes imperative to keep a track of the system you use & should delve upon. And so, I bring you my working knowledge on the format of IPv6 & its many aspects. 732 more words

Advantages Of IPv6