Robert Watson wrote:
> On Sat, 8 Jan 2005, Ivan Voras wrote:
>
>
>> I've just noticed I can't create a raw socket on 5.3-RELEASE, while the
>> same code works on 5.2. I get 'Protocol not supported' error on code
>> like this:
>
>
>
> I've not got a 5.2 box on hand, but this appears not to work on 4.x. There isn't a domain handler for AF_LINK, so you shouldn't be able to
> create a socket of that type, so if it was possible in 5.2, it was likely
> a bug.
I use it in this code:
/* get interface name by index */ int cardif_get_int(int index, char *retInterface) { struct ifreq ifr; struct ifaddrs *ifa_master, *ifa; int sock, retval; char msg[100];
sock = socket(AF_LINK, SOCK_RAW, 0);
if (sock < 0) {
sprintf(msg, "cardif_get_int: cannot create raw socket: %s\n", strerror(errno));
debug_printf(DEBUG_NORMAL, msg);
return XESOCKOP;
}
getifaddrs(&ifa_master);
for (ifa = ifa_master; ifa != NULL; ifa = ifa->ifa_next) { strncpy(ifr.ifr_name, ifa->ifa_name, IFNAMSIZ);
retval = ioctl(sock, SIOCGIFINDEX, &ifr);
if (retval < 0) {
debug_printf(DEBUG_NORMAL, "Error getting interface index value for interface %s\n", ifa->ifa_name);
freeifaddrs(ifa_master);
close(sock);
return XESOCKOP;
}
if (ifr.ifr_index == index) break; }
if (ifa == NULL) {
debug_printf(DEBUG_NORMAL, "Cannot find interface name by its index: %d\n", index);
freeifaddrs(ifa_master);
close(sock);
return XENOTINT;
}
strncpy(retInterface, ifa->ifa_name, IFNAMSIZ);
freeifaddrs(ifa_master); close(sock); return XENONE; }
---
i.e. I need it for the ioctl() call. Is there another way?
_______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"