UDP packet does not arrive
I'm not sure if this is the right place to ask this question. If not, i
will remove it...
Anyway, i have made driver for enc28j60 for LPC1788 and I'm trying to send
UDP message to it from iOS. Sending fails. Communication starts by iOS
sending the ARP request. On LPC i make response and send it to iOS MAC
address. I have read RFC for ARP and created packet by the specification,
but for some reason i dont see the response in network sniffer.
That would for sure indicate that my response routine does not work, if
there was not this case when i send udp message from OSX (nc -u
xxx.xxx.xxx.xxx port) that comes correctly to LPC.
The difference that i observed is that OSX sends the request which is
42bytes long and gets 60bytes long response with last 18bytes of 0's
(padding bytes), and iOS sends the 60byte long request with last 4bytes as
90 eb 58 96.
I tried to respond with all padding zeros, and with copying those 4 bytes,
but neither approach worked.
OSX ARP(req, res) and UDP package is visible in sniffer. iOS ARP req is
visible in sniffer and nothing else.
Any idea ?
EDIT:
IOS code:
CFSocketRef sock = CFSocketCreate(kCFAllocatorDefault, PF_INET,
SOCK_DGRAM, IPPROTO_UDP, 0, NULL, NULL);
if ( sock == NULL) {
NSLog(@"CfSocketCreate Failed");
}else{
struct sockaddr_in remoteAddress;
memset(&remoteAddress, 0, sizeof(remoteAddress));
remoteAddress.sin_family = AF_INET;
remoteAddress.sin_len = sizeof(remoteAddress);
remoteAddress.sin_port = htons(1200);
remoteAddress.sin_addr.s_addr = inet_addr("192.168.5.8");
char data[] = "test";
NSData *message_data = [NSData dataWithBytes:&data length:4];
NSData* remoteAddressData = [NSData dataWithBytes:&remoteAddress
length:sizeof(remoteAddress)];
CFSocketError er = CFSocketSendData(sock, (__bridge
CFDataRef)(remoteAddressData), (__bridge CFDataRef)message_data, 0);
}
No comments:
Post a Comment