[rescue] Compile IRIX file

Horacio Gomez horaciojgomez at gmail.com
Mon Feb 8 12:37:18 CST 2010


I need to compile the following file for IRIX 6.5. Could somebody do it for
me? I don4t find the right libraries to do it.
Thanks in advance for your help.


#include <stdio.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/raw.h>
#include <net/if.h>
#include <net/soioctl.h>

main(int argc,char **argv)
{
        int cnt,ret,sock,a1,a2,a3,a4,a5,a6;
        struct ifreq ifdat;
        struct sockaddr_raw sr;

        if (argc<3)
        {
                printf("usage : %s <interface> <eaddr>\n",argv[0]);
                exit(1);
        }

        sock=socket(PF_RAW, SOCK_RAW, RAWPROTO_SNOOP);

        if (sock<0) {
                perror("socket:");
                exit(1);
        }

        strcpy(ifdat.ifr_name, argv[1]);
        ret=ioctl(sock, SIOCGIFADDR, &ifdat );
        if (ret<0)
        {
                printf("ret=%d\n", ret);
                perror("ioctl:");
                exit(1);
        }

        printf("Current address : %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n",
                ifdat.ifr_ifru.ifru_enaddr[2],
ifdat.ifr_ifru.ifru_enaddr[3],
                ifdat.ifr_ifru.ifru_enaddr[4],
ifdat.ifr_ifru.ifru_enaddr[5],
                ifdat.ifr_ifru.ifru_enaddr[6],
ifdat.ifr_ifru.ifru_enaddr[7]);

        sscanf(argv[2],"%x:%x:%x:%x:%x:%x", &a1,&a2,&a3,&a4,&a5,&a6);
        printf("setting %s to %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n",
                                argv[1],a1,a2,a3,a4,a5,a6);

        ifdat.ifr_ifru.ifru_enaddr[2]=a1; ifdat.ifr_ifru.ifru_enaddr[3]=a2;
        ifdat.ifr_ifru.ifru_enaddr[4]=a3; ifdat.ifr_ifru.ifru_enaddr[5]=a4;
        ifdat.ifr_ifru.ifru_enaddr[6]=a5; ifdat.ifr_ifru.ifru_enaddr[7]=a6;

        ret=ioctl(sock, SIOCSIFADDR, &ifdat );
        if (ret<0)
        {
                printf("ret=%d\n", ret);
                perror("ioctl:");
                exit(1);
        }
        printf("Done\n");
        return 0;
}


--
Ing. Horacio J. Gsmez
Socio Gerente
VCG Imagen SRL
Nuqez 5124
Buenos Aires (1431)
Argentina
t: +5411-4545-1767
f: +5411-4541-4716
c: +54911-4478-3646
e: horacio at vcgimagen.com.ar
w: www.vcgimagen.com.ar



More information about the rescue mailing list