资源简介
linux操作系统下手工安装openssh的tar安装包(openssh-8.2.tar.gz)《openssh-8.2.tar.gz》
代码片段和文件信息
/* $OpenBSD: addrmatch.cv 1.14 2018/07/31 03:07:24 djm Exp $ */
/*
* Copyright (c) 2004-2008 Damien Miller
*
* Permission to use copy modify and distribute this software for any
* purpose with or without fee is hereby granted provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED “AS IS“ AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL DIRECT INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE DATA OR PROFITS WHETHER IN AN
* ACTION OF CONTRACT NEGLIGENCE OR OTHER TORTIOUS ACTION ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include “match.h“
#include “log.h“
struct xaddr {
sa_family_t af;
union {
struct in_addr v4;
struct in6_addr v6;
u_int8_t addr8[16];
u_int32_t addr32[4];
} xa; /* 128-bit address */
u_int32_t scope_id; /* iface scope id for v6 */
#define v4 xa.v4
#define v6 xa.v6
#define addr8 xa.addr8
#define addr32 xa.addr32
};
static int
addr_unicast_masklen(int af)
{
switch (af) {
case AF_INET:
return 32;
case AF_INET6:
return 128;
default:
return -1;
}
}
static inline int
masklen_valid(int af u_int masklen)
{
switch (af) {
case AF_INET:
return masklen <= 32 ? 0 : -1;
case AF_INET6:
return masklen <= 128 ? 0 : -1;
default:
return -1;
}
}
/*
* Convert struct sockaddr to struct xaddr
* Returns 0 on success -1 on failure.
*/
static int
addr_sa_to_xaddr(struct sockaddr *sa socklen_t slen struct xaddr *xa)
{
struct sockaddr_in *in4 = (struct sockaddr_in *)sa;
struct sockaddr_in6 *in6 = (struct sockaddr_in6 *)sa;
memset(xa ‘\0‘ sizeof(*xa));
switch (sa->sa_family) {
case AF_INET:
if (slen < (socklen_t)sizeof(*in4))
return -1;
xa->af = AF_INET;
memcpy(&xa->v4 &in4->sin_addr sizeof(xa->v4));
break;
case AF_INET6:
if (slen < (socklen_t)sizeof(*in6))
return -1;
xa->af = AF_INET6;
memcpy(&xa->v6 &in6->sin6_addr sizeof(xa->v6));
xa->scope_id = in6->sin6_scope_id;
break;
default:
return -1;
}
return 0;
}
/*
* Calculate a netmask of length ‘l‘ for address family ‘af‘ and
* store it in ‘n‘.
* Returns 0 on success -1 on failure.
*/
static int
addr_netmask(int af u_int l struct xaddr *n)
{
int i;
if (masklen_valid(af l) != 0 || n == NULL)
return -1;
memset(n ‘\0‘ sizeof(*n));
switch (af) {
case AF_INET:
n->af = AF_INET;
if (l == 0)
return 0;
n->v4.s_addr = htonl((0xffffffff << (32 - l)) & 0xffffffff);
return 0;
case AF_INET6:
n->af = AF_INET6;
for (i = 0; i < 4 && l >= 32; i++ l -= 32)
n->addr32[i] = 0xf
相关资源
- Linux常用命令全集260354
- smartctl源码
- Linux命令大全完整版.pdf
- Linux ATM取款机简单实现附详细说明-
- 2018年最新全套linux视频教程源码笔记
- 华中科技大学计算机学院操作系统一
- linux使用规范
- libsigar-amd64-linux.so以及libsigar-x86-linu
- linux哲学家就餐3种方法代码实现
- centos 7的telnet安装包.zip
- Linux版本浙江闪讯拨号连接
- Linux 下多线程数字排序
- pcap 在linux简单实现网络的抓包程序
- 在Linux环境下模拟实现命令解释器--操
- linux 线程池封装类
- 嵌入式linux 应用程序开发框架之模块
- linux 常用压测命令
- linux下shell编程
- linux usb hid device端测试程序
- 用qml简单的文本编辑器,可以跨平台
- LINUX下的一个多线程的服务器和客户端
- tcpdump-4.9.0-5.el7.x86_64.rpm
- Linux C利用多进程或多线程模拟实现生
- linux下用freetype2显示汉字
- lsof-4.82-4.el6.x86_64.rpm
- Linux操作系统设计实践报告一
- 等保主机安全基线合规--配置指导li
- linux ls命令 源代码
- linux 系统调用 实现文件复制
- linux kernel系统函数调用层次图
评论
共有 条评论