HSOCKET UDPOpen(const LLADP * pLLAdp, HPMGR hPMGR, const void * pIPvXDest, uint16_t portRemote, uint16_t portLocal, IPSTATUS * pStatus) { UDPSOCKET * pSocket = (UDPSOCKET *) IPSGetSocketFromSocketHeap(); if(UDPOpenWithSocket(pLLAdp, pSocket, hPMGR, pIPvXDest, portRemote, portLocal, pStatus) == NULL) { IPSReleaseSocket((TCPSOCKET *) pSocket); return(NULL); } return(pSocket); }
bool DNSInit(const LLADP * pLLAdp, void * rgbDNSMem, uint32_t cbDNSMem, HPMGR hPMGR, IPSTATUS * pStatus) { IPSTATUS status = ipsSuccess; DNSMEM * pDNSMem = (DNSMEM *) rgbDNSMem; uint32_t i = 0; if(pLLAdp == NULL) { status = ipsAdaptorMustBeSpecified; } else if(hPMGR == NULL) { status = ipsNoPMGRGiven; } else if(rgbDNSMem == NULL) { status = ipsDNSMemIsNULL; } else if(cbDNSMem < sizeof(DNSMEM)) { status = ipsDNSNotEnoughMem; } else if(pLLAdp->pDNSMem != NULL) { status = ipsDNSAlreadyInitialized; } else if(ILIsIPv6(pLLAdp)) { status = ipsIPv6NotSupported; } if(IsIPStatusAnError(status)) { AssignStatusSafely(pStatus, status); return(false); } memset(pDNSMem, 0, cbDNSMem); if(&pDNSMem->socket != UDPOpenWithSocket(pLLAdp, &pDNSMem->socket, hPMGR, &IPv4BROADCAST, portDNSServer, portDynamicallyAssign, &status) || IsIPStatusAnError(status)) { UDPClose(&pDNSMem->socket); AssignStatusSafely(pStatus, status); return(false); } pDNSMem->dnsNSMax = (cbDNSMem - sizeof(DNSMEM)) / sizeof(IPv4or6); pDNSMem->cDhcpNS = 0; pDNSMem->iDNSCur = DNSiInvalid; pDNSMem->iDNSWorks = DNSiInvalid; pDNSMem->dnsState = dnsReady; pDNSMem->cTry = 0; ((LLADP *) pLLAdp)->pDNSMem = pDNSMem; // initialize them all to the Google NS // that way there is something in all of the slots // this will get over written if DHCP is used. for(i=0; i<pDNSMem->dnsNSMax; i++) { if((i % 2) == 0) { pDNSMem->dnsNS[i].ipv4.u32 = 0x04040808; // Google public DNS server } else { pDNSMem->dnsNS[i].ipv4.u32 = 0x08080808; // Google public DNS server } } AssignStatusSafely(pStatus, status); return(true); }