/* * Copyright (C) James R. Leu 2000 * jleu@mindspring.com * * This software is covered under the LGPL, for more * info check out http://www.gnu.org/copyleft/lgpl.html */ #include #include "ldp_struct.h" #include "ldp_pdu_setup.h" #include "ldp_msg_alloc.h" #include "ldp_mm_impl.h" mplsLdpHeader_t *allocLdpHdr(uint32_t lsraddr,int label_space, int message_length) { mplsLdpHeader_t *header = (mplsLdpHeader_t*)ldp_malloc(sizeof(mplsLdpHeader_t)); if(header == NULL) { return NULL; } header->protocolVersion = 1; header->pduLength = message_length + 6; header->lsrAddress = lsraddr; header->labelSpace = label_space; return header; } mplsLdpHelloMsg_t *allocLdpHello(unsigned int messageId) { mplsLdpHelloMsg_t *hello = (mplsLdpHelloMsg_t*)ldp_malloc(sizeof(mplsLdpHelloMsg_t)); if(hello == NULL) { return NULL; } setupBaseMsg(&(hello->baseMsg),MPLS_HELLO_MSGTYPE,0,messageId); hello->chpTlvExists = 0; hello->trAdrTlvExists = 0; hello->csnTlvExists = 0; return hello; } mplsLdpInitMsg_t *allocLdpInit(unsigned int messageId) { mplsLdpInitMsg_t *ini = (mplsLdpInitMsg_t*)ldp_malloc(sizeof(mplsLdpInitMsg_t)); if(ini == NULL) { return NULL; } setupBaseMsg(&(ini->baseMsg),MPLS_INIT_MSGTYPE,0,messageId); ini->cspExists = 0; ini->aspExists = 0; ini->fspExists = 0; return ini; } mplsLdpKeepAlMsg_t *allocLdpKeepalive(unsigned int messageId) { mplsLdpKeepAlMsg_t *keep = (mplsLdpKeepAlMsg_t*)ldp_malloc(sizeof(mplsLdpKeepAlMsg_t)); if(keep != NULL) { setupBaseMsg(&(keep->baseMsg),MPLS_KEEPAL_MSGTYPE,0,messageId); } return keep; } mplsLdpLblReqMsg_t *allocLdpLabelRequest(unsigned int messageId) { mplsLdpLblReqMsg_t *req = (mplsLdpLblReqMsg_t*)ldp_malloc(sizeof(mplsLdpLblReqMsg_t)); if(req == NULL) { return NULL; } setupBaseMsg(&(req->baseMsg),MPLS_LBLREQ_MSGTYPE,0,messageId); req->fecTlvExists = 0; req->hopCountTlvExists = 0; req->pathVecTlvExists = 0; req->lblMsgIdTlvExists = 0; req->erTlvExists = 0; req->trafficTlvExists = 0; req->lspidTlvExists = 0; req->pinningTlvExists = 0; req->recClassTlvExists = 0; req->preemptTlvExists = 0; return req; } mplsLdpLblMapMsg_t *allocLdpLabelMapping(unsigned int messageId) { mplsLdpLblMapMsg_t *map = (mplsLdpLblMapMsg_t*)ldp_malloc(sizeof(mplsLdpLblMapMsg_t)); if(map == NULL) { return NULL; } setupBaseMsg(&(map->baseMsg),MPLS_LBLMAP_MSGTYPE,0,messageId); map->fecTlvExists = 0; map->hopCountTlvExists = 0; map->pathVecTlvExists = 0; map->lspidTlvExists = 0; map->trafficTlvExists = 0; map->genLblTlvExists = 0; map->atmLblTlvExists = 0; map->frLblTlvExists = 0; map->lblMsgIdTlvExists = 0; return map; } mplsLdpAdrMsg_t *allocLdpAddrWith(unsigned int messageId) { mplsLdpAdrMsg_t *addr = (mplsLdpAdrMsg_t*)ldp_malloc(sizeof(mplsLdpAdrMsg_t)); setupBaseMsg(&(addr->baseMsg),MPLS_ADDRWITH_MSGTYPE,0,messageId); if(addr != NULL) { addr->adrListTlvExists = 0; } return addr; } mplsLdpAdrMsg_t *allocLdpAddr(unsigned int messageId) { mplsLdpAdrMsg_t *addr = (mplsLdpAdrMsg_t*)ldp_malloc(sizeof(mplsLdpAdrMsg_t)); setupBaseMsg(&(addr->baseMsg),MPLS_ADDR_MSGTYPE,0,messageId); if(addr != NULL) { addr->adrListTlvExists = 0; } return addr; } mplsLdpLbl_W_R_Msg_t *allocLdpLabelRelease(unsigned int messageId) { mplsLdpLbl_W_R_Msg_t *with = (mplsLdpLbl_W_R_Msg_t*)ldp_malloc(sizeof(mplsLdpLbl_W_R_Msg_t)); if(with == NULL) { return NULL; } setupBaseMsg(&(with->baseMsg),MPLS_LBLREL_MSGTYPE,0,messageId); with->fecTlvExists = 0; with->genLblTlvExists = 0; with->atmLblTlvExists = 0; with->frLblTlvExists = 0; with->lspidTlvExists = 0; return with; } mplsLdpLbl_W_R_Msg_t *allocLdpLabelWithdraw(unsigned int messageId) { mplsLdpLbl_W_R_Msg_t *with = (mplsLdpLbl_W_R_Msg_t*)ldp_malloc(sizeof(mplsLdpLbl_W_R_Msg_t)); if(with == NULL) { return NULL; } setupBaseMsg(&(with->baseMsg),MPLS_LBLWITH_MSGTYPE,0,messageId); with->fecTlvExists = 0; with->genLblTlvExists = 0; with->atmLblTlvExists = 0; with->frLblTlvExists = 0; with->lspidTlvExists = 0; return with; } mplsLdpNotifMsg_t *allocLdpNotify(unsigned int messageId) { mplsLdpNotifMsg_t *notif = (mplsLdpNotifMsg_t*)ldp_malloc(sizeof(mplsLdpNotifMsg_t)); if(notif == NULL) { return NULL; } setupBaseMsg(&(notif->baseMsg),MPLS_NOT_MSGTYPE,0,messageId); notif->statusTlvExists = 0; notif->exStatusTlvExists = 0; notif->retPduTlvExists = 0; notif->retMsgTlvExists = 0; notif->lspidTlvExists = 0; return notif; } mplsLdpLblAbortMsg_t *allocLdpLabelAbort(unsigned int messageId) { mplsLdpLblAbortMsg_t *abrt = (mplsLdpLblAbortMsg_t*)ldp_malloc(sizeof(mplsLdpLblAbortMsg_t)); if(abrt == NULL) { return NULL; } setupBaseMsg(&(abrt->baseMsg),MPLS_NOT_MSGTYPE,0,messageId); abrt->fecTlvExists = 0; abrt->lblMsgIdTlvExists = 0; return abrt; }