Browse Source

Almost done with packet fragmentation

MissValeska 10 years ago
parent
commit
2231df0ea7
1 changed files with 20 additions and 5 deletions
  1. 20
    5
      src/inet.c

+ 20
- 5
src/inet.c View File

552
 		return -1;
552
 		return -1;
553
 	}
553
 	}
554
 
554
 
555
+        printf("Socket FD: %i ", sockfd);
556
+        
555
 	return sockfd;
557
 	return sockfd;
556
 }
558
 }
557
 
559
 
1064
 			error("Packet artificially fragmented: %d", stderr);
1066
 			error("Packet artificially fragmented: %d", stderr);
1065
                                 error("\nData Length: %u", len);
1067
                                 error("\nData Length: %u", len);
1066
                                 int bytesleft = len;
1068
                                 int bytesleft = len;
1067
-                                while(bytesleft > 1024) {
1068
-                                inet_sendto(s, msg, 1024, flags, to, tolen);
1069
-                                bytesleft -= 1024;
1070
-				//err=inet_sendto(s, ((const char *)msg+(len/2)),
1071
-						//len-(len/2), flags, to, tolen);
1069
+                                int sendbuf;
1070
+                                socklen_t optlen;
1071
+                                optlen = sizeof(sendbuf);
1072
+                                int res = getsockopt(s, SOL_SOCKET, SO_SNDBUF, &sendbuf, &optlen);
1073
+                                
1074
+                                error("GetSockOpt: %i \n", res);
1075
+                                
1076
+                                while(bytesleft != 0) {
1077
+                                    if(bytesleft > 64000) {
1078
+                                        inet_sendto(s, msg, 64000, flags, to, tolen);
1079
+                                        bytesleft -= 64000;
1080
+                                        //err=inet_sendto(s, ((const char *)msg+(len/2)),
1081
+                                                 //len-(len/2), flags, to, tolen);
1082
+                                    }
1083
+                                    else    {
1084
+                                        inet_sendto(s, msg, bytesleft, flags, to, tolen);
1085
+                                        bytesleft = 0;
1086
+                                    }
1072
                                 }
1087
                                 }
1073
 				break;
1088
 				break;
1074
 			case EFAULT:
1089
 			case EFAULT:

Loading…
Cancel
Save