Add SM4-FF1, update socket API

This commit is contained in:
Zhi Guan
2026-06-22 22:52:39 +08:00
parent 3a3f632b46
commit 6c2b35b96d
15 changed files with 1058 additions and 44 deletions

View File

@@ -120,7 +120,6 @@ int http_get(const char *uri, uint8_t *buf, size_t *contentlen, size_t buflen)
char host[128];
int port;
char path[256];
struct hostent *hp;
struct sockaddr_in server;
tls_socket_t sock = tls_socket_invalid();
char get[sizeof(HTTP_GET_TEMPLATE) + sizeof(host) + sizeof(path)];
@@ -141,13 +140,10 @@ int http_get(const char *uri, uint8_t *buf, size_t *contentlen, size_t buflen)
}
// connect and send request
if (!(hp = gethostbyname(host))) {
if (tls_socket_get_addr(host, port, &server) != 1) {
error_print();
return -1;
}
server.sin_addr = *((struct in_addr *)hp->h_addr_list[0]);
server.sin_family = AF_INET;
server.sin_port = htons(port);
if (tls_socket_create(&sock, AF_INET, SOCK_STREAM, 0) != 1) {
error_print();
@@ -198,7 +194,6 @@ int http_post(const char *uri, const char *content_type,
char host[128];
int port;
char path[256];
struct hostent *hp;
struct sockaddr_in server;
tls_socket_t sock = tls_socket_invalid();
char post[1024];
@@ -223,13 +218,10 @@ int http_post(const char *uri, const char *content_type,
return -1;
}
if (!(hp = gethostbyname(host))) {
if (tls_socket_get_addr(host, port, &server) != 1) {
error_print();
return -1;
}
server.sin_addr = *((struct in_addr *)hp->h_addr_list[0]);
server.sin_family = AF_INET;
server.sin_port = htons(port);
if (tls_socket_create(&sock, AF_INET, SOCK_STREAM, 0) != 1) {
error_print();