~ubuntu-branches/debian/sid/trinity/sid

« back to all changes in this revision

Viewing changes to net/ax25.c

  • Committer: Package Import Robot
  • Author(s): gustavo panizzo
  • Date: 2014-01-17 21:10:15 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20140117211015-k2qbnpu0osa5mlil
Tags: 1.3-1
* New upstream version 1.3.
* Removed wrong dependency on linux-headers. (Closes: #733771).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <sys/types.h>
2
 
#include <sys/socket.h>
3
 
#include <sys/un.h>
4
 
#include <netinet/in.h>
5
 
#include <linux/ax25.h>
6
 
#include <stdlib.h>
7
 
#include "maps.h"       // page_rand
8
 
#include "net.h"
9
 
#include "random.h"
10
 
 
11
 
void ax25_gen_sockaddr(unsigned long *addr, unsigned long *addrlen)
12
 
{
13
 
        struct sockaddr_ax25 *ax25;
14
 
 
15
 
        ax25 = malloc(sizeof(struct sockaddr_ax25));
16
 
        if (ax25 == NULL)
17
 
                return;
18
 
 
19
 
        ax25->sax25_family = PF_AX25;
20
 
        memcpy(ax25->sax25_call.ax25_call, page_rand, 7);
21
 
        ax25->sax25_ndigis = rand();
22
 
        *addr = (unsigned long) ax25;
23
 
        *addrlen = sizeof(struct sockaddr_ax25);
24
 
}
25
 
 
26
 
#define NR_AX25_PROTOS 13
27
 
static int ax25_protocols[NR_AX25_PROTOS] = {
28
 
        0x01,   /* ROSE */
29
 
        0x06,   /* Compressed TCP/IP packet   *//* Van Jacobsen (RFC 1144)    */
30
 
        0x07,   /* Uncompressed TCP/IP packet *//* Van Jacobsen (RFC 1144)    */
31
 
        0x08,   /* Segmentation fragment      */
32
 
        0xc3,   /* TEXTNET datagram protocol  */
33
 
        0xc4,   /* Link Quality Protocol      */
34
 
        0xca,   /* Appletalk                  */
35
 
        0xcb,   /* Appletalk ARP              */
36
 
        0xcc,   /* ARPA Internet Protocol     */
37
 
        0xcd,   /* ARPA Address Resolution    */
38
 
        0xce,   /* FlexNet                    */
39
 
        0xcf,   /* NET/ROM                    */
40
 
        0xF0    /* No layer 3 protocol impl.  */
41
 
};
42
 
 
43
 
void ax25_rand_socket(struct socket_triplet *st)
44
 
{
45
 
        switch (rand() % 3) {
46
 
        case 0: st->type = SOCK_DGRAM;
47
 
                st->protocol = 0;
48
 
                break;
49
 
        case 1: st->type = SOCK_SEQPACKET;
50
 
                st->protocol = ax25_protocols[rand() % NR_AX25_PROTOS];
51
 
                break;
52
 
        case 2: st->type = SOCK_RAW;
53
 
                break;
54
 
        default:break;
55
 
        }
56
 
}