char *TCPClientSocketWindows::getIp(void) const { char *str = new char[50]; InetNtop(AF_INET, (void *)&(this->_addr.sin_addr), reinterpret_cast<PWSTR>(str), 49); // inet_ntop(AF_INET, &(this->_addr.sin_addr), str, 49); return (str); }
static PCSTR addrToStr(SFLAddress *address, char *buf, size_t len) { return InetNtop(address->type == SFLADDRESSTYPE_IP_V6 ? AF_INET6 : AF_INET, &address->address, buf, len); }
/** * Use GetTcpTable */ static void dump_tcp4_table(void) { MIB_TCPTABLE *pTcpTable; const MIB_TCPROW *pTcpRow; DWORD i; TCHAR szLocalAddrBuffer[16], szRemoteAddrBuffer[16]; pTcpTable = GetTcpTable_a(); if (!pTcpTable) { return; } _tprintf(_T("TCP/IPv4 connections (%lu):\n"), pTcpTable->dwNumEntries); for (i = 0; i < pTcpTable->dwNumEntries; i++) { pTcpRow = &pTcpTable->table[i]; _tprintf(_T(" * %s/%u -> %s/%u ("), InetNtop(AF_INET, &pTcpRow->dwLocalAddr, szLocalAddrBuffer, ARRAYSIZE(szLocalAddrBuffer)), ntohs((WORD)pTcpRow->dwLocalPort), InetNtop(AF_INET, &pTcpRow->dwRemoteAddr, szRemoteAddrBuffer, ARRAYSIZE(szRemoteAddrBuffer)), ntohs((WORD)pTcpRow->dwRemotePort)); switch (pTcpRow->dwState) { case_print(MIB_TCP_STATE_CLOSED, _T("CLOSED")); case_print(MIB_TCP_STATE_LISTEN, _T("LISTEN")); case_print(MIB_TCP_STATE_SYN_SENT, _T("SYN SENT")); case_print(MIB_TCP_STATE_SYN_RCVD, _T("SYN RECEIVED")); case_print(MIB_TCP_STATE_ESTAB, _T("ESTABLISHED")); case_print(MIB_TCP_STATE_FIN_WAIT1, _T("FIN WAIT 1")); case_print(MIB_TCP_STATE_FIN_WAIT2, _T("FIN WAIT 2")); case_print(MIB_TCP_STATE_CLOSE_WAIT, _T("CLOSE WAIT")); case_print(MIB_TCP_STATE_CLOSING, _T("CLOSING")); case_print(MIB_TCP_STATE_LAST_ACK, _T("LAST ACK")); case_print(MIB_TCP_STATE_TIME_WAIT, _T("TIME WAIT")); case_print(MIB_TCP_STATE_DELETE_TCB, _T("DELETE TCB")); default: _tprintf(_T("Unknown state %lu"), pTcpRow->dwState); break; } _tprintf(_T(")\n")); } HeapFree(GetProcessHeap(), 0, pTcpTable); }
/** * Use GetIpAddrTable */ static void dump_ipv4addr_table(void) { MIB_IPADDRTABLE *pIpAddrTable; const MIB_IPADDRROW *pIpAddrRow; DWORD i; TCHAR szAddrBuffer[16], szMaskBuffer[16], szBCastBuffer[16]; pIpAddrTable = GetIpAddrTable_a(); if (!pIpAddrTable) { return; } _tprintf(_T("IPv4 addresses (%lu):\n"), pIpAddrTable->dwNumEntries); for (i = 0; i < pIpAddrTable->dwNumEntries; i++) { pIpAddrRow = &pIpAddrTable->table[i]; _tprintf(_T(" * Iface %lu: %s/%s\n"), pIpAddrRow->dwIndex, InetNtop(AF_INET, &pIpAddrRow->dwAddr, szAddrBuffer, ARRAYSIZE(szAddrBuffer)), InetNtop(AF_INET, &pIpAddrRow->dwMask, szMaskBuffer, ARRAYSIZE(szMaskBuffer))); _tprintf(_T(" * Broadcast: %s\n"), InetNtop(AF_INET, &pIpAddrRow->dwBCastAddr, szBCastBuffer, ARRAYSIZE(szBCastBuffer))); _tprintf(_T(" * Reassembly size: %lu\n"), pIpAddrRow->dwReasmSize); } HeapFree(GetProcessHeap(), 0, pIpAddrTable); }
Void System::NetAddressToString( GChar * outString, const NetAddress * pAddress ) const { switch( pAddress->iType ) { case NETADDRESS_IPv4: { const NetAddressIPv4 * pAddr = (const NetAddressIPv4*)pAddress; in_addr ipAddr; ipAddr.S_un.S_addr = pAddr->Addr.Value; const GChar * strOut = InetNtop( AF_INET, &ipAddr, outString, 16 ); DebugAssert( strOut != NULL ); *outString++ = ':'; StringFn->FromUInt( outString, (UInt64)( ntohs(pAddr->wPort) ) ); } break; case NETADDRESS_IPv6: { DebugAssert( false ); } break; default: DebugAssert( false ); break; } }
/** * Use GetUdpTable */ static void dump_udp4_table(void) { MIB_UDPTABLE *pUdpTable; const MIB_UDPROW *pUdpRow; DWORD i; TCHAR szLocalAddrBuffer[16]; pUdpTable = GetUdpTable_a(); if (!pUdpTable) { return; } _tprintf(_T("UDP/IPv4 connections (%lu):\n"), pUdpTable->dwNumEntries); for (i = 0; i < pUdpTable->dwNumEntries; i++) { pUdpRow = &pUdpTable->table[i]; _tprintf(_T(" * %s/%u\n"), InetNtop(AF_INET, &pUdpRow->dwLocalAddr, szLocalAddrBuffer, ARRAYSIZE(szLocalAddrBuffer)), ntohs((WORD)pUdpRow->dwLocalPort)); } HeapFree(GetProcessHeap(), 0, pUdpTable); }
return len; } int WinSocket::sendBinary(void *point, int len) { WSABUF Databuf; Databuf.len = len; Databuf.buf = (CHAR * )point; if (WSASend(this->sock, &Databuf, 1, &Databuf.len, 0,0,0) == SOCKET_ERROR) return NULL; return 0; } int WinSocket::recBinaryFrom(void* buffer , int blocksize, std::string &ip) { WSABUF Databuf; DWORD receive; struct sockaddr_in in; int len;
std::string WinSocket::getIp() { int len = sizeof(this->sin); char str[32]; char const*s; struct sockaddr name; int lens = sizeof(name); if (getpeername(this->sock, &name, &lens) == SOCKET_ERROR) return 0; struct sockaddr_in *in = (struct sockaddr_in*)&name; if (in == NULL) return 0; int ipAddr = in->sin_addr.s_addr; if ((s = InetNtop( AF_INET, &ipAddr, str, 32)) == NULL) { wprintf(L"InetNtop failed with error %u\n", WSAGetLastError()); return 0; } std::cout << "lol3" << std::endl; return s; }
// Debug function that prints out the linked list returned by getaddrinfo. // Reference: getaddrinfo function in MSDN // https://msdn.microsoft.com/en-us/library/windows/desktop/ms738520(v=vs.85).aspx void printAddrInfo(struct addrinfo *result) { // DEBUG // Print out all addresses returned from getaddrinfo. struct addrinfo *ptr; int i = 1; struct sockaddr_in *sockaddr_ipv4; struct sockaddr_in6 *sockaddr_ipv6; LPSOCKADDR sockaddr_ip; char ipstringbuffer[46]; DWORD ipbufferlength = 46; INT iRetval; for (ptr = result; ptr != NULL; ptr = ptr->ai_next) { printf("getaddrinfo response %d\n", i++); printf("\tFlags: 0x%x\n", ptr->ai_flags); printf("\tFamily: "); switch (ptr->ai_family) { case AF_UNSPEC: printf("Unspecified\n"); break; case AF_INET: printf("AF_INET (IPv4)\n"); sockaddr_ipv4 = (struct sockaddr_in *) ptr->ai_addr; InetNtop(AF_INET, &sockaddr_ipv4->sin_addr, ipstringbuffer, ipbufferlength); printf("\tIPv4 address %s\n", ipstringbuffer); break; case AF_INET6: printf("AF_INET6 (IPv6)\n"); // the InetNtop function is available on Windows Vista and later sockaddr_ipv6 = (struct sockaddr_in6 *) ptr->ai_addr; InetNtop(AF_INET6, &sockaddr_ipv6->sin6_addr, ipstringbuffer, ipbufferlength); printf("\tIPv6 address %s\n", ipstringbuffer); break; case AF_NETBIOS: printf("AF_NETBIOS (NetBIOS)\n"); break; default: printf("Other %ld\n", ptr->ai_family); break; } printf("\tSocket type: "); switch (ptr->ai_socktype) { case 0: printf("Unspecified\n"); break; case SOCK_STREAM: printf("SOCK_STREAM (stream)\n"); break; case SOCK_DGRAM: printf("SOCK_DGRAM (datagram) \n"); break; case SOCK_RAW: printf("SOCK_RAW (raw) \n"); break; case SOCK_RDM: printf("SOCK_RDM (reliable message datagram)\n"); break; case SOCK_SEQPACKET: printf("SOCK_SEQPACKET (pseudo-stream packet)\n"); break; default: printf("Other %ld\n", ptr->ai_socktype); break; } printf("\tProtocol: "); switch (ptr->ai_protocol) { case 0: printf("Unspecified\n"); break; case IPPROTO_TCP: printf("IPPROTO_TCP (TCP)\n"); break; case IPPROTO_UDP: printf("IPPROTO_UDP (UDP) \n"); break; default: printf("Other %ld\n", ptr->ai_protocol); break; } printf("\tLength of this sockaddr: %d\n", ptr->ai_addrlen); printf("\tCanonical name: %s\n", ptr->ai_canonname); } }
/* Cliente Aplicacao simples de cliente tcp que se conecta num IP e PORTA passados por parametro, envia um comando ao servidor e escreve na saida padrao o retorno */ int main(int argc, char **argv) { // Declaracao de variaveis int sockfd; char buf[MAXDATASIZE + 1], error[MAXDATASIZE + 1]; char server[MAXDATASIZE + 1], server_reply[MAXDATASIZE + 1]; struct sockaddr_in servaddr; // Checa a presenca do parametro de IP e Porta // caso ausente, fecha o programa if (argc != 3) { strcpy(error,"uso: "); strcat(error,argv[0]); strcat(error," <IPaddress> <Port>"); perror(error); exit(1); } // Cria um socket sockfd = Socket(AF_INET, SOCK_STREAM, 0); // Limpa o que estiver no ponteiro do socket que representa o servidor // Seta o socket do servidor como IPv4 e seta a porta de conexao para a porta da aplicacao. bzero(&servaddr, sizeof(servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_port = htons(atoi(argv[2])); // Converte o IP recebido na entrada para a forma binária da struct InetPton(AF_INET, argv[1], servaddr); // Conecta o socket local com o socket servidor Connect(sockfd, servaddr); // Escrever IP e porta do servidor na saida padrao printf("Server: IP %s - Port %d\n", argv[1], atoi(argv[2])); // Coletar informacoes sobre o socket com o servidor servaddr = Getsockname(sockfd, servaddr); // Converter informacao do IP de binario para string // armazenar o resultado no buffer InetNtop(AF_INET, server, servaddr); // Escrever IP e porta do cliente no socket na saida padrao printf("Client: IP %s - Port %d\n", server, ntohs(servaddr.sin_port)); // lê uma cadeia de caracteres do teclado printf("Digite um comando:\n"); fgets(buf, MAXDATASIZE, stdin); // Imprime a linha de comando digitada pelo usuario printf("Linha de comando digitada: %s", buf); // envia os dados lidos ao servidor Write(sockfd , buf); // le os dados enviados pelo servidor Read(sockfd, server_reply); // Imprime a linha de comando devolvida pelo servidor printf("Linha de comando recebida: %s\n", server_reply); exit(0); }
/** * Use GetIpForwardTable */ static void dump_ipv4fwd_table(void) { MIB_IPFORWARDTABLE *pIpForwardTable; const MIB_IPFORWARDROW *pIpForwardRow; DWORD i; TCHAR szDestBuffer[16], szMaskBuffer[16], szNextHopBuffer[16]; pIpForwardTable = GetIpForwardTable_a(); if (!pIpForwardTable) { return; } _tprintf(_T("IPv4 routes (%lu):\n"), pIpForwardTable->dwNumEntries); for (i = 0; i < pIpForwardTable->dwNumEntries; i++) { pIpForwardRow = &pIpForwardTable->table[i]; _tprintf(_T(" * Iface %lu: %s/%s\n"), pIpForwardRow->dwForwardIfIndex, InetNtop(AF_INET, &pIpForwardRow->dwForwardDest, szDestBuffer, ARRAYSIZE(szDestBuffer)), InetNtop(AF_INET, &pIpForwardRow->dwForwardMask, szMaskBuffer, ARRAYSIZE(szMaskBuffer))); _tprintf(_T(" * Next Hop: %s\n"), InetNtop(AF_INET, &pIpForwardRow->dwForwardNextHop, szNextHopBuffer, ARRAYSIZE(szNextHopBuffer))); _tprintf(_T(" * Type: ")); /* Old MinGW headers do not define MIB_IPROUTE_* */ #ifdef MIB_IPROUTE_TYPE_OTHER switch (pIpForwardRow->dwForwardType) { case_print(MIB_IPROUTE_TYPE_OTHER, _T("Other")); case_print(MIB_IPROUTE_TYPE_INVALID, _T("Invalid")); case_print(MIB_IPROUTE_TYPE_DIRECT, _T("Direct")); case_print(MIB_IPROUTE_TYPE_INDIRECT, _T("Indirect")); default: _tprintf(_T("Unknown (%lu)"), pIpForwardRow->dwForwardType); break; } #else _tprintf(_T("%lu"), pIpForwardRow->dwForwardType); #endif _tprintf(_T("\n")); _tprintf(_T(" * Proto: ")); /* Old MinGW headers do not define MIB_IPPROTO_* */ #ifdef MIB_IPPROTO_OTHER switch (pIpForwardRow->dwForwardProto) { case_print(MIB_IPPROTO_OTHER, _T("Other")); case_print(MIB_IPPROTO_LOCAL, _T("Local")); case_print(MIB_IPPROTO_NETMGMT, _T("Static (Network Management)")); case_print(MIB_IPPROTO_ICMP, _T("ICMP redirect")); case_print(MIB_IPPROTO_EGP, _T("Exterior Gateway Protocol (EGP)")); case_print(MIB_IPPROTO_GGP, _T("Gateway-to-Gateway Protocol (GGP)")); case_print(MIB_IPPROTO_HELLO, _T("Hello Protocol")); case_print(MIB_IPPROTO_RIP, _T("Routing Information Protocol (RIP)")); case_print(MIB_IPPROTO_IS_IS, _T("Intermediate System-to-Intermediate System (IS-IS)")); case_print(MIB_IPPROTO_ES_IS, _T("End System-to-Intermediate System (ES-IS)")); case_print(MIB_IPPROTO_CISCO, _T("Cisco Interior Gateway Routing Protocol (IGRP)")); case_print(MIB_IPPROTO_BBN, _T("BBN Internet Gateway Protocol (IGP) using SPF")); case_print(MIB_IPPROTO_OSPF, _T("Open Shortest Path First (OSPF)")); case_print(MIB_IPPROTO_BGP, _T("Border Gateway Protocol (BGP)")); case_print(MIB_IPPROTO_NT_AUTOSTATIC, _T("special Windows auto static route")); case_print(MIB_IPPROTO_NT_STATIC, _T("special Windows static route")); case_print(MIB_IPPROTO_NT_STATIC_NON_DOD, _T("special Windows static route not based on Internet standards")); default: _tprintf(_T("Unknown (%lu)"), pIpForwardRow->dwForwardProto); break; } #else _tprintf(_T("%lu"), pIpForwardRow->dwForwardProto); #endif _tprintf(_T("\n")); _tprintf(_T(" * Age: %lu\n"), pIpForwardRow->dwForwardAge); _tprintf(_T(" * Metric1: %lu\n"), pIpForwardRow->dwForwardMetric1); } HeapFree(GetProcessHeap(), 0, pIpForwardTable); }
DWORD WINAPI handle_http(LPVOID targ) { #else void *handle_http(void *targ) { #endif int connsd,i,tid,itmp,len=0; char *method=NULL, *uri=NULL, *version=NULL, *query=NULL; char *bp=NULL, *res=NULL; char buf[MAXLINE]; char header[HTTP_HEADER_SIZE]; thread_data_p tdata; struct common_data *common; socklen_t alen; struct sockaddr_storage addr; struct sockaddr_in *s4; struct sockaddr_in6 *s6; char ipstr[INET6_ADDRSTRLEN]; int port; #ifdef USE_OPENSSL SSL* ssl=NULL; #else void* ssl=NULL; #endif #if _MSC_VER #else struct timespec tim, tim2; tim.tv_sec = 0; tim.tv_nsec = 1000; #endif tdata=(thread_data_p) targ; tid=tdata->thread_id; common=tdata->common; while(1) { // infinite loop for threadpool, just once for non-threadpool if ((tdata->realthread)!=2) { // once-run thread connsd=tdata->conn; } else { // threadpool thread #ifdef MULTI_THREAD #if THREADPOOL pthread_mutex_lock(&(common->mutex)); while ((common->count==0) && (common->shutdown==0)) { itmp=pthread_cond_wait(&(common->cond),&(common->mutex)); // wait if (itmp) { errprint(COND_WAIT_FAIL_ERR,NULL); exit(ERR_EX_UNAVAILABLE); } } if (common->shutdown) { pthread_mutex_unlock(&(common->mutex)); // ? warnprint(SHUTDOWN_THREAD_WARN,NULL); tdata->inuse=0; pthread_exit((void*) tid); return NULL; } #endif #endif connsd=common->queue[common->head].conn; #ifdef USE_OPENSSL ssl=common->queue[common->head].ssl; if (SSL_accept(ssl)==-1) { SSL_free(ssl); ssl=NULL; //fprintf(stderr,"ssl accept error\n"); //ERR_print_errors_fp(stderr); } //ShowCerts(ssl); #endif common->head+=1; common->head=(common->head == common->queue_size) ? 0 : common->head; common->count-=1; #ifdef MULTI_THREAD #if THREADPOOL pthread_mutex_unlock(&(common->mutex)); #endif #endif } // who is calling? alen = sizeof addr; getpeername(connsd, (struct sockaddr*)&addr, &alen); if (addr.ss_family == AF_INET) { s4 = (struct sockaddr_in *)&addr; port = ntohs(s4->sin_port); #if _MSC_VER InetNtop(AF_INET, &s4->sin_addr, ipstr, sizeof ipstr); } else { // AF_INET6 s6 = (struct sockaddr_in6 *)&addr; port = ntohs(s6->sin6_port); InetNtop(AF_INET6, &s6->sin6_addr, ipstr, sizeof ipstr); } #else inet_ntop(AF_INET, &s4->sin_addr, ipstr, sizeof ipstr); } else { // AF_INET6
int __cdecl main( void ) { //----------------------------------------- // Declare and initialize variables DWORD dwRetval; int i = 1; struct addrinfo *result = NULL; struct addrinfo *ptr = NULL; struct sockaddr_in *sockaddr_ipv4; struct sockaddr_in6 *sockaddr_ipv6; char ipstringbuffer[46]; DWORD ipbufferlength = 46; //-------------------------------- // Initialiser la biblioteque Winsock wsStartup(); //-------------------------------- // Le nom du host dont on veut savoir l'adresse IP char *host = ""; //-------------------------------- // Appeller getaddrinfo(). Si l'appel reussi, // la variable result contiendra la liste des // structures addrinfo avec toutes les adresses du host dwRetval = getaddrinfo(host, NULL, NULL, &result); if ( dwRetval != 0 ) { printf("Erreur %d avec getaddrinfo.\n", dwRetval); WSACleanup(); return 1; } printf("getaddrinfo a reussi!\n"); // Extraire chaque address et afficher son détail for(ptr = result; ptr != NULL; ptr = ptr->ai_next) { printf("Adresse # %d\n", i++); printf("\tFlags: 0x%x\n", ptr->ai_flags); printf("\tFamille: "); switch (ptr->ai_family) { case AF_UNSPEC: printf("Non spécifiée\n"); break; case AF_INET: printf("AF_INET (IPv4)\n"); sockaddr_ipv4 = (struct sockaddr_in *) ptr->ai_addr; printf("\tAdresse IPv4: %s\n", inet_ntoa(sockaddr_ipv4->sin_addr) ); break; case AF_INET6: printf("AF_INET6 (IPv6)\n"); // the InetNtop function is available on Windows Vista and later sockaddr_ipv6 = (struct sockaddr_in6 *) ptr->ai_addr; printf("\tAdresse IPv6: %s\n", InetNtop(AF_INET6, &sockaddr_ipv6->sin6_addr, ipstringbuffer, 46) ); break; case AF_NETBIOS: printf("AF_NETBIOS (NetBIOS)\n"); break; default: printf("Autre type %ld\n", ptr->ai_family); break; } printf("\tTaille de cette adresse: %d octets\n", ptr->ai_addrlen); printf("\tNom canonique: %s\n", ptr->ai_canonname); } freeaddrinfo(result); WSACleanup(); printf("Appuyer une touche pour finir2...\n"); getchar(); return 0; }
void ConfigureDomainName(const CipUint interface_index) { CipDword dwSize = 0; int i = 0; // Set the flags to pass to GetAdaptersAddresses CipUdint flags = GAA_FLAG_INCLUDE_PREFIX; CipDword dwRetVal = 0; // default to unspecified address family (both) CipUdint family = AF_UNSPEC; LPVOID lpMsgBuf = NULL; PIP_ADAPTER_ADDRESSES pAddresses = NULL; PIP_ADAPTER_ADDRESSES pCurrAddresses = NULL; IP_ADAPTER_DNS_SERVER_ADDRESS *pDnServer = NULL; CipUdint outBufLen = 0; CipUdint tries = 0; family = AF_INET; // Allocate a 15 KB buffer to start with. outBufLen = WORKING_BUFFER_SIZE; do { pAddresses = (IP_ADAPTER_ADDRESSES *)CipCalloc(1,outBufLen); if (pAddresses == NULL) { printf ("Memory allocation failed for IP_ADAPTER_ADDRESSES struct\n"); exit(1); } dwRetVal = GetAdaptersAddresses(family, flags, NULL, pAddresses, &outBufLen); if (dwRetVal == ERROR_BUFFER_OVERFLOW) { CipFree(pAddresses); pAddresses = NULL; } else { break; } tries++; } while ( (dwRetVal == ERROR_BUFFER_OVERFLOW) && (tries < MAX_TRIES) ); if (dwRetVal == NO_ERROR) { // If successful, output some information from the data we received pCurrAddresses = pAddresses; while (pCurrAddresses) { if (interface_index == pCurrAddresses->IfIndex) { pDnServer = pCurrAddresses->FirstDnsServerAddress; if (pDnServer) { for (i = 0; pDnServer != NULL; i++) { pDnServer = pDnServer->Next; } } char pStringBuf[INET_ADDRSTRLEN]; if (i != 0) { if (NULL != interface_configuration_.domain_name.string) { /* if the string is already set to a value we have to free the resources * before we can set the new value in order to avoid memory leaks. */ CipFree(interface_configuration_.domain_name.string); } interface_configuration_.domain_name.length = strlen( pCurrAddresses->DnsSuffix); if (interface_configuration_.domain_name.length) { interface_configuration_.domain_name.string = (CipByte *)CipCalloc( interface_configuration_.domain_name.length + 1, sizeof(CipUsint) ); strcpy(interface_configuration_.domain_name.string, pCurrAddresses->DnsSuffix); } else { interface_configuration_.domain_name.string = NULL; } InetNtop(AF_INET, pCurrAddresses->FirstDnsServerAddress->Address.lpSockaddr->sa_data + 2, interface_configuration_.name_server, sizeof(interface_configuration_.name_server) ); InetNtop(AF_INET, pCurrAddresses->FirstDnsServerAddress->Next->Address.lpSockaddr->sa_data + 2, interface_configuration_.name_server_2, sizeof(interface_configuration_.name_server_2) ); } else{ interface_configuration_.domain_name.length = 0;} } pCurrAddresses = pCurrAddresses->Next; } } else { OPENER_TRACE_INFO("Call to GetAdaptersAddresses failed with error: %d\n", dwRetVal); if (dwRetVal == ERROR_NO_DATA) { OPENER_TRACE_INFO( "\tNo addresses were found for the requested parameters\n"); } else { if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwRetVal, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPTSTR)&lpMsgBuf, 0, NULL) ) { OPENER_TRACE_INFO("\tError: %s", lpMsgBuf); CipFree(lpMsgBuf); if (pAddresses) { CipFree(pAddresses); } exit(1); } } } if (pAddresses) { CipFree(pAddresses); } }