/[dynamips]/upstream/dynamips-0.2.7-RC2/udp_send.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /upstream/dynamips-0.2.7-RC2/udp_send.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8 - (show annotations)
Sat Oct 6 16:24:54 2007 UTC (12 years, 1 month ago) by dpavlin
File MIME type: text/plain
File size: 738 byte(s)
dynamips-0.2.7-RC2

1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <stdarg.h>
5 #include <unistd.h>
6 #include <fcntl.h>
7 #include <errno.h>
8 #include <assert.h>
9
10 #include "utils.h"
11 #include "net.h"
12
13 #define MAX_PKT_SIZE 2048
14
15 int main(int argc,char *argv[])
16 {
17 char pkt[MAX_PKT_SIZE];
18 size_t pkt_size;
19 int sck;
20 FILE *fd;
21
22 if (!(fd = fopen(argv[1],"r"))) {
23 perror("fopen");
24 exit(EXIT_FAILURE);
25 }
26
27 /* Read packet from file */
28 pkt_size = fread(pkt,1,MAX_PKT_SIZE,fd);
29
30 /* Connect to remote port */
31 if ((sck = udp_connect(atoi(argv[2]),argv[3],atoi(argv[4]))) < 0)
32 exit(EXIT_FAILURE);
33
34 /* Send it */
35 if (send(sck,pkt,pkt_size,0) < 0)
36 exit(EXIT_FAILURE);
37
38 close(sck);
39 return(0);
40 }

  ViewVC Help
Powered by ViewVC 1.1.26