📄 tcpip-openbsd-tcpip-apis.html
字号:
<!-- Copyright (C) 2003 Red Hat, Inc. --><!-- This material may be distributed only subject to the terms --><!-- and conditions set forth in the Open Publication License, v1.0 --><!-- or later (the latest version is presently available at --><!-- http://www.opencontent.org/openpub/). --><!-- Distribution of the work or derivative of the work in any --><!-- standard (paper) book form is prohibited unless prior --><!-- permission is obtained from the copyright holder. --><HTML><HEAD><TITLE>APIs</TITLE><meta name="MSSmartTagsPreventParsing" content="TRUE"><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+"><LINKREL="HOME"TITLE="eCos Reference Manual"HREF="ecos-ref.html"><LINKREL="UP"TITLE="OpenBSD TCP/IP Stack port for eCos"HREF="tcpip-openbsd.html"><LINKREL="PREVIOUS"TITLE="Building the Network Stack"HREF="tcpip-openbsd-building-the-network-stack.html"><LINKREL="NEXT"TITLE="Enhanced Select()"HREF="tcpip-openbsd-enhanced-select.html"></HEAD><BODYCLASS="CHAPTER"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">eCos Reference Manual</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="tcpip-openbsd-building-the-network-stack.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom"></TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="tcpip-openbsd-enhanced-select.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="CHAPTER"><H1><ANAME="TCPIP-OPENBSD-TCPIP-APIS">Chapter 44. APIs</H1><DIVCLASS="TOC"><DL><DT><B>Table of Contents</B></DT><DT><AHREF="tcpip-openbsd-tcpip-apis.html#TCPIP-OPENBSD-STANDARD-NETWORKING-API">Standard networking</A></DT><DT><AHREF="tcpip-openbsd-enhanced-select.html">Enhanced Select()</A></DT></DL></DIV><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="TCPIP-OPENBSD-STANDARD-NETWORKING-API">Standard networking</H1><P>The APIs for the standard networking calls such as<TTCLASS="FUNCTION">socket()</TT>, <TTCLASS="FUNCTION">recv()</TT> and so on, arein header files relative to the top-levelinclude directory, within the standard subdirectories as conventionallyfound in <TTCLASS="FILENAME">/usr/include</TT>. For example:<TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING"> install/include/arpa/tftp.h install/include/netinet/tcpip.h install/include/sys/socket.h install/include/sys/socketvar.h install/include/sys/sockio.h</PRE></TD></TR></TABLE></P><P><TTCLASS="FILENAME">network.h</TT> at the top leveldefines various extensions, for example the API<TTCLASS="FUNCTION">init_all_network_interfaces(void)</TT>describedabove. We advise including <TTCLASS="FILENAME">network.h</TT> whetheryou use these features or not.</P><P>In general, using the networking code may require definitionof two symbols: _KERNEL and __ECOS. _KERNELis not normally required; __ECOS is normally required.So add this to your compile lines for files which use the networkstack:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING"> -D__ECOS</PRE></TD></TR></TABLE><P>To expand a little, it’s like this because this isa port of a standard distribution external to Red Hat. One goalis to perturb the sources as little as possible, so that upgradingand maintenance from the external distribution is simplified. The __ECOSsymbol marks out Red Hat’s additions in making the port.The _KERNEL symbol is traditional UNIX practice: it distinguishesa compilation which is to be linked into the kernel from one whichis part of an application. eCos applications are fully linked,so this distinction does not apply. _KERNEL can howeverbe used to control the visibility of the internals of the stack,so depending on what features your application uses, it may or maynot be necessary.</P><P>The include file <TTCLASS="FILENAME">network.h</TT> undefines _KERNELunconditionally, to provide an application-like compilation environment.If you were writing code which, for example,enumerates the stack’s internalstructures, that is a kernel-like compilation environment, so youwould need to define _KERNEL (in addition to __ECOS)and avoid including <TTCLASS="FILENAME">network.h</TT>.</P></DIV></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="tcpip-openbsd-building-the-network-stack.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="ecos-ref.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="tcpip-openbsd-enhanced-select.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Building the Network Stack</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="tcpip-openbsd.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Enhanced Select()</TD></TR></TABLE></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -