~ubuntu-branches/ubuntu/raring/apparmor/raring

« 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: 2007-03-23 16:42:01 UTC
  • Revision ID: james.westby@ubuntu.com-20070323164201-jkax6f0oku087b7l
Tags: upstream-2.0.1+510.dfsg
ImportĀ upstreamĀ versionĀ 2.0.1+510.dfsg

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
}