static void Despatch(struct bundle *bundle, struct link *l, struct mbuf *bp, u_short proto) { unsigned f; for (f = 0; f < DSIZE; f++) if (despatcher[f].proto == proto) { bp = (*despatcher[f].fn)(bundle, l, bp); break; } if (bp) { struct physical *p = link2physical(l); log_Printf(LogPHASE, "%s protocol 0x%04x (%s)\n", f == DSIZE ? "Unknown" : "Unexpected", proto, hdlc_Protocol2Nam(proto)); bp = m_pullup(proto_Prepend(bp, proto, 0, 0)); lcp_SendProtoRej(&l->lcp, MBUF_CTOP(bp), bp->m_len); if (p) { p->hdlc.lqm.SaveInDiscards++; p->hdlc.stats.unknownproto++; } m_freem(bp); } }
struct ppp_mbuf * proto_LayerPush(/*struct bundle *b, */struct link *l, struct ppp_mbuf *bp, VOS_INT32 pri, VOS_UINT16 *proto) { bp = proto_Prepend(bp, *proto, l->lcp.his_protocomp, acf_WrapperOctets(&l->lcp, *proto)); return bp; }
static struct mbuf * proto_LayerPush(struct bundle *b, struct link *l, struct mbuf *bp, int pri, u_short *proto) { log_Printf(LogDEBUG, "proto_LayerPush: Using 0x%04x\n", *proto); bp = proto_Prepend(bp, *proto, l->lcp.his_protocomp, acf_WrapperOctets(&l->lcp, *proto)); m_settype(bp, MB_PROTOOUT); link_ProtocolRecord(l, *proto, PROTO_OUT); return bp; }
/***************************************************************************** 函 数 名 : PPP_HDLC_ProcIpModeUlData 功能描述 : IP类型拨号,软件或硬件解封装完成后,调用此接口处理输出数据 输入参数 : pstLink - PPP链路信息 pstMem - 解封装后单个输出数据包 usProto - 数据包对应的协议 输出参数 : 无 返 回 值 : 无 调用函数 : 被调函数 : 修改历史 : 1.日 期 : 2012年4月10日 作 者 : l00164359 修改内容 : 新生成函数 *****************************************************************************/ VOS_VOID PPP_HDLC_ProcIpModeUlData ( struct link *pstLink, PPP_ZC_STRU *pstMem, VOS_UINT16 usProto ) { #ifdef PPP_ST_TEST PPP_STUB_ProcUlData(pstMem, 5); #else VOS_UINT32 f; struct ppp_mbuf *bp; /* 把PPP协商包作为可维可测信息,IP包不做可维可测维护*/ if (PROTO_IP != usProto) { Ppp_TtfMemFrameMntnInfo(pstMem, usProto, PPP_RECV_IN_PROTOCOL_FRAME); } for (f = 0; f < DSIZE; f++) { if (despatcher[f].proto == usProto) { pstMem = (*despatcher[f].fn)(/*bundle, */pstLink, pstMem); break; } } /* 如果是不支持的协议,向对端发送REJ帧 */ if (VOS_NULL_PTR != pstMem) { bp = ppp_m_get_from_ttfmem(pstMem); PPP_MemFree(pstMem); if (VOS_NULL_PTR == bp) { return; } /* struct physical *p = link2physical(l); log_Printf(LogPHASE, "%s protocol 0x%04x (%s)\n", f == DSIZE ? "Unknown" : "Unexpected", proto, hdlc_Protocol2Nam(proto));*/ bp = ppp_m_pullup(proto_Prepend(bp, usProto, 0, 0)); if (VOS_NULL_PTR == bp) { return; } lcp_SendProtoRej(&pstLink->lcp, PPP_MBUF_CTOP(bp), bp->m_len); if (pstLink) { pstLink->hdlc.lqm.SaveInDiscards++; pstLink->hdlc.stats.unknownproto++; } ppp_m_freem(bp); } return; #endif }
cp[1] = proto & 0xff; if (comp && cp[0] == 0) bp = m_prepend(bp, cp + 1, 1, extra); else bp = m_prepend(bp, cp, 2, extra); return bp; } static struct mbuf * proto_LayerPush(struct bundle *b __unused, struct link *l, struct mbuf *bp, int pri __unused, u_short *proto) { log_Printf(LogDEBUG, "proto_LayerPush: Using 0x%04x\n", *proto); bp = proto_Prepend(bp, *proto, l->lcp.his_protocomp, acf_WrapperOctets(&l->lcp, *proto)); m_settype(bp, MB_PROTOOUT); link_ProtocolRecord(l, *proto, PROTO_OUT); return bp; } static struct mbuf * proto_LayerPull(struct bundle *b __unused, struct link *l, struct mbuf *bp, u_short *proto) { u_char cp[2]; size_t got; if ((got = mbuf_View(bp, cp, 2)) == 0) { m_freem(bp);
struct mbuf * lqr_Input(struct bundle *bundle, struct link *l, struct mbuf *bp) { struct physical *p = link2physical(l); struct lcp *lcp = p->hdlc.lqm.owner; int len; if (p == NULL) { log_Printf(LogERROR, "lqr_Input: Not a physical link - dropped\n"); m_freem(bp); return NULL; } len = m_length(bp); if (len != sizeof(struct lqrdata)) log_Printf(LogWARN, "lqr_Input: Got packet size %d, expecting %ld !\n", len, (long)sizeof(struct lqrdata)); else if (!IsAccepted(l->lcp.cfg.lqr) && !(p->hdlc.lqm.method & LQM_LQR)) { bp = m_pullup(proto_Prepend(bp, PROTO_LQR, 0, 0)); lcp_SendProtoRej(lcp, MBUF_CTOP(bp), bp->m_len); } else { struct lqrdata *lqr; bp = m_pullup(bp); lqr = (struct lqrdata *)MBUF_CTOP(bp); if (ntohl(lqr->MagicNumber) != lcp->his_magic) log_Printf(LogWARN, "lqr_Input: magic 0x%08lx is wrong," " expecting 0x%08lx\n", (u_long)ntohl(lqr->MagicNumber), (u_long)lcp->his_magic); else { struct lqrdata lastlqr; memcpy(&lastlqr, &p->hdlc.lqm.lqr.peer, sizeof lastlqr); lqr_ChangeOrder(lqr, &p->hdlc.lqm.lqr.peer); lqr_Dump(l->name, "Input", &p->hdlc.lqm.lqr.peer); /* we have received an LQR from our peer */ p->hdlc.lqm.lqr.resent = 0; /* Snapshot our state when the LQR packet was received */ memcpy(&p->hdlc.lqm.lqr.prevSave, &p->hdlc.lqm.lqr.Save, sizeof p->hdlc.lqm.lqr.prevSave); p->hdlc.lqm.lqr.Save.InLQRs = ++p->hdlc.lqm.lqr.InLQRs; p->hdlc.lqm.lqr.Save.InPackets = p->hdlc.lqm.ifInUniPackets; p->hdlc.lqm.lqr.Save.InDiscards = p->hdlc.lqm.ifInDiscards; p->hdlc.lqm.lqr.Save.InErrors = p->hdlc.lqm.ifInErrors; p->hdlc.lqm.lqr.Save.InOctets = p->hdlc.lqm.lqr.InGoodOctets; lqr_Analyse(&p->hdlc, &lastlqr, &p->hdlc.lqm.lqr.peer); /* * Generate an LQR response if we're not running an LQR timer OR * two successive LQR's PeerInLQRs are the same. */ if (p->hdlc.lqm.timer.load == 0 || !(p->hdlc.lqm.method & LQM_LQR) || (lastlqr.PeerInLQRs && lastlqr.PeerInLQRs == p->hdlc.lqm.lqr.peer.PeerInLQRs)) SendLqrData(lcp); } } m_freem(bp); return NULL; }