1
0
This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
ZyXEL_PMG5617GA/package/libs/clinkc/patches/058-FEATURE_online_firmware_upgrade.patch
2022-11-27 10:16:14 +00:00

100 lines
3.1 KiB
Diff

Index: clinkc/include/cybergarage/http/chttp.h
===================================================================
--- clinkc.orig/include/cybergarage/http/chttp.h 2015-11-13 10:54:42.990720896 +0800
+++ clinkc/include/cybergarage/http/chttp.h 2015-11-13 10:56:44.927637407 +0800
@@ -778,6 +778,14 @@
void cg_http_vallist_set(CgHttpValList *valList, char *name, char *value);
char *cg_http_vallist_getvalue(CgHttpValList *valList, char *name);
char *cg_http_vallist_dump(CgHttpValList *valList);
+
+#endif
+
+#ifdef ZyXEL_Online_Firmware_Upgrade
+/*******************************************
+* cg_http_customrequest_post
+********************************************/
+CgHttpResponse *cg_http_customrequest_post(CgHttpRequest *httpReq, char *ipaddr, int port, char *savedFile);
#endif
#ifdef __cplusplus
Index: clinkc/src/cybergarage/http/chttp_request.c
===================================================================
--- clinkc.orig/src/cybergarage/http/chttp_request.c 2015-11-13 10:54:42.978720896 +0800
+++ clinkc/src/cybergarage/http/chttp_request.c 2015-11-13 10:57:34.191604515 +0800
@@ -1200,4 +1200,74 @@
free(valStr);
}
}
+
+#endif
+
+
+#ifdef ZyXEL_Online_Firmware_Upgrade
+/*******************************************
+* cg_http_customrequest_post
+********************************************/
+CgHttpResponse *cg_http_customrequest_post(CgHttpRequest *httpReq, char *ipaddr, int port, char *savedFile)
+{
+
+ CgSocket *sock = NULL;
+ char *method, *uri, *version;
+ CgString *firstLine;
+
+ cg_log_debug_l4("Entering...\n");
+
+ cg_http_response_clear(httpReq->httpRes);
+
+ cg_log_debug_s("(HTTP) Posting:\n");
+ cg_http_request_print(httpReq);
+
+
+ sock = cg_socket_stream_new();
+
+
+ if (cg_socket_connect(sock, ipaddr, port, NULL) == FALSE) {
+ cg_socket_delete(sock);
+ return httpReq->httpRes;
+ }
+
+ cg_http_request_sethost(httpReq, ipaddr, port);
+ cg_http_packet_setheadervalue((CgHttpPacket*)httpReq, CG_HTTP_USERAGENT, cg_http_request_getuseragent(httpReq));
+
+ method = cg_http_request_getmethod(httpReq);
+ uri = cg_http_request_geturi(httpReq);
+ version = cg_http_request_getversion(httpReq);
+
+ if (method == NULL || uri == NULL || version == NULL) {
+ cg_socket_close(sock);
+ cg_socket_delete(sock);
+ return httpReq->httpRes;
+ }
+
+ /**** send first line ****/
+ firstLine = cg_string_new();
+ cg_string_addvalue(firstLine, method);
+ cg_string_addvalue(firstLine, CG_HTTP_SP);
+ cg_string_addvalue(firstLine, uri);
+ cg_string_addvalue(firstLine, CG_HTTP_SP);
+ cg_string_addvalue(firstLine, version);
+ cg_string_addvalue(firstLine, CG_HTTP_CRLF);
+ cg_socket_write(sock, cg_string_getvalue(firstLine), cg_string_length(firstLine));
+ cg_string_delete(firstLine);
+ /**** send header and content ****/
+ cg_http_packet_post((CgHttpPacket *)httpReq, sock);
+ /**** read response ****/
+ cg_http_response_read(httpReq->httpRes, sock, cg_http_request_isheadrequest(httpReq), savedFile);
+
+
+ cg_socket_close(sock);
+ cg_socket_delete(sock);
+
+ cg_http_response_print(httpReq->httpRes);
+
+ cg_log_debug_l4("Leaving...\n");
+
+ return httpReq->httpRes;
+
+}
#endif
\ No newline at end of file