int main(void) { SLPIfaceInfo ifaceinfo; SLPIfaceInfo ifaceinfo6; SLPXcastSockets socks; SLPBuffer buffer; /* multicast srvloc address */ uint8_t v6Addr[] = {0xFF, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x16}; struct sockaddr_storage dst; int mtu; #ifdef _WIN32 WSADATA wsadata; WSAStartup(MAKEWORD(2, 2), &wsadata); #endif mtu = SLPPropertyGetMTU(); //const struct in6_addr in6addr; buffer = SLPBufferAlloc(mtu); if (buffer) { strcpy((char *)buffer->start, "testdata"); SLPIfaceGetInfo(NULL,&ifaceinfo, AF_INET); SLPIfaceGetInfo(NULL,&ifaceinfo6, AF_INET6); if (SLPBroadcastSend(&ifaceinfo, buffer, &socks) !=0) printf("\n SLPBroadcastSend failed \n"); SLPXcastSocketsClose(&socks); /* for v6 */ if (SLPBroadcastSend(&ifaceinfo6, buffer,&socks) !=0) printf("\n SLPBroadcastSend failed for ipv6\n"); SLPXcastSocketsClose(&socks); if (SLPMulticastSend(&ifaceinfo, buffer, &socks, 0) !=0) printf("\n SLPMulticast failed \n"); SLPXcastSocketsClose(&socks); /* set up address and scope for v6 multicast */ SLPNetSetAddr(&dst, AF_INET6, 0, (uint8_t *)v6Addr); if (SLPMulticastSend(&ifaceinfo6, buffer, &socks, &dst) !=0) printf("\n SLPMulticast failed for ipv\n"); SLPXcastSocketsClose(&socks); printf("Success\n"); SLPBufferFree(buffer); } #ifdef _WIN32 WSACleanup(); #endif return 0; }
main() { SLPIfaceInfo ifaceinfo; SLPXcastSockets socks; SLPBuffer buffer; buffer = SLPBufferAlloc(SLP_MAX_DATAGRAM_SIZE); if(buffer) { strcpy(buffer->start,"testdata"); SLPIfaceGetInfo(NULL,&ifaceinfo); if (SLPBroadcastSend(&ifaceinfo, buffer,&socks) !=0) printf("\n SLPBroadcastSend failed \n"); SLPXcastSocketsClose(&socks); if (SLPMulticastSend(&ifaceinfo, buffer, &socks) !=0) printf("\n SLPMulticast failed \n"); SLPXcastSocketsClose(&socks); printf("Success\n"); SLPBufferFree(buffer); } }