Hi, You were right, sendto() wasn't working properly, but not because of my last patch, it never really worked in IP_TRANSPARENT mode. I've attached two patches I've just submitted to netdev, which should solve your problem. I'm Ccing the tproxy list as well. On Mon, 2008-11-17 at 21:21 +0200, elyasaf wrote:
You are right that in my isolate example was a bug Now I add transparenty and its continue to be "Invalid argument" (but without transparenty it work fine) Its some how really work before the patch, and I cant see any reason why, the patch seen clean and not related...
int main(int argc, char *argv[]) { char buf[5]="aaaa"; struct sockaddr_in source,destination; source.sin_family = AF_INET; source.sin_addr.s_addr = inet_addr("10.0.0.26"); source.sin_port = htons(INADDR_ANY);
destination.sin_family = AF_INET; destination.sin_port = htons(1500); destination.sin_addr.s_addr = inet_addr("10.0.0.2"); send_to_transparenty(buf,4,&source,&destination); }
int send_to_transparenty(char *buf,int len,struct sockaddr_in *source,struct sockaddr_in *destination){ int fd=socket(AF_INET, SOCK_DGRAM, 0); int flags=1; if (setsockopt(fd, SOL_IP, IP_TRANSPARENT, &flags, sizeof(int)) == -1){ perror("destination-setsockopt() IP_TRANSPARENT error!"); return; }else{ printf("destination-setsockopt IP_TRANSPARENT is OK...\n"); } setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &flags, sizeof(flags)); setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &flags, sizeof(flags)); if(bind (fd, (struct sockaddr *) source,sizeof(*source))==-1){ perror("destination-bind() error!"); return; } flags=0; if(sendto(fd,buf,len,flags,(struct sockaddr *)destination,sizeof(*destination))==-1){ perror("destination-sendto() error!"); return; } close(fd); }
execve("./udpserver", ["./udpserver"], [/* 31 vars */]) = 0 brk(0) = 0x602000
-- Bazsi