void ccnl_ll_TX(struct ccnl_relay_s *ccnl, struct ccnl_if_s *ifc, sockunion *dest, struct ccnl_buf_s *buf) { int rc; switch(dest->sa.sa_family) { #ifdef USE_IPV4 case AF_INET: rc = sendto(ifc->sock, buf->data, buf->datalen, 0, (struct sockaddr*) &dest->ip4, sizeof(struct sockaddr_in)); DEBUGMSG(DEBUG, "udp sendto %s/%d returned %d\n", inet_ntoa(dest->ip4.sin_addr), ntohs(dest->ip4.sin_port), rc); /* { int fd = open("t.bin", O_WRONLY | O_CREAT | O_TRUNC); write(fd, buf->data, buf->datalen); close(fd); } */ break; #endif #ifdef USE_LINKLAYER case AF_PACKET: rc = ccnl_eth_sendto(ifc->sock, dest->linklayer.sll_addr, ifc->addr.linklayer.sll_addr, buf->data, buf->datalen); DEBUGMSG(DEBUG, "eth_sendto %s returned %d\n", ll2ascii(dest->linklayer.sll_addr, dest->linklayer.sll_halen), rc); break; #endif #ifdef USE_UNIXSOCKET case AF_UNIX: rc = sendto(ifc->sock, buf->data, buf->datalen, 0, (struct sockaddr*) &dest->ux, sizeof(struct sockaddr_un)); DEBUGMSG(DEBUG, "unix sendto %s returned %d\n", dest->ux.sun_path, rc); break; #endif default: DEBUGMSG(WARNING, "unknown transport\n"); break; } (void) rc; // just to silence a compiler warning (if USE_DEBUG is not set) }
void ccnl_ll_TX(struct ccnl_relay_s *ccnl, struct ccnl_if_s *ifc, sockunion *dest, struct ccnl_buf_s *buf) { int rc; switch(dest->sa.sa_family) { case AF_INET: rc = sendto(ifc->sock, buf->data, buf->datalen, 0, (struct sockaddr*) &dest->ip4, sizeof(struct sockaddr_in)); DEBUGMSG(99, "udp sendto %s/%d returned %d\n", inet_ntoa(dest->ip4.sin_addr), ntohs(dest->ip4.sin_port), rc); break; #ifdef USE_ETHERNET case AF_PACKET: rc = ccnl_eth_sendto(ifc->sock, dest->eth.sll_addr, ifc->addr.eth.sll_addr, buf->data, buf->datalen); DEBUGMSG(99, "eth_sendto %s returned %d\n", eth2ascii(dest->eth.sll_addr), rc); break; #endif #ifdef USE_UNIXSOCKET case AF_UNIX: rc = sendto(ifc->sock, buf->data, buf->datalen, 0, (struct sockaddr*) &dest->ux, sizeof(struct sockaddr_un)); DEBUGMSG(99, "unix sendto %s returned %d\n", dest->ux.sun_path, rc); break; #endif default: DEBUGMSG(99, "unknown transport\n"); break; } rc = 0; // just to silence a compiler warning (if USE_DEBUG is not set) }