31.05.2017 08:07 Für alle die nicht nur TCP für was es RINETD gibt sondern auch UDP Traffic umleiten wollen. /* http://www.brokestream.com/udp_redirect.html Build: gcc -o udp_redirect udp_redirect.c udp_redirect.c Version 2008-11-09 Copyright (C) 2007 Ivan Tikhonov This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. Ivan Tikhonov, kefeer@brokestream.com */ #include #include #include #include #include int main(int argc, char *argv[]) { if (argc!=5) { printf("Usage: %s our-ip our-port first-mirror-ip second-mirror-ip\n",argv[0]); exit(1); } int osck=socket(PF_INET,SOCK_DGRAM,IPPROTO_IP); struct sockaddr_in sadr_bnd; sadr_bnd.sin_family=AF_INET; sadr_bnd.sin_addr.s_addr=inet_addr(argv[1]); sadr_bnd.sin_port=htons(atoi(argv[2])); if( bind(osck,(struct sockaddr *)&sadr_bnd,sizeof(sadr_bnd)) == -1) { printf("Can't bind our address (%s:%s)\n", argv[1], argv[2]); exit(1); } struct sockaddr_in sadr_one; sadr_one.sin_family=AF_INET; sadr_one.sin_addr.s_addr=inet_addr(argv[3]); sadr_one.sin_port=htons(atoi(argv[2])); struct sockaddr_in sadr_two; sadr_two.sin_family=AF_INET; sadr_two.sin_addr.s_addr=inet_addr(argv[4]); sadr_two.sin_port=htons(atoi(argv[2])); struct sockaddr_in sa; struct sockaddr_in da; da.sin_addr.s_addr=0; while(1) { char buf[65535]; int sn=sizeof(sa); int n=recvfrom(osck,buf,sizeof(buf),0,(struct sockaddr *)&sa,&sn); if(n<=0) continue; //printf("data from %s:%u\n", inet_ntoa(sa.sin_addr), ntohs(sa.sin_port)); /* inet_ntoa needs #include [0] "201705310807-161288706258-0.jpg" [1] "201705310807-161288706258-1.jpg" |