Juha Ylönen wrote:
> Yeah, I've been lurking there for a while, but being so much on/off from
>  the computer lately it's been easier to email. I'll certainly begin
>  bugging You through irc once I have time to sit down for a while..=)

It would help a lot. We are currently waiting for a lot more information from 
you.

I think it isn't really a big endian vs. little endian problem. I have 
installed batman-adv 1559 on a powerpc and on my amd64. Both can talk to each 
other without problems.

Do you have any filters installed which could filter out the ethernet frames? 
Does your hardware on arm transport non-standard ethernet types? A tcpdump on 
both sides which we can compare would help a lot.

I usually use a small test program to send raw ethernet packets from one host 
to another (one sided ping test). It helps a lot to find one directional 
problems.

On one side you must use `./rawsend DEVICE` and on the other
`./rawsend DEVICE TARGET-MAC`

Best regards,
        Sven
#include <stdio.h>
#include <sys/ioctl.h>
#include <net/if.h> 
#include <sys/types.h>
#include <sys/socket.h>
#include <netpacket/packet.h>
#include <net/ethernet.h>
#include <stdint.h>
#include <string.h>
#include <arpa/inet.h>
#include <unistd.h>

int getmac(const char *src, unsigned char *dst)
{
	unsigned int n[6];
	int i;
	if (sscanf(src, "%x:%x:%x:%x:%x:%x",
	    &n[0], &n[1], &n[2], &n[3], &n[4], &n[5]) != 6) {
		if(sscanf(src, "%2x%2x.%2x%2x.%2x%2x",
		   &n[0], &n[1], &n[2], &n[3], &n[4], &n[5]) != 6) {
			return 1;
		}
	}

	for (i = 0; i < 6; i++) {
		if (n[i] <= 255)
			dst[i] = (unsigned char)n[i];
		else
			return 1;
	}

	return 0;
}

int main(int argc, char *argv[])
{
	int rawsock;
	uint16_t type = 0x1337;
	struct ifreq req;
	struct sockaddr_ll addr;
	struct iovec vector[2];
	char buf[256];
	size_t size = 256;
	struct ether_header header;

	if (argc != 2 && argc != 3) {
		fprintf(stderr, "Usage: %s DEVICE [DST-MAC]\n", argv[0]);
		return 1;
	}

	if ((rawsock = socket(PF_PACKET, SOCK_RAW, htons(type))) < 0 ) {
			fprintf(stderr, "Could not open raw socket\n");
			return 1;
	}

	strncpy(req.ifr_name, argv[1], IFNAMSIZ);
	if (ioctl(rawsock, SIOCGIFINDEX, &req) < 0) {
		fprintf(stderr, "Could not find device %s\n", argv[1]);
		return 1;
	}

	addr.sll_family = AF_PACKET;
	addr.sll_protocol = htons(type);
	addr.sll_ifindex  = req.ifr_ifindex;

	if (bind(rawsock, (struct sockaddr *)&addr, sizeof(addr)) < 0 ) {
		fprintf(stderr, "Could not bind to device %s\n", argv[1]);
		return 1;
	}

	strncpy(req.ifr_name, argv[1], IFNAMSIZ);
	if (ioctl(rawsock, SIOCGIFHWADDR, &req) < 0) {
		fprintf(stderr, "Could not get hwaddr of device %s\n", argv[1]);
		return 1;
	}

	if (argc == 2) {
		vector[0].iov_base = &header;
		vector[0].iov_len  = sizeof(struct ether_header);
		vector[1].iov_base = buf;
		vector[1].iov_len  = size;

		if (readv(rawsock, vector, 2) < 0) {
			close(rawsock);
			fprintf(stderr, "Could not receive message\n");
			return 1;
		}
		printf("Received message\n");
	} else if (argc == 3) {
		vector[0].iov_base = &header;
		vector[0].iov_len  = sizeof(struct ether_header);
		vector[1].iov_base = buf;
		vector[1].iov_len  = size;

		header.ether_type = htons(type);

		memcpy(header.ether_shost, req.ifr_hwaddr.sa_data, ETH_ALEN);

		if (getmac(argv[2], header.ether_dhost)) {
			close(rawsock);
			fprintf(stderr, "Could not parse mac address %s\n", argv[2]);
			return 1;
		}
		if (writev(rawsock, vector, 2) < 0) {
			close(rawsock);
			fprintf(stderr, "Could not send message\n");
			return 1;
		}
	}
	close(rawsock);
	return 0;
}

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to