unix网络编程中的unp.h_weixin_34301307的博客-程序员宅基地

技术标签: python  网络  

/* Our own header. Tabs are set for 4 spaces,not 8 */
#ifndef __unp_h
#define __unp_h
#include "/usr/lib/perl5/5.8.0/i386-linux-thread-multi/CORE/config.h"    /* configuration options for current OS */
                /* "../config.h" is generated by configure */
/* If anything changes in the following list of #includes,must change
 acsite.m4 also,for configure's tests */
#include<sys/types.h>        /* basic system data types */
#include<sys/socket.h>       /* basic socket definations */
#include<sys/time.h>         /* timeval{} for select() */
#include<time.h>             /* timespec{} for pselect() */
#include<netinet/in.h>       /* sockaddr_in{} and other Internet defns */
#include<arpa/inet.h>        /* inet(3) functions */
#include<errno.h>
#include<fcntl.h>            /* for nonblocking */
#include<netdb.h>
#include<signal.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<sys/stat.h>         /* for S_xxx file mode constants */
#include<sys/uio.h>          /* for iovec{} and readv /writev */
#include<unistd.h>
#include<sys/wait.h>
#include<sys/un.h>           /* for Unix domain sockets */
#ifdef HAVE_SYS_SELECT_H
#include<sys/select.h>       /* for convenience */
#endif
#ifdef HAVE_SYS_SYSCTL_H
#include<sys/sysctl.h>
#endif
#ifdef HAVE_POLL_H
#include<poll.h>             /* for convenience */
#endif
#ifdef HAVE_SYS_EVENT_H
#include<sys/event.h>      /* for kqueue */
#endif
#ifdef HAVE_STRINGS_H
#include<strings.h>           /* for convenience */
#endif
/* Three headers are normally needed for socket/file ioctl's;
 * <sys/ioctl.h>,<sys/fillo.h>,and <sys/sockio.h>.
 */
#ifdef HAVE_SYS_IOCTL_H
#include<sys/ioctl.h>
#endif
#ifdef HAVE_SYS_FILIO_H
#include<sys/filio.h>
#endif
#ifdef HAVE_SYS_SOCKIO_H
#include<sys/sockio.h>
#endif
#ifdef HAVE_PTHREAD_H
#include<pthread.h>
#endif
#ifdef HAVE_NET_IF_DL_H
#include<net/if_dl.h>
#endif
#ifdef HAVE_NETINET_SCTP_H
#include<netinet/sctp.h>
#endif
/* OSF/1 actually disables recv() and send() in <sys/socket.h> */
#ifdef  __osf__
#undef recv
#undef send
#define recv(a,b,c,d) recvfrom(a,b,c,d,0,0)
#define send(a,b,c,d) sendto(a,b,c,d,0,0)
#endif
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff    /* should have been in <netinet/in.h> */
#endif
#ifndef SHUT_RD                   /* these three POSIX names are quite new */
#define SHUT_RD     0             /* shutdown for reading */
#define SHUT_WR     1             /* shutdown for writing */
#define SHUT_RDWR   2             /* shutdown for reading and writing */
#endif
#ifndef INET_ADDRSTRLEN
#define INET_ADDRSTRLEN   16      /* "ddd.ddd.ddd.ddd\0"
                                      1234567890123456 */
#endif
/* Define following even if IPv6 not supported,so we can always allocate
 an adequately sized buffer,without #ifdefs in the code. */
#ifndef INET6_ADDRSRLEN
#define INET6_ADDRSTRLEN  46      /* max size of IPv6 address string;
            "xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx" or
            "xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:ddd.ddd.ddd.ddd\0"
             1234567890123456789012345678901234567890123456 */
#endif
/* Define bzero() as a macro if it's not in standard C library. */
#ifndef HAVE_BZERO
#define bzero(ptr,n)      memset(ptr,0,n)
#endif
/* Older resolves do not have gethostbyname2() */
#ifndef HAVE_GETHOSTBYNAME2
#define gethostbyname2(host,family)     gethostbyname((host))
#endif
/* The structure returned by recvform_flags() */
struct unp_in_pktinfo{
    struct in_addr ipi_addr;       /* dst IPv4 address */
    int ipi_ifindex;               /* received interface index */
};
/* We need the newer CMSG_LEN() and CMSG_SPACE() macros,but few
 implementations support them today.  These two macros really need
 an ALIGN() macro, but each implementation does this differently. */
#ifndef CMSG_LEN
#define CMSG_LEN(size)   (sizeof(struct cmsghdr)+(size))
#endif
#ifndef CMSG_SPACE
#define CMSG_SPACE(size)   (sizeof(struct cmsghdr)+(size))
#endif
/* POSIX requires the SUN_LEN() macro, but not all implementations define
  it(yet). Note that this 4.4BSD macro works regardless whether there is
  a length field or not. */
#ifndef SUN_LEN
#define SUN_LEN(su) \
   (sizeof(*(su)-sizeof((su)->sun_path)+strlen((su)->sun_path))
#endif
/* POSIX renames "Unix domain" as "local IPC".
  But not all systems define AF_LCOAL and PF_LOCAL(yet). */
#ifndef AF_LOCAL
#define AF_LOCAL AF_UNIX
#endif
#ifndef PF_LOCAL
#define PF_LOCAL PF_UNIX
#endif
/* POSIX requires that an #include of<poll.h> define INFTIM,but many
 systems still define it in <sys/stropts.h>. We don't want to include
 all the streams stuff if it's not needed,so we just define INFTIME here.
 This is the standard value,but there's no guarantee it is -1. */
#ifndef INFTIM
#define INFTIM     (-1)  /* infinite poll timeout */
#ifdef HAVE_POLL_H
#define INFTIM_UNPH      /* tell unpxti.h we defined it */
#endif
#endif
/* Following could be derived from SOMAXCONN in <sys/socket.h>,but many
 kernels still #define it as 5,while actually supporting many more */
#define LISTENQ 1024     /* 2nd argument to listen() */
/* Miscellaneous constants */
#define MAXLINE 4096     /* max text line length */
#define BUFFSIZE 8192    /* buffer size for reads and writes */
/* Define some port number that can be used for our examples */
#define SERV_PORT  9877  /* TCP and UDP */
#define SERV_PORT_STR  "9877"   /* TCP and UDP */
#define UNIXSTR_PATH  "/tmp/unix.str"  /* Unix domain stream */
#define UNIXDG_PATH  "/tmp/unix.dg" /* Unix domain datagram */
/* Following shortens all the type casts of pointer arguments */
#define SA struct sockaddr
#define HAVE_STRUCT_SOCKADDR_STORAGE
#ifndef HAVE_STRUCT_SOCKADDR_STORAGE
/*
 * RFC 3493: protocol-independent placeholder for socket addresses
 */
#define __ss_MAXSIZE 128
#define __ss_ALIGNSIZE (sizeof(int64_t))
#ifdef HAVE_SOCKADDR_SA_LEN
#define __SS_PADlSIZE (__SS_ALIGNSIZE-sizeof(u_char)-sizeof(sa_family_t))
#else
#define __SS_PADlSIZE (__SS_ALIGNSIZE-sizeof(sa_family_t))
#endif
#define __SS_PAD2SIZE (__SS_MAXSIZE-2*__SS_ALIGNSIZE)
struct sockaddr_storage{
#ifdef HAVE_SOCKADDR_SA_LEN
 u_char ss_len;
#endif
 sa_family_t ss_family;
 char __ss_pad1[__SS_PAD1SIZE];
 int64_t __ss_align;
 char __ss_pad2[__SS_PAD2SIZE];
};
#endif
#define FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
                  /* default file access permissions for new files */
#define DIR_MODE (FILE_MODE | S_IXUSR | S_IXGRP | S_IXOTH)
   /* default permissions for new directories */
typedef void Sigfunc(int);   /* for signal handlers */
#define min(a,b)    ((a)<(b)?(a):(b))
#define max(a,b)    ((a)>(b)?(a):(b))
#ifndef HAVE_ADDRINFO_STRUCT
#include "../lib/addrinfo.h"
#endif
#ifndef HAVE_IF_NAMEINDEX_STRUCT
struct if_nameindex{
    unsigned int if_index;    /* 1,2,... */
    char    *if_name;            /* null teminated name:""le0",...*/
};
#endif
#ifndef HAVE_TIMESPEC_STRUCT
struct timespec{
    time_t tv_sec;           /* seconds */
    long   tv_nsec;          /* and nanoseconds */
};
#endif

转载于:https://my.oschina.net/u/2546684/blog/667311

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_34301307/article/details/92323980

智能推荐

MySql的like语句中的通配符:百分号、下划线和escape_下划线和百分号在数据库是什么意思-程序员宅基地

MySql的like语句中的通配符:百分号、下划线和escape%:表示任意个或多个字符。可匹配任意类型和长度的字符。Sql代码select * from user where username like ‘%huxiao’;select * from user where username like ‘huxiao%’;select * from user where username like ‘%huxiao%’;另外,如果需要找出u_name中既有“三”又有“猫”的记录,请使用and条件_下划线和百分号在数据库是什么意思

鸿蒙系统移植到 FPGA,我把 ncnn 移植到 RISC-V 啦!-程序员宅基地

有人预言,RISC-V或将是继Intel和Arm之后的第三大主流处理器体系。欢迎访问全球首家只专注于RISC-V单片机行业应用的中文网站您需要 登录 才可以下载或查看,没有帐号?立即注册x本帖最后由 sky 于 2020-9-16 10:15 编辑移植01.jpg (131.33 KB, 下载次数: 0)2020-9-16 10:14 上传可以转载,但不准删改内容!RISC-V,我喜欢缩写成 ri..._我ncnn

Navicat链接树莓派Mysql报错2003_navicat远程连接树莓派上的mysql-程序员宅基地

Navicat链接树莓派Mysql报错2003解决方法:1、确定树莓派装了 Mysql2、mysql -u root -p回车,输入密码回车,登录3、授权远程用户登录a. 对所有 root 用户授权:GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘root用户密码’ WITH GRANT OPTION;b. 对指定 IP ..._navicat远程连接树莓派上的mysql

物联网如何赋能污水治理_互联网 处理污水-程序员宅基地

将“物联网”视为一种思维方式:将物理对象和处理现场连接到互联网,并且在云端统一部署解决方案、处理逻辑,以便更迅速、有效地监控它们、指挥它们、纠正它们。_互联网 处理污水

基于Spring Boot技术栈博客系统企业级前后端实战_spring boot技术栈博客企业前后端 百度云-程序员宅基地

实战课程项目-基于Spring boot博客的搭建教程技术栈后端: SpringBoot+ElasticSearch+SpringSecurity前端: Thymeleaf/Bootstrap/jQuery数据库:MySQL/MongoDB/H2技术语言 jdk 1.8开发平台 Idea 2018 +win10项目简介:视频简介项目源码:github仓..._spring boot技术栈博客企业前后端 百度云

2018-2019-1 20165207 20165209 20165215 实验二——固件程序设计-程序员宅基地

2018-2019-1 20165207 20165209 20165215 实验二——固件程序设计任务一 MDK实验目的1. 参考云班课资源中“信息安全系统实验箱指导书.pdf “第一章,1.1-1.5安装MDK,JLink驱动,注意,要用系统管理员身分运行uVision4,破解MDK(破解程序中target一定选ARM)2. 提交破解程序中产生LIC的截图3. 提交破解成功的截图..._mdk-arm_addon_sc000_support

随便推点

最新豆瓣API接口_https://img2.doubanio.com/view/photo/s_ratio_poste-程序员宅基地

前段时间豆瓣API不能访问了, 今天军哥自己在服务器上部署 了一套,仅供学习交流技术交流QQ群 277030213豆瓣 api php项目 https://github.com/wenyanjun/douban豆瓣 api 地址 服务器地址 http://106.55.173.177:8081/index.php/top250?page=01.搜索接口 http://106.55.173.177:8081/index.php/search?q=肖申克的救赎&page=0请求参数 ._https://img2.doubanio.com/view/photo/s_ratio_poster/public/p2372307693.jpg

考试反思_反思考试。-程序员宅基地

考试反思经过了这次考试,我收获到了1、考试时要专心,不能一心多用,打题目时要仔细,不能发呆,偷看或有偷看别人的意图产生;2、不能紧张,要冷静,否则想不出来题目; 3、我应该多思考,不能不动脑,不然考试的时候会懒得想题目,以至时间一分一秒流逝,题目都打不出来,从而很紧张;4、做题目时要尽量往简单的方面想,不然既耽误了时间,又a不了,电脑还会累死;5、能少用循环尽量少用循环,否则容易超时;仅此而已。..._反思考试。

海思Hi3518EV200硬件介绍-程序员宅基地

1.硬件:HI3518E V200是ARM9内核的CPU,集成64M的DDR以及各种内部外设组成SOC外扩8M的spi flash以及各种外部外设组成HI3518EV2002.音视频编码:支持H264(AVC),H265(HENV )和MJPEG编码,音频也是支持AAC的音频编码H.264/H.265 编码可支持最大分辨率为 2M Pixel,也就是1080*1920的分辨率H.264/H.265 多码流实时编码能力,而在程序中我们使用的是3路码流输出并且支持JPEG抓拍2M ._hi3518ev200

网络安全-sqlmap实战之sqlilabs-Less11-程序员宅基地

目录类型-dbs枚举数据库--tables枚举数据库表--columns枚举列--dump枚举数据查看源代码类型基于错误-字符串登陆成功当然,因为之前已经通过sql注入看到了数据库,正常情况下应该是失败,而且网站一般有验证码。登录失败错误回显sql语句猜测select * from users where username="参数" and password="参数" LIMIT 0,1-dbs枚举数据库使用-o参数优化,--batch

pod curl: (22) The requested URL returned error: 403 Forbidden_curl 22_skyhh的博客-程序员宅基地

这里写自定义目录标题欢迎使用Markdown编辑器新的改变功能快捷键合理的创建标题,有助于目录的生成如何改变文本的样式插入链接与图片如何插入一段漂亮的代码片生成一个适合你的列表创建一个表格设定内容居中、居左、居右SmartyPants创建一个自定义列表如何创建一个注脚注释也是必不可少的KaTeX数学公式新的甘特图功能,丰富你的文章UML 图表FLowchart流程图导出与导入导出导入欢迎使用Markdown编辑器你好! 这是你第一次使用 Markdown编辑器 所展示的欢迎页。如果你想学习如何使用Mar_curl 22

Vue学习组件化-程序员宅基地

Vue学习笔记----组件化组件的创建私有组件组件中的data组件的创建Vue.extend创建全局Vue组件<body> <div id="app"> <!-- 如果要使用组件,直接把组件的名称 以HTML标签的形式 引入到页面中 --> <my-com1></my-com1> ...