<!-- Copyright (C) 2003 Red Hat, Inc. -->
|
<!-- Copyright (C) 2003 Red Hat, Inc. -->
|
<!-- This material may be distributed only subject to the terms -->
|
<!-- This material may be distributed only subject to the terms -->
|
<!-- and conditions set forth in the Open Publication License, v1.0 -->
|
<!-- and conditions set forth in the Open Publication License, v1.0 -->
|
<!-- or later (the latest version is presently available at -->
|
<!-- or later (the latest version is presently available at -->
|
<!-- http://www.opencontent.org/openpub/). -->
|
<!-- http://www.opencontent.org/openpub/). -->
|
<!-- Distribution of the work or derivative of the work in any -->
|
<!-- Distribution of the work or derivative of the work in any -->
|
<!-- standard (paper) book form is prohibited unless prior -->
|
<!-- standard (paper) book form is prohibited unless prior -->
|
<!-- permission is obtained from the copyright holder. -->
|
<!-- permission is obtained from the copyright holder. -->
|
<HTML
|
<HTML
|
><HEAD
|
><HEAD
|
><TITLE
|
><TITLE
|
>APIs</TITLE
|
>APIs</TITLE
|
><meta name="MSSmartTagsPreventParsing" content="TRUE">
|
><meta name="MSSmartTagsPreventParsing" content="TRUE">
|
<META
|
<META
|
NAME="GENERATOR"
|
NAME="GENERATOR"
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
|
"><LINK
|
"><LINK
|
REL="HOME"
|
REL="HOME"
|
TITLE="eCos Reference Manual"
|
TITLE="eCos Reference Manual"
|
HREF="ecos-ref.html"><LINK
|
HREF="ecos-ref.html"><LINK
|
REL="UP"
|
REL="UP"
|
TITLE="OpenBSD TCP/IP Stack port for eCos"
|
TITLE="OpenBSD TCP/IP Stack port for eCos"
|
HREF="tcpip-openbsd.html"><LINK
|
HREF="tcpip-openbsd.html"><LINK
|
REL="PREVIOUS"
|
REL="PREVIOUS"
|
TITLE="Building the Network Stack"
|
TITLE="Building the Network Stack"
|
HREF="tcpip-openbsd-building-the-network-stack.html"><LINK
|
HREF="tcpip-openbsd-building-the-network-stack.html"><LINK
|
REL="NEXT"
|
REL="NEXT"
|
TITLE="Enhanced Select()"
|
TITLE="Enhanced Select()"
|
HREF="tcpip-openbsd-enhanced-select.html"></HEAD
|
HREF="tcpip-openbsd-enhanced-select.html"></HEAD
|
><BODY
|
><BODY
|
CLASS="CHAPTER"
|
CLASS="CHAPTER"
|
BGCOLOR="#FFFFFF"
|
BGCOLOR="#FFFFFF"
|
TEXT="#000000"
|
TEXT="#000000"
|
LINK="#0000FF"
|
LINK="#0000FF"
|
VLINK="#840084"
|
VLINK="#840084"
|
ALINK="#0000FF"
|
ALINK="#0000FF"
|
><DIV
|
><DIV
|
CLASS="NAVHEADER"
|
CLASS="NAVHEADER"
|
><TABLE
|
><TABLE
|
SUMMARY="Header navigation table"
|
SUMMARY="Header navigation table"
|
WIDTH="100%"
|
WIDTH="100%"
|
BORDER="0"
|
BORDER="0"
|
CELLPADDING="0"
|
CELLPADDING="0"
|
CELLSPACING="0"
|
CELLSPACING="0"
|
><TR
|
><TR
|
><TH
|
><TH
|
COLSPAN="3"
|
COLSPAN="3"
|
ALIGN="center"
|
ALIGN="center"
|
>eCos Reference Manual</TH
|
>eCos Reference Manual</TH
|
></TR
|
></TR
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="10%"
|
WIDTH="10%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
><A
|
><A
|
HREF="tcpip-openbsd-building-the-network-stack.html"
|
HREF="tcpip-openbsd-building-the-network-stack.html"
|
ACCESSKEY="P"
|
ACCESSKEY="P"
|
>Prev</A
|
>Prev</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="80%"
|
WIDTH="80%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="10%"
|
WIDTH="10%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="bottom"
|
VALIGN="bottom"
|
><A
|
><A
|
HREF="tcpip-openbsd-enhanced-select.html"
|
HREF="tcpip-openbsd-enhanced-select.html"
|
ACCESSKEY="N"
|
ACCESSKEY="N"
|
>Next</A
|
>Next</A
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><HR
|
><HR
|
ALIGN="LEFT"
|
ALIGN="LEFT"
|
WIDTH="100%"></DIV
|
WIDTH="100%"></DIV
|
><DIV
|
><DIV
|
CLASS="CHAPTER"
|
CLASS="CHAPTER"
|
><H1
|
><H1
|
><A
|
><A
|
NAME="TCPIP-OPENBSD-TCPIP-APIS">Chapter 44. APIs</H1
|
NAME="TCPIP-OPENBSD-TCPIP-APIS">Chapter 44. APIs</H1
|
><DIV
|
><DIV
|
CLASS="TOC"
|
CLASS="TOC"
|
><DL
|
><DL
|
><DT
|
><DT
|
><B
|
><B
|
>Table of Contents</B
|
>Table of Contents</B
|
></DT
|
></DT
|
><DT
|
><DT
|
><A
|
><A
|
HREF="tcpip-openbsd-tcpip-apis.html#TCPIP-OPENBSD-STANDARD-NETWORKING-API"
|
HREF="tcpip-openbsd-tcpip-apis.html#TCPIP-OPENBSD-STANDARD-NETWORKING-API"
|
>Standard networking</A
|
>Standard networking</A
|
></DT
|
></DT
|
><DT
|
><DT
|
><A
|
><A
|
HREF="tcpip-openbsd-enhanced-select.html"
|
HREF="tcpip-openbsd-enhanced-select.html"
|
>Enhanced Select()</A
|
>Enhanced Select()</A
|
></DT
|
></DT
|
></DL
|
></DL
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="SECT1"
|
CLASS="SECT1"
|
><H1
|
><H1
|
CLASS="SECT1"
|
CLASS="SECT1"
|
><A
|
><A
|
NAME="TCPIP-OPENBSD-STANDARD-NETWORKING-API">Standard networking</H1
|
NAME="TCPIP-OPENBSD-STANDARD-NETWORKING-API">Standard networking</H1
|
><P
|
><P
|
>The APIs for the standard networking calls such as
|
>The APIs for the standard networking calls such as
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>socket()</TT
|
>socket()</TT
|
>, <TT
|
>, <TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>recv()</TT
|
>recv()</TT
|
> and so on, are
|
> and so on, are
|
in header files relative to the top-level
|
in header files relative to the top-level
|
include directory, within the standard subdirectories as conventionally
|
include directory, within the standard subdirectories as conventionally
|
found in <TT
|
found in <TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>/usr/include</TT
|
>/usr/include</TT
|
>. For example:
|
>. For example:
|
<TABLE
|
<TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="PROGRAMLISTING"
|
CLASS="PROGRAMLISTING"
|
> install/include/arpa/tftp.h
|
> install/include/arpa/tftp.h
|
install/include/netinet/tcpip.h
|
install/include/netinet/tcpip.h
|
install/include/sys/socket.h
|
install/include/sys/socket.h
|
install/include/sys/socketvar.h
|
install/include/sys/socketvar.h
|
install/include/sys/sockio.h</PRE
|
install/include/sys/sockio.h</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
></P
|
></P
|
><P
|
><P
|
><TT
|
><TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>network.h</TT
|
>network.h</TT
|
> at the top level
|
> at the top level
|
defines various extensions, for example the API
|
defines various extensions, for example the API
|
<TT
|
<TT
|
CLASS="FUNCTION"
|
CLASS="FUNCTION"
|
>init_all_network_interfaces(void)</TT
|
>init_all_network_interfaces(void)</TT
|
>
|
>
|
described
|
described
|
above. We advise including <TT
|
above. We advise including <TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>network.h</TT
|
>network.h</TT
|
> whether
|
> whether
|
you use these features or not.</P
|
you use these features or not.</P
|
><P
|
><P
|
>In general, using the networking code may require definition
|
>In general, using the networking code may require definition
|
of two symbols: _KERNEL and __ECOS. _KERNEL
|
of two symbols: _KERNEL and __ECOS. _KERNEL
|
is not normally required; __ECOS is normally required.
|
is not normally required; __ECOS is normally required.
|
So add this to your compile lines for files which use the network
|
So add this to your compile lines for files which use the network
|
stack:</P
|
stack:</P
|
><TABLE
|
><TABLE
|
BORDER="5"
|
BORDER="5"
|
BGCOLOR="#E0E0F0"
|
BGCOLOR="#E0E0F0"
|
WIDTH="70%"
|
WIDTH="70%"
|
><TR
|
><TR
|
><TD
|
><TD
|
><PRE
|
><PRE
|
CLASS="PROGRAMLISTING"
|
CLASS="PROGRAMLISTING"
|
> -D__ECOS</PRE
|
> -D__ECOS</PRE
|
></TD
|
></TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
><P
|
><P
|
>To expand a little, it’s like this because this is
|
>To expand a little, it’s like this because this is
|
a port of a standard distribution external to Red Hat. One goal
|
a port of a standard distribution external to Red Hat. One goal
|
is to perturb the sources as little as possible, so that upgrading
|
is to perturb the sources as little as possible, so that upgrading
|
and maintenance from the external distribution is simplified. The __ECOS
|
and maintenance from the external distribution is simplified. The __ECOS
|
symbol marks out Red Hat’s additions in making the port.
|
symbol marks out Red Hat’s additions in making the port.
|
The _KERNEL symbol is traditional UNIX practice: it distinguishes
|
The _KERNEL symbol is traditional UNIX practice: it distinguishes
|
a compilation which is to be linked into the kernel from one which
|
a compilation which is to be linked into the kernel from one which
|
is part of an application. eCos applications are fully linked,
|
is part of an application. eCos applications are fully linked,
|
so this distinction does not apply. _KERNEL can however
|
so this distinction does not apply. _KERNEL can however
|
be used to control the visibility of the internals of the stack,
|
be used to control the visibility of the internals of the stack,
|
so depending on what features your application uses, it may or may
|
so depending on what features your application uses, it may or may
|
not be necessary.</P
|
not be necessary.</P
|
><P
|
><P
|
>The include file <TT
|
>The include file <TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>network.h</TT
|
>network.h</TT
|
> undefines _KERNEL
|
> undefines _KERNEL
|
unconditionally, to provide an application-like compilation environment.
|
unconditionally, to provide an application-like compilation environment.
|
If you were writing code which, for example,
|
If you were writing code which, for example,
|
enumerates the stack’s internal
|
enumerates the stack’s internal
|
structures, that is a kernel-like compilation environment, so you
|
structures, that is a kernel-like compilation environment, so you
|
would need to define _KERNEL (in addition to __ECOS)
|
would need to define _KERNEL (in addition to __ECOS)
|
and avoid including <TT
|
and avoid including <TT
|
CLASS="FILENAME"
|
CLASS="FILENAME"
|
>network.h</TT
|
>network.h</TT
|
>.</P
|
>.</P
|
></DIV
|
></DIV
|
></DIV
|
></DIV
|
><DIV
|
><DIV
|
CLASS="NAVFOOTER"
|
CLASS="NAVFOOTER"
|
><HR
|
><HR
|
ALIGN="LEFT"
|
ALIGN="LEFT"
|
WIDTH="100%"><TABLE
|
WIDTH="100%"><TABLE
|
SUMMARY="Footer navigation table"
|
SUMMARY="Footer navigation table"
|
WIDTH="100%"
|
WIDTH="100%"
|
BORDER="0"
|
BORDER="0"
|
CELLPADDING="0"
|
CELLPADDING="0"
|
CELLSPACING="0"
|
CELLSPACING="0"
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="tcpip-openbsd-building-the-network-stack.html"
|
HREF="tcpip-openbsd-building-the-network-stack.html"
|
ACCESSKEY="P"
|
ACCESSKEY="P"
|
>Prev</A
|
>Prev</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="34%"
|
WIDTH="34%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="ecos-ref.html"
|
HREF="ecos-ref.html"
|
ACCESSKEY="H"
|
ACCESSKEY="H"
|
>Home</A
|
>Home</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="tcpip-openbsd-enhanced-select.html"
|
HREF="tcpip-openbsd-enhanced-select.html"
|
ACCESSKEY="N"
|
ACCESSKEY="N"
|
>Next</A
|
>Next</A
|
></TD
|
></TD
|
></TR
|
></TR
|
><TR
|
><TR
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="left"
|
ALIGN="left"
|
VALIGN="top"
|
VALIGN="top"
|
>Building the Network Stack</TD
|
>Building the Network Stack</TD
|
><TD
|
><TD
|
WIDTH="34%"
|
WIDTH="34%"
|
ALIGN="center"
|
ALIGN="center"
|
VALIGN="top"
|
VALIGN="top"
|
><A
|
><A
|
HREF="tcpip-openbsd.html"
|
HREF="tcpip-openbsd.html"
|
ACCESSKEY="U"
|
ACCESSKEY="U"
|
>Up</A
|
>Up</A
|
></TD
|
></TD
|
><TD
|
><TD
|
WIDTH="33%"
|
WIDTH="33%"
|
ALIGN="right"
|
ALIGN="right"
|
VALIGN="top"
|
VALIGN="top"
|
>Enhanced Select()</TD
|
>Enhanced Select()</TD
|
></TR
|
></TR
|
></TABLE
|
></TABLE
|
></DIV
|
></DIV
|
></BODY
|
></BODY
|
></HTML
|
></HTML
|
|
|