Annotation of embedaddon/libnet/src/libnet_build_link.c, revision 1.1

1.1     ! misho       1: /*
        !             2:  *  $Id: libnet_build_link.c,v 1.9 2004/03/04 20:50:20 kkuehl Exp $
        !             3:  *
        !             4:  *  libnet
        !             5:  *  libnet_build_link.c - link-layer packet assembler
        !             6:  *
        !             7:  *  Copyright (c) 2003 Roberto Larcher <roberto.larcher@libero.it>
        !             8:  *  Copyright (c) 1998 - 2004 Mike D. Schiffman <mike@infonexus.com>
        !             9:  *  All rights reserved.
        !            10:  *
        !            11:  * Redistribution and use in source and binary forms, with or without
        !            12:  * modification, are permitted provided that the following conditions
        !            13:  * are met:
        !            14:  * 1. Redistributions of source code must retain the above copyright
        !            15:  *    notice, this list of conditions and the following disclaimer.
        !            16:  * 2. Redistributions in binary form must reproduce the above copyright
        !            17:  *    notice, this list of conditions and the following disclaimer in the
        !            18:  *    documentation and/or other materials provided with the distribution.
        !            19:  *
        !            20:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
        !            21:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            22:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            23:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
        !            24:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            25:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            26:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            27:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            28:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            29:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            30:  * SUCH DAMAGE.
        !            31:  *
        !            32:  */
        !            33: 
        !            34: #if (HAVE_CONFIG_H)
        !            35: #include "../include/config.h"
        !            36: #endif
        !            37: #if (!(_WIN32) || (__CYGWIN__))
        !            38: #include "../include/libnet.h"
        !            39: #else
        !            40: #include "../include/win32/libnet.h"
        !            41: #endif
        !            42: 
        !            43: libnet_ptag_t
        !            44: libnet_build_link(u_int8_t *dst, u_int8_t *src, u_int8_t *oui, u_int16_t type,
        !            45: u_int8_t *payload, u_int32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
        !            46: 
        !            47: {
        !            48:        u_int8_t org[3] = {0x00, 0x00, 0x00};
        !            49:     switch (l->link_type)
        !            50:     {
        !            51:         /* add FDDI */
        !            52:         case DLT_EN10MB:
        !            53:             return (libnet_build_ethernet(dst, src, type, payload, payload_s, l,
        !            54:                     ptag));
        !            55:         case DLT_IEEE802:
        !            56:             return (libnet_build_token_ring(LIBNET_TOKEN_RING_FRAME,
        !            57:                     LIBNET_TOKEN_RING_LLC_FRAME, dst, src, LIBNET_SAP_SNAP,
        !            58:                     LIBNET_SAP_SNAP, 0x03, org, type, payload, payload_s,
        !            59:                     l, ptag));
        !            60:         default:
        !            61:             break;
        !            62:     }
        !            63:     snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
        !            64:             "%s(): linktype %d not supported\n", __func__, l->link_type);
        !            65:     return (-1);
        !            66: }
        !            67: 
        !            68: libnet_ptag_t
        !            69: libnet_autobuild_link(u_int8_t *dst, u_int8_t *oui, u_int16_t type, libnet_t *l)
        !            70: {
        !            71:        u_int8_t org[3] = {0x00, 0x00, 0x00};
        !            72:     switch (l->link_type)
        !            73:     {
        !            74:        /* add FDDI */
        !            75:         case DLT_EN10MB:
        !            76:             return (libnet_autobuild_ethernet(dst, type, l));
        !            77:         case DLT_IEEE802:
        !            78:             return (libnet_autobuild_token_ring(LIBNET_TOKEN_RING_FRAME,
        !            79:                    LIBNET_TOKEN_RING_LLC_FRAME, dst, LIBNET_SAP_SNAP,
        !            80:                    LIBNET_SAP_SNAP, 0x03, org, TOKEN_RING_TYPE_IP, l));
        !            81:         default:
        !            82:             break;
        !            83:     }
        !            84:     snprintf(l->err_buf, LIBNET_ERRBUF_SIZE,
        !            85:             "%s(): linktype %d not supported\n", __func__, l->link_type);
        !            86:     return (-1);
        !            87: }
        !            88: 
        !            89: /* EOF */
        !            90: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>