summaryrefslogtreecommitdiffstats
path: root/README.md
blob: 0503680761046633ec66afe99dec5f72767d44b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
Vector Packet Processing
========================

## Introduction

The VPP platform is an extensible framework that provides out-of-the-box
production quality switch/router functionality. It is the open source version
of Cisco's Vector Packet Processing (VPP) technology: a high performance,
packet-processing stack that can run on commodity CPUs.

The benefits of this implementation of VPP are its high performance, proven
technology, its modularity and flexibility, and rich feature set.

For more information on VPP and its features please visit the
[FD.io website](http://fd.io/) and
[What is VPP?](https://wiki.fd.io/view/VPP/What_is_VPP%3F) pages.


## Changes

Details of the changes leading up to this version of VPP can be found under
doc/releasenotes.


## Directory layout

| Directory name         | Description                                 |
| ---------------------- | ------------------------------------------- |
| build-data             | Build metadata                              |
| build-root             | Build output directory                      |
| docs                   | Sphinx Documentation                        |
| dpdk                   | DPDK patches and build infrastructure       |
| extras/libmemif        | Client library for memif                    |
| src/examples           | VPP example code                            |
| src/plugins            | VPP bundled plugins directory               |
| src/svm                | Shared virtual memory allocation library    |
| src/tests              | Standalone tests (not part of test harness) |
| src/vat                | VPP API test program                        |
| src/vlib               | VPP application library                     |
| src/vlibapi            | VPP API library                             |
| src/vlibmemory         | VPP Memory management                       |
| src/vnet               | VPP networking                              |
| src/vpp                | VPP application                             |
| src/vpp-api            | VPP application API bindings                |
| src/vppinfra           | VPP core library                            |
| src/vpp/api            | Not-yet-relocated API bindings              |
| test                   | Unit tests and Python test harness          |

## Getting started

In general anyone interested in building, developing or running VPP should
consult the [VPP wiki](https://wiki.fd.io/view/VPP) for more complete
documentation.

In particular, readers are recommended to take a look at [Pulling, Building,
Running, Hacking, Pushing](https://wiki.fd.io/view/VPP/Pulling,_Building,_Run
ning,_Hacking_and_Pushing_VPP_Code) which provides extensive step-by-step
coverage of the topic.

For the impatient, some salient information is distilled below.


### Quick-start: On an existing Linux host

To install system dependencies, build VPP and then install it, simply run the
build script. This should be performed a non-privileged user with `sudo`
access from the project base directory:

    ./extras/vagrant/build.sh

If you want a more fine-grained approach because you intend to do some
development work, the `Makefile` in the root directory of the source tree
provides several convenience shortcuts as `make` targets that may be of
interest. To see the available targets run:

    make


### Quick-start: Vagrant

The directory `extras/vagrant` contains a `VagrantFile` and supporting
scripts to bootstrap a working VPP inside a Vagrant-managed Virtual Machine.
This VM can then be used to test concepts with VPP or as a development
platform to extend VPP. Some obvious caveats apply when using a VM for VPP
since its performance will never match that of bare metal; if your work is
timing or performance sensitive, consider using bare metal in addition or
instead of the VM.

For this to work you will need a working installation of Vagrant. Instructions
for this can be found [on the Setting up Vagrant wiki page]
(https://wiki.fd.io/view/DEV/Setting_Up_Vagrant).


## More information

Several modules provide documentation, see @subpage user_doc for more
end-user-oriented information. Also see @subpage dev_doc for developer notes.

Visit the [VPP wiki](https://wiki.fd.io/view/VPP) for details on more
advanced building strategies and other development notes.
0 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/* 
 *------------------------------------------------------------------
 * Copyright (c) 1997-2016 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include <stdio.h>
#include <ctype.h>
#include <malloc.h>
#include <time.h>
#include <gtk/gtk.h>
#include <string.h>

static char *sxerox (char *s);
void exit(int);

#define NBUCKETS 97

typedef struct prop_ {
    struct prop_ *next;
    char *name;
    char *value;
} prop_t;

static prop_t *buckets [NBUCKETS];
static int hash_shifts[4] = {24, 16, 8, 0};

/*
 * getprop 
 */

char *getprop (char *name)
{
    unsigned char *cp;
    unsigned long hash=0;
    prop_t *bp;
    int i=0;

    for (cp = (unsigned char *) name; *cp; cp++)
        hash ^= (*cp)<<(hash_shifts[(i++)&0x3]);

    bp = buckets [hash%NBUCKETS];

    while (bp && strcmp (bp->name, name)) {
        bp = bp->next;
    }

    if (bp == NULL)
        return (0);
    else
        return (bp->value);
}

/*
 * getprop_default
 */

char *getprop_default (char *name, char *def)
{
    char *rv;
    rv = getprop (name);
    if (rv)
        return (rv);
    else
        return (def);
}

/*
 * addprop
 */

void addprop (char *name, char *value)
{
    unsigned char *cp;
    unsigned long hash=0;
    prop_t **bpp;
    prop_t *bp;
    int i=0;

    bp = (prop_t *)g_malloc (sizeof (prop_t));

    bp->next = 0;
    bp->name = sxerox (name);
    bp->value = sxerox (value);

    for (cp = (unsigned char *)name; *cp; cp++)
        hash ^= (*cp)<<(hash_shifts[(i++)&0x3]);

    bpp = &buckets [hash%NBUCKETS];

    if (*bpp == NULL)
        *bpp = bp;
    else {
        bp->next = *bpp;
        *bpp = bp;
    }
}

/*
 * sxerox 
 */

static char *sxerox (char *s)
{
    char *rv = (char *) g_malloc (strlen (s) + 1);
    strcpy (rv, s);
    return rv;
}

/*
 * readprops 
 */

#define START 0
#define READNAME  1
#define READVALUE 2
#define C_COMMENT 3
#define CPP_COMMENT 4

int readprops (char *filename)
{
    FILE *ifp;
    unsigned char c;
    int state=START;
    int linenum=1;
    char namebuf [128];
    char valbuf [512];
    int i;

    ifp = fopen (filename, "r");

    if (ifp == NULL)
        return (-1);

    while (1) {

    readchar:
        c = getc (ifp);

    again:
        switch (state) {
        case START:
            if (feof (ifp)) {
                fclose (ifp);
                return (0);
            }

            if (c == ' ' || c == '\t')
                goto readchar;

            if (c == '\n') {
                linenum++;
                goto readchar;
            }
            if (isalpha (c) || (c == '_')) {
                state = READNAME;
                goto again;
            }
            if (c == '/') {
                c = getc (ifp);
                if (c == '/') {
                    state = CPP_COMMENT;
                    goto readchar;
                } else if (c == '*') {
                    state = C_COMMENT;
                    goto readchar;
                } else {
                    fprintf (stderr, "unknown token '/' line %d\n",
                             linenum);
                    exit (1);
                }
            }
            fprintf (stderr, "unknown token '%c' line %d\n",
                     c, linenum);
            exit (1);
            break;
            
        case CPP_COMMENT:
            while (1) {
                c = getc (ifp);
                if (feof (ifp))
                    return (0);
                if (c == '\n') {
                    linenum++;
                    state = START;
                    goto readchar;
                }
            }
            break;

        case C_COMMENT:
            while (1) {
                c = getc (ifp);
                if (feof (ifp)) {
                    fprintf (stderr, "unterminated comment, line %d\n",
                             linenum);
                    exit (1);
                }
                if (c == '*') {
                staragain:
                    c = getc (ifp);
                    if (c == '/') {
                        state = START;
                        goto readchar;
                    }
                    if (c == '*')
                        goto staragain;
                }
            }
            break;
                    
        case READNAME:
            i = 0;
            namebuf[i++] = c;
            while (1) {
                c = getc (ifp);
                if (feof (ifp)) {
                    fprintf (stderr, "EOF while reading a name, line %d\n",
                             linenum);
                    exit (1);
                }
                if ((!isalnum (c)) && (c != '_')) {
                    namebuf [i] = 0;
                    state = READVALUE;
                    goto again;
                }
                namebuf [i++] = c;
            }
            break;

        case READVALUE:
            i = 0;
            while ((c == ' ') || (c == '\t') || (c == '=')) {
                c = getc (ifp);
                if (feof (ifp)) {
                    fprintf (stderr, "EOF while reading a value, line %d\n",
                             linenum);
                    exit (1);
                }
            }
            goto firsttime;
            while (1) {
                c = getc (ifp);

            firsttime:
                if (c == '\\') {
                    c = getc (ifp);
                    if (feof (ifp)) {
                        fprintf (stderr, "EOF after '\\', line %d\n",
                                 linenum);
                        exit (1);
                    }
                    valbuf[i++] = c;
                    continue;
                }
                if (c == '\n') {
                    linenum++;
                    while (valbuf [i-1] == ' ' || valbuf[i-1] == '\t')
                        i--;
                    valbuf[i] = 0;
                    addprop (namebuf, valbuf);
                    state = START;
                    goto readchar;
                }
                valbuf[i++] = c;
            }

        }
    }
}