Home |
Function http_find_string_value Function http_add_get_functions Function http_add_post_functions Function http_set_browser_list Function http_set_put_function |
Function http_set_browser_listDefines the global list of acceptable IP addresses for the Web server. typedef struct browser { BYTE ip_addr[4]; // acceptable server IP addresses BYTE ip_mask[4]; // mask for server IP addresses } browser; int http_set_browser_list(browser * browser_info, int num_elements); Parametersbrowser_infoPointer to an array of browser structures defining acceptable IP addresses. num_elementsNumber of elements in the array pointed to by browser_info. return valueReturns 0 if successful, otherwise SOCKET_ERROR. If an error occurred, call xn_getlasterror and xn_geterror_string to return the error value. In addition to the error values listed below, all errors returned by accept, send, and recv may also be set. Section Error Codes further describes each error. Possible values for this function are:
This function copies the contents of parameter *browser_info into the global browser list. This enables a simple security feature for the Web Server by limiting the browsers which may access the server. If this function is called with IP addresses, only requests from browsers which are in *browser_info will be serviced. A reset will be sent to all browsers not in the table. If this function is never called, the server will accept connections from any browser. Example:// allow web request from 205.161.8.1 and 205.181.8.x browser browser_info[2]; BYTE ip_addr1[4] = {205, 161, 8, 1}; BYTE ip_mask1[4] = {255, 255, 255, 255}; BYTE ip_addr2[4] = {205, 181, 8, 0}; BYTE ip_mask2[4] = {255, 255, 255, 0}; memcpy(browser_info[0].ip_addr, ip_addr1, 4); memcpy(browser_info[0].ip_mask, ip_mask1, 4); memcpy(browser_info[1].ip_addr, ip_addr2, 4); memcpy(browser_info[1].ip_mask, ip_mask2, 4); if (http_set_browser_list(browser_info, 2) == SOCKET_ERROR) printf("http_set_browser_list failed\n");
|