⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 machdep.h

📁 ospf 源码 可用于基本的LINUX环境 对OSPF的基本运用有更深入的了解
💻 H
字号:
/*
 *   OSPFD routing daemon
 *   Copyright (C) 1998 by John T. Moy
 *   
 *   This program is free software; you can redistribute it and/or
 *   modify it under the terms of the GNU General Public License
 *   as published by the Free Software Foundation; either version 2
 *   of the License, or (at your option) any later version.
 *   
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *   
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#include <stdarg.h>
#include <string.h>

/* 
 * Machine-dependent and compiler-dependent constants and macros.
 * Defined here for a Intel architecture, and a compiler whose
 * "ints" are 32-bits and "shorts" 16.
 */

// Definition of fixed-length types

typedef unsigned char byte;	// Byte (8-bit unsigned)
typedef	unsigned short uns16;	// 16-bit unsigned
typedef	unsigned uns32;		// 32-bit unsigned
typedef char int8;		// 8-bit signed
typedef	short int16;		// 16-bit signed
typedef	int int32;		// 32-bit signed

typedef unsigned long word;	// Generic pointer

// Constant for fletcher checksum calculation
const int MODX = 4102;

// Machine-dependencies in the socket interface
typedef int socklen;		// length arg to accept(), etc.
#define PHYBINDADDR "127.0.0.1"

// Convert fields between network and machine byte-order
// This involves byte-swapping on an Intel architecture
	
// Convert a 32-bit unsigned quantity from network to host order

inline uns32 ntoh32(uns32 value)

{
    uns32 swval;

    swval = (value << 24);
    swval |= (value << 8) & 0x00ff0000L;
    swval |= (value >> 8) & 0x0000ff00L;
    swval |= (value >> 24);
    return(swval);
}

// Convert a 32-bit quantity from host to network order

inline uns32 hton32(uns32 value)

{
    return(ntoh32(value));
}

// Convert a 16-bit unsigned quantity from network to host order

inline uns16 ntoh16(uns16 value)

{
    uns16 swval;

    swval = (value << 8);
    swval |= (value >> 8) & 0xff;
    return(swval);
}

// Convert a 16-bit quantity from host to network order

inline uns16 hton16(uns16 value)

{
    return(ntoh16(value));
}


/* Standard utility functions
 * These have been defined in the standard Linux
 * header files above.
 *
 * void	bcopy(const void *from, void *to, size_t);	// Byte copy
 * int bcmp(const void *from, const void *to, size_t);	// Byte compare
 * void	bzero(void *ptr, size_t);		// Zero memory
 * char *strncpy(char *dest, const char *src, size_t n);
 */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -