~ubuntu-branches/ubuntu/wily/maradns/wily-proposed

« back to all changes in this revision

Viewing changes to deadwood-3.2.05/sqa/dwood2rc_n_resurrections/dead.server.c

  • Committer: Package Import Robot
  • Author(s): Dariusz Dwornikowski, Tomasz Buchert, Dariusz Dwornikowski
  • Date: 2015-03-27 18:34:08 UTC
  • mfrom: (1.2.12)
  • Revision ID: package-import@ubuntu.com-20150327183408-wnfachdkdjt96yu6
Tags: 2.0.11-1
[ Tomasz Buchert ]
* Imported Upstream version 2.0.11

[ Dariusz Dwornikowski ]
* d/patches: 
  - refreshed all patches for new deadwood version
  - removed generating of random prime on build (Closes: #785536) 
* d/rules: date taken from changelog (Closes: #785535)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2009 Sam Trenholme
2
 
 *
3
 
 * TERMS
4
 
 *
5
 
 * Redistribution and use in source and binary forms, with or without
6
 
 * modification, are permitted provided that the following conditions
7
 
 * are met:
8
 
 *
9
 
 * 1. Redistributions of source code must retain the above copyright
10
 
 *    notice, this list of conditions and the following disclaimer.
11
 
 * 2. Redistributions in binary form must reproduce the above copyright
12
 
 *    notice, this list of conditions and the following disclaimer in the
13
 
 *    documentation and/or other materials provided with the distribution.
14
 
 *
15
 
 * This software is provided 'as is' with no guarantees of correctness or
16
 
 * fitness for purpose.
17
 
 */
18
 
 
19
 
/* Simple UDP DNS server; this never replies to a DNS query one sends
20
 
 * us */
21
 
 
22
 
#include <sys/socket.h>
23
 
#include <netinet/in.h>
24
 
#include <arpa/inet.h>
25
 
#include <string.h>
26
 
#include <unistd.h>
27
 
#include <fcntl.h>
28
 
#include <stdlib.h>
29
 
#include <stdio.h>
30
 
 
31
 
/* This is the IP "10.11.12.13" added to their question */
32
 
char p[17] =
33
 
"\xc0\x0c\x00\x01\x00\x01\x00\x00\x00\x00\x00\x04\x0a\x0b\x0c\x0d";
34
 
 
35
 
main() {
36
 
        int a, b, len_inet, sock;
37
 
        struct sockaddr_in dns_udp;
38
 
        char in[512];
39
 
        int foo = sizeof(in);
40
 
        int localhost = 0x7f000002; /* 127.0.0.2 */
41
 
        int leni = sizeof(struct sockaddr);
42
 
 
43
 
        /* Bind to 127.0.0.2 port 53 */
44
 
        sock = socket(AF_INET,SOCK_DGRAM,0);
45
 
        if(sock == -1) {printf("socket error\n");exit(0);}
46
 
        memset(&dns_udp,0,sizeof(dns_udp));
47
 
        dns_udp.sin_family = AF_INET;
48
 
        dns_udp.sin_port = htons(53);
49
 
        dns_udp.sin_addr.s_addr = htonl(localhost);
50
 
        if(dns_udp.sin_addr.s_addr == INADDR_NONE) {
51
 
                printf("htonl error\n");exit(0);}
52
 
        len_inet = sizeof(dns_udp);
53
 
        if(bind(sock,(struct sockaddr *)&dns_udp,len_inet) == -1) {
54
 
                printf("bind error\n");exit(0);}
55
 
 
56
 
        /* Linux kernel bug */
57
 
        /* fcntl(sock, F_SETFL, O_NONBLOCK); */
58
 
 
59
 
        for(b=0;;b++) {
60
 
          /* Get data from UDP port 53 */
61
 
          len_inet = recvfrom(sock,in,255,0,(struct sockaddr *)&dns_udp,&foo);
62
 
          /* Roy Arends check: We only answer questions */
63
 
          if(1 == 1) {
64
 
                printf("Packet not sent\n");
65
 
                continue;
66
 
          }
67
 
          printf("Why are we here?\n");
68
 
          }
69
 
 
70
 
        }
71
 
 
72