00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071 #include <stdlib.h>
00072 #include <stdio.h>
00073 #include <sys/types.h>
00074 #include <sys/time.h>
00075 #include <string.h>
00076 #include <ctype.h>
00077 #include <time.h>
00078 #include <unistd.h>
00079 #include <netdb.h>
00080 #include <sys/socket.h>
00081 #include <sys/utsname.h>
00082
00083 #include <regex.h>
00084 #include <netinet/in.h>
00085 #include <arpa/inet.h>
00086 #include <sys/poll.h>
00087
00088 #include <errno.h>
00089
00090
00091 void shoot()
00092 {
00093 struct sockaddr_in addr, sockname;
00094 struct timeval tv, sendtime, recvtime, firstsendt;
00095 struct timezone tz;
00096 struct pollfd sockerr;
00097 int ssock, redirected, retryAfter;
00098 int sock, i, len, ret, usrlocstep, randretrys;
00099 int dontsend, cseqcmp, cseqtmp;
00100 int rem_rand, rem_namebeg;
00101 char *contact, *crlf, *foo, *bar;
00102 fd_set fd;
00103 socklen_t slen;
00104 regex_t redexp, proexp, okexp, tmhexp, errexp;
00105 int bsd_compat, opt_size;
00106
00107 int nretries=3;
00108 char *buff="MiniTest";
00109
00110
00111
00112 sock = (int)socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
00113 if (sock==-1) {
00114 perror("no client socket");
00115 exit(2);
00116 }
00117
00118
00119 #ifndef _NO_LISTENER
00120
00121 ssock = (int)socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
00122 if (ssock==-1) {
00123 perror("no server socket");
00124 exit(2);
00125 }
00126
00127 sockname.sin_family=AF_INET;
00128 sockname.sin_addr.s_addr = htonl( INADDR_ANY );
00129 sockname.sin_port = htons((short)47437);
00130 if (bind( ssock, (struct sockaddr *) &sockname, sizeof(sockname) )==-1) {
00131 perror("no bind");
00132 exit(2);
00133 }
00134 #endif
00135
00136
00137
00138
00139 addr.sin_addr.s_addr = inet_addr("192.168.99.100");
00140 addr.sin_port = htons((short)888);
00141 addr.sin_family = AF_INET;
00142
00143
00144
00145 #ifdef CONNECTED
00146
00147
00148 ret = connect(sock, (struct sockaddr *)&addr, sizeof(addr));
00149 if (ret==-1) {
00150 perror("no connect");
00151 exit(2);
00152 }
00153 #endif
00154
00155 if (getsockopt( sock, SOL_SOCKET, SO_BSDCOMPAT, &bsd_compat, &opt_size )==-1) {
00156 perror("ERROR");
00157 exit(1);
00158 }
00159 printf("BSD compat: %d\n", bsd_compat);
00160
00161
00162
00163 for (i = 0; i <= nretries; i++)
00164 {
00165
00166
00167
00168
00169
00170 #ifdef CONNECTED
00171 ret = send(sock, buff, strlen(buff), 0);
00172 #else
00173 ret=sendto(sock, buff, strlen(buff), 0, (struct sockaddr *)&addr, sizeof(addr));
00174 #endif
00175
00176 usleep(100000);
00177 if (ret==-1) {
00178 perror("send failure");
00179 exit( 1 );
00180 }
00181 }
00182
00183 exit(0);
00184 }
00185
00186 int main(int argc, char *argv[])
00187 {
00188 shoot();
00189 }
00190