怎么理解(*ifp->if_if you start me up)(ifp)

国际高中课程核心服务
国际预科课程(International Fundamental Program)是美国文化教育委员会与美国的众多一流高校合作设计的大学基础课程。狄邦教育获得CACE的唯一授权,将该课程引入中国,开设国际预科课程。
国际预科课程主要针对两类学生群体:已经决定放弃高考并决意出国留学的高二在读学生,和已经参加高考、但成绩不够理想从而决定出国的高三毕业学生。课程旨在利用学生暑假及随后一学年的时间,通过一系列学术英语课程、TOEFL/IELTS备考课程、美国/西方社会与文化课程、大学学术技能课程以及美国大学数学、科学等部分基础学科的课程,帮助学生在了解美国社会与文化的同时,全面提高学生的英语水平、专业课程的学习能力和大学学术技能,为学生将来更好地适应西方大学的教学方式,更快地进入学习状态和融入西方社会打好基础。
国际预科课程同时兼顾加拿大、英国、澳大利亚等主要英语国家的大学对大学基础课程的要求,课程涵盖大学学术技能、高等数学基础、统计学、商学、经济学、科学、社会与文化等,帮助学生率先掌握学习方法与课程内容,为直升海外大学打下扎实基础。
版权所有:狄邦教育管理集团* Copyright (c)
* The Regents of the University of California.
All rights reserved.
* This code is derived from software contributed to Berkeley by
* Sony Corp. and Kazumasa Utashiro of Software Research Associates, Inc.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED.
IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* from: $Hdr: if_en.c,v 4.300 91/06/09 06:25:54 root Rel41 $ SONY
* @(#)if_en.c 8.1 (Berkeley) 6/11/93
#include "en.h"
#include "rawether.h"
#include "bpfilter.h"
#if NEN > 0
* Interlan Ethernet Communications Controller interface
#ifdef INET
#ifdef CPU_SINGLE
#define iop_device hb_device
#define iop_driver hb_driver
#define ii_unit
#define ii_intr
#define ii_alive hi_alive
int enprobe(), enattach(), enrint(), enxint();
struct mbuf *m_devget();
#ifdef CPU_SINGLE
struct hb_device *eninfo[NEN];
struct hb_driver endriver = { enprobe, 0, enattach, 0, 0, "en", eninfo };
struct iop_device *eninfo[NEN];
struct iop_driver endriver = { enprobe, 0, enattach, 0, "en", eninfo };
#define ENUNIT(x) minor(x)
int eninit(),enioctl(),enreset(),enwatch(),enstart();
int endebug = 0;
struct ether_addr {
u_char addr[6];
struct en_softc en_softc[NEN];
#if NBPFILTER > 0
enprobe(ii)
struct iop_device *
return (en_probe(ii));
* Interface exists: make available by filling in network interface
System will initialize the interface when it is ready
* to accept packets.
A STATUS command is done to get the ethernet
* address and other interesting data.
enattach(ii)
register struct iop_device *
register struct en_softc *es = &en_softc[ii->ii_unit];
register struct ifnet *ifp = &es->es_
extern char *ether_sprintf();
en_attach(ii->ii_unit);
printf("en%d: hardware address %s\n",
ii->ii_unit, ether_sprintf((u_char *)es->es_addr));
ifp->if_unit = ii->ii_
ifp->if_name = "en";
ifp->if_mtu = ETHERMTU;
ifp->if_init =
ifp->if_ioctl =
ifp->if_output = ether_
#ifdef NOTDEF /* KU:XXX if_reset is obsolete */
ifp->if_reset =
ifp->if_start =
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX;
#if NBPFILTER > 0
bpfattach(&es->es_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
if_attach(ifp);
* Reset of interface after IOP reset.
enreset(unit)
register struct iop_device *
if (unit >= NEN || (ii = eninfo[unit]) == 0 || ii->ii_alive == 0)
printf(" en%d", unit);
en_softc[unit].es_if.if_flags &= ~(IFF_RUNNING|IFF_OACTIVE);
en_softc[unit].es_flags &= ~ENF_RUNNING;
eninit(unit);
* Initial clear recorded pending
* operations, and reinitialize IOP usage.
eninit(unit)
register struct en_softc *es = &en_softc[unit];
register struct ifnet *ifp = &es->es_
/* not yet, if address still unknown */
if (ifp->if_addrlist == (struct ifaddr *)0)
if (es->es_flags & ENF_RUNNING)
if ((ifp->if_flags & IFF_RUNNING) == 0) {
if (if_newsinit(&es->es_ifnews,
sizeof (struct en_rheader), (int)btoc(ETHERMTU)) == 0) {
printf("en%d: can't initialize\n", unit);
es->es_if.if_flags &= ~IFF_UP;
ifp->if_watchdog =
es->es_interval = ENWATCHINTERVAL;
ifp->if_timer = es->es_
s = splimp();
en_init(unit);
es->es_if.if_flags |= IFF_RUNNING|IFF_NOTRAILERS;
es->es_flags |= ENF_RUNNING;
* Start output on interface.
* Get another datagram to send off of the interface queue,
* and map it to the interface before starting the output.
enstart(ifp)
register struct ifnet *
int unit = ifp->if_unit,
register struct en_softc *es = &en_softc[unit];
register struct mbuf *m;
IF_DEQUEUE(&es->es_if.if_snd, m);
if (m == 0)
return(0);
#ifdef CPU_SINGLE
es->es_ifnews.ifn_waddr = (caddr_t)get_xmit_buffer(unit);
len = if_wnewsput(&es->es_ifnews, m);
* Ensure minimum packet length.
* This makes the safe assumtion that there are no virtual holes
* after the data.
* For security, it might be wise to zero out the added bytes,
* but we're mainly interested in speed at the moment.
if (len - sizeof(struct ether_header) es_if.if_flags |= IFF_OACTIVE;
(void) splx(s);
/* KU:XXX */
#if NBPFILTER > 0
* If bpf is listening on this interface, let it
* see the packet before we commit it to the wire.
if (es->es_bpf) {
#ifdef CPU_SINGLE
bpf_tap(es->es_bpf, es->es_ifnews.ifn_waddr, len);
bpf_mtap(es->es_bpf, m);
#endif /* NBPFILTER > 0 */
return(0);
* Transmit done interrupt.
_enxint(unit, error, collision)
int error,
register struct en_softc *es = &en_softc[unit];
#ifdef notyet /* KU:XXX */
intrcnt[INTR_ETHER0 + unit]++;
if ((es->es_if.if_flags & IFF_OACTIVE) == 0) {
printf("en%d: stray xmit interrupt\n", unit);
es->es_if.if_flags &= ~IFF_OACTIVE;
es->es_if.if_opackets++;
if (error)
es->es_if.if_oerrors++;
if (collision)
es->es_if.if_collisions++;
enstart(&es->es_if);
* Ethernet interface receiver interrupt.
* If input error just drop packet.
* Otherwise purge input buffered data path and examine
* packet to determine type.
If can't determine length
* from type, then have to drop packet.
Othewise decapsulate
* packet based on type and pass to type specific higher-level
* input routine.
_enrint(unit, len)
register struct en_softc *es = &en_softc[unit];
register struct en_rheader *
struct mbuf *m;
int off, resid,
register struct ensw *
extern struct mbuf *if_rnewsget();
#if defined(mips) && defined(CPU_SINGLE)
int bxcopy();
#ifdef notyet /* KU:XXX */
intrcnt[INTR_ETHER0 + unit]++;
es->es_if.if_ipackets++;
if ((es->es_flags & ENF_RUNNING) == 0)
en = (struct en_rheader *)(es->es_ifnews.ifn_raddr);
ETHERMTU) {
es->es_if.if_ierrors++;
#if NBPFILTER > 0
* Check if there's a bpf filter listening on this interface.
* If so, hand off the raw packet to enet.
if (es->es_bpf) {
bpf_tap(es->es_bpf, es->es_ifnews.ifn_raddr,
len + sizeof(struct en_rheader));
* Note that the interface cannot be in promiscuous mode if
* there are no bpf listeners. And if we are in promiscuous
* mode, we have to check if this packet is really ours.
* XXX This test does not support multicasts.
if ((es->es_if.if_flags & IFF_PROMISC)
&& bcmp(en->enr_dhost, es->es_addr,
sizeof(en->enr_dhost)) != 0
&& bcmp(en->enr_dhost, etherbroadcastaddr,
sizeof(en->enr_dhost)) != 0)
#endif /* NBPFILTER > 0 */
* Deal with trailer protocol: if type is trailer type
* get true type from first 16-bit word past data.
* Remember that type was trailer by setting off.
en->enr_type = ntohs((u_short)en->enr_type);
#define endataaddr(en, off, type) ((type)(((caddr_t)((en)+1)+(off))))
if (en->enr_type >= ETHERTYPE_TRAIL &&
en->enr_type enr_type - ETHERTYPE_TRAIL) * 512;
if (off >= ETHERMTU)
en->enr_type = ntohs(*endataaddr(en, off, u_short *));
resid = ntohs(*(endataaddr(en, off+2, u_short *)));
if (off + resid > len)
len = off +
* Pull packet off interface.
Off is nonzero if packet
* m_devget will then force this header
* information to be at the front, but we still have to drop
* the type and length which are at the front of any trailer data.
* KU:XXX really?
type = en->enr_
#if defined(mips) && defined(CPU_SINGLE)
m = m_devget((char *)(en + 1), len, off, &es->es_if, bxcopy);
m = m_devget((char *)(en + 1), len, off, &es->es_if, 0);
if (m == 0)
ether_input(&es->es_if, (struct ether_header *) en->enr_dhost, m);
* Watchdog routine, request statistics from board.
enwatch(unit)
register struct en_softc *es = &en_softc[unit];
register struct ifnet *ifp = &es->es_
ifp->if_timer = es->es_
* Process an ioctl request.
enioctl(ifp, cmd, data)
register struct ifnet *
register struct ifaddr *ifa = (struct ifaddr *)
register struct en_softc *es = &en_softc[ifp->if_unit];
register struct ensw *
int s = splimp(), error = 0;
switch (cmd) {
case SIOCSIFADDR:
ifp->if_flags |= IFF_UP;
eninit(ifp->if_unit);
switch (ifa->ifa_addr->sa_family) {
#ifdef INET
case AF_INET:
((struct arpcom *)ifp)->ac_ipaddr =
IA_SIN(ifa)->sin_
arpwhohas((struct arpcom *)ifp, &IA_SIN(ifa)->sin_addr);
case SIOCSIFFLAGS:
if ((ifp->if_flags & IFF_UP) == 0 &&
es->es_flags & ENF_RUNNING) {
es->es_flags &= ~ENF_RUNNING;
} else if (ifp->if_flags & IFF_UP &&
(es->es_flags & ENF_RUNNING) == 0)
eninit(ifp->if_unit);
#if NBPFILTER > 0
else if (ifp->if_flags & IFF_UP &&
(ifp->if_flags & IFF_RUNNING) == 0) {
en_prom_mode(ifp->if_unit,
ifp->if_flags & IFF_PROMISC);
ifp->if_flags |= IFF_RUNNING;
error = EINVAL;
return (error);
* set ethernet address for unit
ensetaddr(physaddr, unit)
register struct en_softc *es = &en_softc[unit];
if (!(es->es_flags & ENF_RUNNING))
bcopy((caddr_t)physaddr, (caddr_t)es->es_addr, sizeof es->es_addr);
es->es_flags &= ~ENF_RUNNING;
es->es_flags |= ENF_SETADDR;
eninit(unit);
* Machine dependent functions
* en_probe();
* en_attach();
* en_init();
* enxint();
* enrint();
* en_prom_mode()
#ifdef CPU_SINGLE
en_probe(hi)
struct hb_device *
return (lance_probe(hi->hi_unit));
en_attach(unit)
register struct en_softc *es = &en_softc[unit];
register u_char *p;
extern lance_intr();
#if !defined(news700) && !defined(mips)
register_hb_intr4(lance_intr, unit, eninfo[unit]->ii_intr);
if (lance_open(unit) es_addr);
en_init(unit)
en_start(unit, len)
lance_transmit(unit, len);
enxint(unit)
_enxint(unit, lance_xmit_error(unit), lance_collision(unit));
enrint(unit)
register struct en_softc *es = &en_softc[unit];
caddr_t get_recv_buffer();
while (es->es_ifnews.ifn_raddr = get_recv_buffer(unit)) {
_enrint(unit,
get_recv_length(unit) - sizeof(struct en_rheader));
free_recv_buffer(unit);
en_prom_mode(unit, mode)
lance_prom_mode(unit, mode);
#endif /* CPU_SINGLE */
#ifdef IPC_MRX
#include "../ipc/newsipc.h"
#include "../mrx/h/lancereg.h"
#include "../mrx/h/lance.h"
int port_enxmit[NEN];
int port_enrecv[NEN];
int port_enctrl[NEN];
int port_enxmit_iop[NEN];
int port_enrecv_iop[NEN];
int port_enctrl_iop[NEN];
en_probe(ii)
register struct iop_device *
int unit = ii->ii_
int lance_func, *
char name[32];
extern char *make_name();
if (port_enrecv[unit] == 0) {
#define PT_CREATE(buf, name, unit, func) \
port_create(make_name(buf, name, unit), func, unit)
#define OB_QUERY(buf, name, unit) \
object_query(make_name(buf, name, unit))
make_name(name, "@enrecvX", unit);
port_enrecv[unit] = PT_CREATE(name, "@enrecvX", unit, enrint);
port_enxmit[unit] = PT_CREATE(name, "@enxmitX", unit, enxint);
port_enctrl[unit] = PT_CREATE(name, "@enctrlX", unit, NULL);
/* use NULL action port */
port_enrecv_iop[unit] = OB_QUERY(name, "lance_inputX", unit);
port_enxmit_iop[unit] = OB_QUERY(name, "lance_outputX", unit);
port_enctrl_iop[unit] = OB_QUERY(name, "lance_ctrlX", unit);
if (port_enctrl_iop[unit] < 0)
lance_func = EN_START;
msg_send(port_enctrl_iop[unit], port_enctrl[unit], &lance_func,
sizeof(lance_func), 0);
msg_recv(port_enctrl[unit], NULL, &reply, NULL, 0);
if (*reply es_addr, sizeof(struct ether_addr));
msg_free(port_enctrl[unit]);
en_init(unit)
register struct en_softc *es = &en_softc[unit];
struct lance_ctrl_
req.lance_func = EN_SETXMITBUF;
mapsetup(&req.lance_map, es->es_ifnews.ifn_waddr,
ETHERMTU + sizeof(struct en_rheader));
msg_send(port_enctrl_iop[unit], port_enctrl[unit],
&req, sizeof(req), 0);
msg_recv(port_enctrl[unit], NULL, &reply, NULL, 0);
req.lance_func = EN_START;
msg_send(port_enctrl_iop[unit], port_enctrl[unit],
&req, sizeof(req), 0);
msg_recv(port_enctrl[unit], NULL, &reply, NULL, 0);
msg_free(port_enctrl[unit]);
msg_send(port_enrecv_iop[unit], port_enrecv[unit],
es->es_ifnews.ifn_raddr,
ETHERMTU + sizeof(struct en_rheader), MSG_INDIRECT);
en_start(unit, len)
msg_send(port_enxmit_iop[unit], port_enxmit[unit], &len, sizeof(len), 0);
enxint(unit)
struct en_softc *es = &en_softc[unit];
if (msg_recv(port_enxmit[unit], NULL, &len, NULL, 0) es_ifnews.ifn_mbuf)
m_freem(es->es_ifnews.ifn_mbuf);
_enxint(unit, *len < 0, *len & 0x10000);
enrint(unit)
if (msg_recv(port_enrecv[unit], NULL, &reply, NULL, 0)求鉴定更多if_start)(ifp)">
怎么理解(*ifp->if_start)(ifp)_百度作业帮
怎么理解(*ifp->if_start)(ifp)
怎么理解(*ifp->if_start)(ifp)
第一优先级:ifp->if_start,然后是(*ifp->if_start),而(ifp)是一个函数参数.(*ifp->if_start)是带指针的函数的名.所以这是个函数指针.
非常感谢你
if_start是个函数指针吗
在这个例子中(*ifp->if_start)全部构成一个函数指针,if_start只是ifp的一个成员。这里的函数指针中的指针是 * 决定的。与->没有关系。ifp->if_start要作为一个整体用,如(*fun)(ifp)是函数指针。
怎么没有返回类型?
可以没有返回类型吗?
addr_t是什么
这里只是针对你最初给的那个表达式进行解释的,其它的默认你已经理解,函数要有返回类型的,若没有要加上void声明。addr_t,caddr_t没有上下文,不知道什么东东。
caddr_t mh_
我在学习tcp/ip详解
卷2:实现,这本书过时了吗?
caddr_t 这个像是程序中定义的,不用程序中可能不同。有可能是typedef void * caddr_t;也有可能是其它的类型。
想找个高手拜师
mbstat是什么单词的缩写?
m_mtypes[256]
m_mtypes[256]是数组吗?
mbstat可能是mb
state,即mb状态的意思,mb是什么意思,要结合程序来看。m_mtypes[256]是数组,但m_mtypes这个类型要看其定义。
数组mbtypes把mbuf的MT_xxx值转换成相应的M_xxx值(图2.10)。
这句话怎么理解?
怎么转换啊?
tcp/ip详解里的
mb_types[MT_DAYA]是什么意思
return(ENOBUFS)?
(int) ((caddt_t)&((t*)0)->m))
IA_SIN(ifa)是什么意思啊?

我要回帖

更多关于 if i start after 的文章

 

随机推荐