summaryrefslogtreecommitdiff
path: root/patgen.c
diff options
context:
space:
mode:
authormarkster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2002-04-05 22:21:00 +0000
committermarkster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2002-04-05 22:21:00 +0000
commite6dd22f41fe22e02fc2ac5898995e3e760f9f7ad (patch)
treef5d24bab1b2128821cf8484f58b682640f1b0d5d /patgen.c
parent40d359c292e67c2af1d6309ceddc6a0a64d16c40 (diff)
Version 0.2.0 from FTP
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@72 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'patgen.c')
-rwxr-xr-xpatgen.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/patgen.c b/patgen.c
new file mode 100755
index 0000000..bc600bf
--- /dev/null
+++ b/patgen.c
@@ -0,0 +1,71 @@
+#include <stdio.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <linux/zaptel.h>
+#include <stdio.h>
+#include <linux/types.h>
+#include <linux/ppp_defs.h>
+#include <sys/ioctl.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+/* #define BLOCK_SIZE 2048 */
+#define BLOCK_SIZE 2041
+
+void print_packet(unsigned char *buf, int len)
+{
+ int x;
+ printf("{ ");
+ for (x=0;x<len;x++)
+ printf("%02x ",buf[x]);
+ printf("}\n");
+}
+
+int main(int argc, char *argv[])
+{
+ int fd;
+ int fd2;
+ int ires, res, x;
+ int i;
+ ZT_PARAMS tp;
+ int bs = BLOCK_SIZE;
+ unsigned char c=0;
+ unsigned char inbuf[BLOCK_SIZE];
+ unsigned char outbuf[BLOCK_SIZE];
+ unsigned int fcs;
+ static int packets=0;
+ if (argc < 2) {
+ fprintf(stderr, "Usage: markhdlctest <tor device>\n");
+ exit(1);
+ }
+ fd = open(argv[1], O_RDWR, 0600);
+ if (fd < 0) {
+ fprintf(stderr, "Unable to open %s: %s\n", argv[1], strerror(errno));
+ exit(1);
+ }
+ if (ioctl(fd, ZT_SET_BLOCKSIZE, &bs)) {
+ fprintf(stderr, "Unable to set block size to %d: %s\n", bs, strerror(errno));
+ exit(1);
+ }
+ if (ioctl(fd, ZT_GET_PARAMS, &tp)) {
+ fprintf(stderr, "Unable to get channel parameters\n");
+ exit(1);
+ }
+ ioctl(fd, ZT_GETEVENT);
+#if 0
+ print_packet(outbuf, res);
+ printf("FCS is %x, PPP_GOODFCS is %x\n",
+ fcs,PPP_GOODFCS);
+#endif
+ for(;;) {
+ res = bs;
+ for (x=0;x<bs;x++)
+ outbuf[x] = c++;
+ res = write(fd, outbuf, res);
+#if 0
+ printf("(%d) Wrote %d bytes\n", packets++, res);
+#endif
+ }
+
+}