~ubuntu-branches/ubuntu/wily/apparmor/wily

« back to all changes in this revision

Viewing changes to tests/regression/subdomain/net_raw.c

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2011-04-27 10:38:07 UTC
  • mfrom: (5.1.118 natty)
  • Revision ID: james.westby@ubuntu.com-20110427103807-ym3rhwys6o84ith0
Tags: 2.6.1-2
debian/copyright: clarify for some full organization names.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: net_raw.c 61 2006-05-19 18:32:14Z steve-beattie $ */
2
 
 
3
 
/*
4
 
 *      Copyright (C) 2002-2005 Novell/SUSE
5
 
 *
6
 
 *      This program is free software; you can redistribute it and/or
7
 
 *      modify it under the terms of the GNU General Public License as
8
 
 *      published by the Free Software Foundation, version 2 of the
9
 
 *      License.
10
 
 */
11
 
 
12
 
/* Basic tcp networking test. */
13
 
 
14
 
#include <stdio.h>
15
 
#include <stdlib.h>
16
 
#include <string.h>
17
 
#include <unistd.h>
18
 
#include <errno.h>
19
 
//#include <netinet/in.h>
20
 
#include <netpacket/packet.h>
21
 
#include <net/ethernet.h> 
22
 
#include <sys/select.h>
23
 
#include <sys/socket.h>
24
 
#include <sys/time.h>
25
 
#include <sys/types.h>
26
 
#include <sys/wait.h>
27
 
#include <arpa/inet.h>
28
 
#include <fcntl.h>
29
 
 
30
 
#define HOSTIP "127.0.0.1"
31
 
#define HOSTPORT 9876
32
 
#define BUFSIZE 4096
33
 
#define WAITLEN 1 /* number of seconds for select to wait */
34
 
#define DATASOURCE "/dev/urandom"
35
 
 
36
 
char data[BUFSIZE];
37
 
 
38
 
int 
39
 
main (int argc, char * argv[]) {
40
 
        int sockfd;
41
 
 
42
 
        /* create a socket */
43
 
        if ((sockfd = socket (PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) < 0) {
44
 
                perror ("FAIL: Server: can't open raw socket");
45
 
                return 1;
46
 
        }       
47
 
 
48
 
        close (sockfd);
49
 
 
50
 
        printf ("PASS\n");
51
 
 
52
 
        return 0;
53
 
}