From 94e316b6fe50131df66905061b931062e827200d Mon Sep 17 00:00:00 2001 From: pancake Date: Wed, 6 Apr 2011 09:29:25 +0200 Subject: [PATCH] * Do not build r_db * Group bfd getl{16,32} helpers - fix build of sh-dis plugin * Fix lot of warnings * Port rap to use RSocket --- binr/binr.mk | 3 +- binr/radare2/Makefile | 4 +-- libr/Makefile | 2 +- libr/anal/p/anal_sh.c | 4 +++ libr/anal/p/anal_x86_simple.c | 1 + libr/asm/arch/include/mybfd.h | 41 ++++++++++++++++++++-- libr/asm/arch/mips/gnu/mips-dis.c | 46 ------------------------ libr/asm/arch/sh/gnu/sh-dis.c | 8 +++-- libr/asm/arch/sparc/gnu/sparc-dis.c | 27 --------------- libr/cons/cons.c | 4 +-- libr/include/r_socket.h | 3 +- libr/io/p/io_rap.c | 48 +++++++++++++++----------- libr/parse/p/parse_mreplace/mreplace.c | 27 +++++++-------- libr/socket/socket.c | 7 ++++ 14 files changed, 105 insertions(+), 120 deletions(-) diff --git a/binr/binr.mk b/binr/binr.mk index b0b15f1fbe..a9b03d9096 100644 --- a/binr/binr.mk +++ b/binr/binr.mk @@ -5,8 +5,9 @@ include ../../libr/config.mk CFLAGS+=-I../../libr/include CFLAGS+=-DLIBDIR=\"${PREFIX}/lib\" -#LIBS=$(subst r_,-lr_,$(DEPS)) +LIBS=$(subst r_,-lr_,$(BINDEPS)) LIBS+=$(subst r_,-L../../libr/,$(BINDEPS)) +LDFLAGS=${LIBS} all: ${BIN}${EXT_EXE} diff --git a/binr/radare2/Makefile b/binr/radare2/Makefile index 5cbc0a8f16..08ffdad842 100644 --- a/binr/radare2/Makefile +++ b/binr/radare2/Makefile @@ -1,6 +1,6 @@ BIN=radare2 BINDEPS=r_core r_parse r_search r_cons r_lib r_config r_diff -BINDEPS+=r_bin r_debug r_anal r_reg r_bp r_io r_cmd r_th r_fs +BINDEPS+=r_bin r_debug r_anal r_reg r_bp r_io r_cmd r_fs BINDEPS+=r_sign r_print r_lang r_asm r_syscall r_hash r_line r_socket r_flags r_util include ../binr.mk @@ -15,7 +15,7 @@ osxsign: sudo chmod g+s radare2 ifeq ($(WITHNONPIC),1) -LDFLAGS+=${DL_LIBS} -lm -lpthread +LDFLAGS+=${DL_LIBS} -lm ifeq ($(HAVE_LIB_GMP),1) LDFLAGS+=-lgmp endif diff --git a/libr/Makefile b/libr/Makefile index 85a082f7ca..8fc9cd8930 100644 --- a/libr/Makefile +++ b/libr/Makefile @@ -8,7 +8,7 @@ PWD=`pwd` # Libraries LIBLIST=util socket cons line lib io lang flags bin hash config syscall cmd -LIBLIST+=reg asm diff anal print parse search bp sign db debug fs core +LIBLIST+=reg asm diff anal print parse search bp sign debug fs core #DEPRECATED APIS : LIBLIST+=th crypto # sysproxy ... common wat du? diff --git a/libr/anal/p/anal_sh.c b/libr/anal/p/anal_sh.c index 6fa9af9043..1cbbc2a191 100644 --- a/libr/anal/p/anal_sh.c +++ b/libr/anal/p/anal_sh.c @@ -84,6 +84,7 @@ static ut64 disarm_12bit_offset (RAnalOp *op, unsigned int insoff) { return (op->addr<<1) + off + 4; } +#if unused static ut64 disarm_8bit_offset (unsigned int pc, unsigned int insoff) { ut64 add = insoff; /* sign extend if higher bit is 1 (0x08) */ @@ -91,6 +92,7 @@ static ut64 disarm_8bit_offset (unsigned int pc, unsigned int insoff) { add |= 0x00; return (add<<1) + pc + 4; //2*sign_extend(displacement) + 4 } +#endif static char *regs[]={"r0","r1","r2","r3","r4","r5","r6","r7","r8","r9","r10","r11","r12","r13","r14","r15","pc"}; static RAnalValue *anal_fill_ai_rg(RAnal *anal, int idx) { @@ -127,12 +129,14 @@ static RAnalValue *anal_fill_r0_reg_ref(RAnal *anal, int reg,st64 size){ return ret; } +#if unused static st32 sign_extend_12b(st32 v){ if( v & 0x800 ){ v |= 0xFFFFF000; } return v; } +#endif static RAnalValue *anal_pcrel_disp_mov(RAnal* anal,RAnalOp* op,st8 disp){ RAnalValue *ret = r_anal_value_new (); diff --git a/libr/anal/p/anal_x86_simple.c b/libr/anal/p/anal_x86_simple.c index ea8c6bd742..d59f247438 100644 --- a/libr/anal/p/anal_x86_simple.c +++ b/libr/anal/p/anal_x86_simple.c @@ -137,6 +137,7 @@ static int myop(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len) { break; case 0x85: op->type = R_ANAL_OP_TYPE_CMP; + // TODO: use bit test here? if (buf[1]>=0xc0 && buf[1]<=0xff) { // test eax, eax int src = buf[1]&7; int dst = (buf[1]&0x38)>>3; diff --git a/libr/asm/arch/include/mybfd.h b/libr/asm/arch/include/mybfd.h index 896a1d8985..9d77436c82 100644 --- a/libr/asm/arch/include/mybfd.h +++ b/libr/asm/arch/include/mybfd.h @@ -550,12 +550,14 @@ bfd_uint64_t bfd_getb64 (const void *); bfd_uint64_t bfd_getl64 (const void *); bfd_int64_t bfd_getb_signed_64 (const void *); bfd_int64_t bfd_getl_signed_64 (const void *); -bfd_vma bfd_getb32 (const void *); -bfd_vma bfd_getl32 (const void *); bfd_signed_vma bfd_getb_signed_32 (const void *); bfd_signed_vma bfd_getl_signed_32 (const void *); +#if 0 bfd_vma bfd_getb16 (const void *); bfd_vma bfd_getl16 (const void *); +bfd_vma bfd_getb32 (const void *); +bfd_vma bfd_getl32 (const void *); +#endif bfd_signed_vma bfd_getb_signed_16 (const void *); bfd_signed_vma bfd_getl_signed_16 (const void *); void bfd_putb64 (bfd_uint64_t, void *); @@ -5151,4 +5153,39 @@ bfd_byte *bfd_simple_get_relocated_section_contents #ifdef __cplusplus } #endif +/** -- **/ + + +static inline bfd_vma bfd_getl16 (const void *p) { + const bfd_byte *addr = p; + return (addr[1] << 8) | addr[0]; +} + +static inline bfd_vma bfd_getb16 (const void *p) { + const bfd_byte *addr = p; + return (addr[0] << 8) | addr[1]; +} + + +static inline bfd_vma bfd_getb32 (const void *p) { + const bfd_byte *addr = p; + unsigned long v; + + v = (unsigned long) addr[0] << 24; + v |= (unsigned long) addr[1] << 16; + v |= (unsigned long) addr[2] << 8; + v |= (unsigned long) addr[3]; + return v; +} + +static inline bfd_vma bfd_getl32 (const void *p) { + const bfd_byte *addr = p; + unsigned long v; + + v = (unsigned long) addr[0]; + v |= (unsigned long) addr[1] << 8; + v |= (unsigned long) addr[2] << 16; + v |= (unsigned long) addr[3] << 24; + return v; +} #endif diff --git a/libr/asm/arch/mips/gnu/mips-dis.c b/libr/asm/arch/mips/gnu/mips-dis.c index 614812b92a..1327ccaa79 100644 --- a/libr/asm/arch/mips/gnu/mips-dis.c +++ b/libr/asm/arch/mips/gnu/mips-dis.c @@ -31,52 +31,6 @@ #include "elf/mips.h" #include "opintl.h" -/** -- **/ - - -bfd_vma -bfd_getl16 (const void *p) -{ - const bfd_byte *addr = p; - return (addr[1] << 8) | addr[0]; -} - -bfd_vma -bfd_getb16 (const void *p) -{ - const bfd_byte *addr = p; - return (addr[0] << 8) | addr[1]; -} - - -bfd_vma -bfd_getb32 (const void *p) -{ - const bfd_byte *addr = p; - unsigned long v; - - v = (unsigned long) addr[0] << 24; - v |= (unsigned long) addr[1] << 16; - v |= (unsigned long) addr[2] << 8; - v |= (unsigned long) addr[3]; - return v; -} - -bfd_vma -bfd_getl32 (const void *p) -{ - const bfd_byte *addr = p; - unsigned long v; - - v = (unsigned long) addr[0]; - v |= (unsigned long) addr[1] << 8; - v |= (unsigned long) addr[2] << 16; - v |= (unsigned long) addr[3] << 24; - return v; -} - -/** -- **/ - /* FIXME: These are needed to figure out if the code is mips16 or not. The low bit of the address is often a good indicator. No symbol table is available when this code runs out in an embedded diff --git a/libr/asm/arch/sh/gnu/sh-dis.c b/libr/asm/arch/sh/gnu/sh-dis.c index 2ebfdb6d36..b8752b64af 100644 --- a/libr/asm/arch/sh/gnu/sh-dis.c +++ b/libr/asm/arch/sh/gnu/sh-dis.c @@ -16,11 +16,13 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include +#include #define STATIC_TABLE #define DEFINE_TABLE #include "sh-opc.h" #include "dis-asm.h" +#include "mybfd.h" #define LITTLE_BIT 2 @@ -142,7 +144,8 @@ print_insn_shx (memaddr, info) rb = nibs[n] & 0x07; break; default: - abort(); + fprintf(stderr, "sh-dis: abort"); + return 0; } } @@ -294,7 +297,8 @@ print_insn_shx (memaddr, info) fprintf_fn (stream, "xmtrx"); break; default: - abort(); + fprintf(stderr, "sh-dis: abort"); + return 0; } } diff --git a/libr/asm/arch/sparc/gnu/sparc-dis.c b/libr/asm/arch/sparc/gnu/sparc-dis.c index 1e64d80410..32ef138ea0 100644 --- a/libr/asm/arch/sparc/gnu/sparc-dis.c +++ b/libr/asm/arch/sparc/gnu/sparc-dis.c @@ -31,33 +31,6 @@ #define xmalloc malloc -/* BOH */ -bfd_vma -bfd_getb32 (const void *p) -{ - const bfd_byte *addr = p; - unsigned long v; - - v = (unsigned long) addr[0] << 24; - v |= (unsigned long) addr[1] << 16; - v |= (unsigned long) addr[2] << 8; - v |= (unsigned long) addr[3]; - return v; -} - -bfd_vma -bfd_getl32 (const void *p) -{ - const bfd_byte *addr = p; - unsigned long v; - - v = (unsigned long) addr[0]; - v |= (unsigned long) addr[1] << 8; - v |= (unsigned long) addr[2] << 16; - v |= (unsigned long) addr[3] << 24; - return v; -} - /* Bitmask of v9 architectures. */ #define MASK_V9 ((1 << SPARC_OPCODE_ARCH_V9) \ | (1 << SPARC_OPCODE_ARCH_V9A) \ diff --git a/libr/cons/cons.c b/libr/cons/cons.c index 0cd675b7a8..5ac9c71e79 100644 --- a/libr/cons/cons.c +++ b/libr/cons/cons.c @@ -20,7 +20,7 @@ static void break_signal(int sig) { I.event_interrupt (I.data); } -static inline void r_cons_write (char *buf, int len) { +static inline void r_cons_write (const char *buf, int len) { #if __WINDOWS__ r_cons_w32_print ((unsigned char *)buf); #else @@ -238,7 +238,7 @@ R_API void r_cons_visual_flush() { R_API void r_cons_visual_write (char *buffer) { int cols = I.columns; int alen, lines = I.rows-1; - char *endptr; + const char *endptr; char *nl, *ptr = buffer; while (lines && (nl = strchr (ptr, '\n'))) { int clen, len = ((int)(size_t)(nl-ptr))+1; diff --git a/libr/include/r_socket.h b/libr/include/r_socket.h index 9749456fb9..5df3c59823 100644 --- a/libr/include/r_socket.h +++ b/libr/include/r_socket.h @@ -19,6 +19,7 @@ typedef struct r_socket_t { } RSocket; #ifdef R_API +R_API RSocket *r_socket_new_from_fd (int fd); R_API RSocket *r_socket_new (const char *host, const char *port, int is_ssl); R_API void r_socket_free (RSocket *s); #if __UNIX__ @@ -37,7 +38,7 @@ R_API RSocket *r_socket_udp_connect (const char *host, const char *port, int is_ R_API int r_socket_write (RSocket *s, void *buf, int len); R_API int r_socket_puts (RSocket *s, char *buf); R_API void r_socket_printf (RSocket *s, const char *fmt, ...); -R_API int r_socket_read (RSocket *s, unsigned char *read, int len); +R_API int r_socket_read (RSocket *s, ut8 *read, int len); R_API int r_socket_read_block (RSocket *s, unsigned char *buf, int len); R_API int r_socket_gets (RSocket *s, char *buf, int size); diff --git a/libr/io/p/io_rap.c b/libr/io/p/io_rap.c index 63ae281169..34700ef4a3 100644 --- a/libr/io/p/io_rap.c +++ b/libr/io/p/io_rap.c @@ -11,15 +11,16 @@ // go fruit yourself #define ENDIAN (0) typedef struct { - int fd; - int client; + RSocket *fd; + RSocket *client; int listener; } RIORap; -#define RIORAP_FD(x) ((x->data)?(((RIORap*)(x->data))->client):-1) +#define RIORAP_FD(x) ((x->data)?(((RIORap*)(x->data))->client):NULL) #define RIORAP_IS_LISTEN(x) (((RIORap*)(x->data))->listener) #define RIORAP_IS_VALID(x) ((x) && (x->data) && (x->plugin == &r_io_plugin_rap)) static int rap__write(struct r_io_t *io, RIODesc *fd, const ut8 *buf, int count) { + RSocket *s = RIORAP_FD (fd); int ret; ut8 *tmp; if (count>RMT_MAX) @@ -32,9 +33,8 @@ static int rap__write(struct r_io_t *io, RIODesc *fd, const ut8 *buf, int count) r_mem_copyendian ((ut8 *)tmp+1, (ut8*)&count, 4, ENDIAN); memcpy (tmp+5, buf, count); - ret = r_socket_write (RIORAP_FD (fd), tmp, count+5); - // TODO: use r_socket_read here ?? - if (read (RIORAP_FD (fd), tmp, 5) != 5) { // TODO use while'd read here + ret = r_socket_write (s, tmp, count+5); + if (r_socket_read (s, tmp, 5) != 5) { // TODO read_block? eprintf ("rap__write: error\n"); ret = -1; } @@ -43,16 +43,17 @@ static int rap__write(struct r_io_t *io, RIODesc *fd, const ut8 *buf, int count) return ret; } -static int rap__accept(RIO *io, RIODesc *desc, int fd) { +static boolt rap__accept(RIO *io, RIODesc *desc, int fd) { RIORap *rap = desc->data; if (rap) { - rap->client = fd; + rap->client = r_socket_new_from_fd (fd); return R_TRUE; } return R_FALSE; } static int rap__read(struct r_io_t *io, RIODesc *fd, ut8 *buf, int count) { + RSocket *s = RIORAP_FD (fd); int ret; int i = (int)count; ut8 tmp[5]; @@ -62,10 +63,10 @@ static int rap__read(struct r_io_t *io, RIODesc *fd, ut8 *buf, int count) { // send tmp[0] = RMT_READ; r_mem_copyendian (tmp+1, (ut8*)&count, 4, ENDIAN); - r_socket_write (RIORAP_FD (fd), tmp, 5); + r_socket_write (s, tmp, 5); // recv - ret = r_socket_read (RIORAP_FD (fd), tmp, 5); + ret = r_socket_read (s, tmp, 5); if (ret != 5 || tmp[0] != (RMT_READ|RMT_REPLY)) { eprintf ("rap__read: Unexpected rap read reply (%d=0x%02x) expected (%d=0x%02x)\n", ret, tmp[0], 2, (RMT_READ|RMT_REPLY)); @@ -76,7 +77,7 @@ static int rap__read(struct r_io_t *io, RIODesc *fd, ut8 *buf, int count) { eprintf ("rap__read: Unexpected data size %d\n", i); return -1; } - r_socket_read_block (RIORAP_FD (fd), buf, i); + r_socket_read_block (s, buf, i); if (count>0 && countdata; fd->state = R_IO_DESC_TYPE_CLOSED; ret = r_socket_close (r->fd); + ret = r_socket_close (r->client); + //ret = r_socket_close (r->client); free (fd->data); fd->data = NULL; } @@ -98,15 +101,16 @@ static int rap__close(RIODesc *fd) { } static ut64 rap__lseek(struct r_io_t *io, RIODesc *fd, ut64 offset, int whence) { + RSocket *s = RIORAP_FD (fd); int ret; ut8 tmp[10]; // query tmp[0] = RMT_SEEK; tmp[1] = (ut8)whence; r_mem_copyendian (tmp+2, (ut8*)&offset, 8, ENDIAN); - write (RIORAP_FD (fd), &tmp, 10); + r_socket_write (s, &tmp, 10); // get reply - ret = r_socket_read_block (RIORAP_FD (fd), (ut8*)&tmp, 9); + ret = r_socket_read_block (s, (ut8*)&tmp, 9); if (ret!=9) return -1; if (tmp[0] != (RMT_SEEK | RMT_REPLY)) { @@ -122,11 +126,12 @@ static int rap__plugin_open(struct r_io_t *io, const char *pathname) { } static RIODesc *rap__open(struct r_io_t *io, const char *pathname, int rw, int mode) { + RSocket *rap_fd; RIORap *rior; const char *ptr; char *file, *port; char buf[1024]; - int i, p, listenmode, rap_fd; + int i, p, listenmode; if (!rap__plugin_open (io, pathname)) return NULL; @@ -154,7 +159,7 @@ static RIODesc *rap__open(struct r_io_t *io, const char *pathname, int rw, int m rior->client = rior->fd = r_socket_listen (port, R_FALSE, NULL); // TODO: listen mode is broken.. here must go the root loop!! #warning TODO: implement rap:/:9999 listen mode - return r_io_desc_new (&r_io_plugin_rap, rior->fd, pathname, rw, mode, rior); + return r_io_desc_new (&r_io_plugin_rap, rior->fd->fd, pathname, rw, mode, rior); } if ((rap_fd = r_socket_new (ptr, port, R_FALSE))==-1) { eprintf ("Cannot connect to '%s' (%d)\n", ptr, p); @@ -173,7 +178,7 @@ static RIODesc *rap__open(struct r_io_t *io, const char *pathname, int rw, int m r_socket_write (rap_fd, buf, 3+buf[2]); // read eprintf ("waiting... "); - read (rap_fd, (ut8*)buf, 5); + r_socket_read (rap_fd, (ut8*)buf, 5); if (buf[0] != (char)(RMT_OPEN|RMT_REPLY)) { free (rior); return NULL; @@ -181,7 +186,7 @@ static RIODesc *rap__open(struct r_io_t *io, const char *pathname, int rw, int m r_mem_copyendian ((ut8 *)&i, (ut8*)buf+1, 4, ENDIAN); if (i>0) eprintf ("ok\n"); } - return r_io_desc_new (&r_io_plugin_rap, rior->fd, pathname, rw, mode, rior); + return r_io_desc_new (&r_io_plugin_rap, rior->fd->fd, pathname, rw, mode, rior); } static int rap__listener(RIODesc *fd) { @@ -191,6 +196,7 @@ static int rap__listener(RIODesc *fd) { } static int rap__system(RIO *io, RIODesc *fd, const char *command) { + RSocket *s = RIORAP_FD (fd); ut8 buf[1024]; char *ptr; int ret, i, j; @@ -200,10 +206,10 @@ static int rap__system(RIO *io, RIODesc *fd, const char *command) { i = strlen (command); r_mem_copyendian (buf+1, (ut8*)&i, 4, ENDIAN); memcpy (buf+5, command, i); - r_socket_write (RIORAP_FD (fd), buf, i+5); + r_socket_write (s, buf, i+5); // read - ret = r_socket_read_block (RIORAP_FD (fd), buf, 5); + ret = r_socket_read_block (s, buf, 5); if (ret != 5) return -1; if (buf[0] != (RMT_SYSTEM | RMT_REPLY)) { @@ -217,7 +223,7 @@ static int rap__system(RIO *io, RIODesc *fd, const char *command) { i = RMT_MAX; ptr = (char *)malloc (i); if (ptr) { - r_socket_read_block (RIORAP_FD (fd), (ut8*)ptr, i); + r_socket_read_block (s, (ut8*)ptr, i); j = write (1, ptr, i); free (ptr); } diff --git a/libr/parse/p/parse_mreplace/mreplace.c b/libr/parse/p/parse_mreplace/mreplace.c index 01ad290ed0..839d62dc98 100644 --- a/libr/parse/p/parse_mreplace/mreplace.c +++ b/libr/parse/p/parse_mreplace/mreplace.c @@ -27,17 +27,13 @@ #define CHECKS_CHUNCK_SIZE 1024 #define CHECKS_CHUNCK_COUNT 6 -int matchs(const char *string, char *pattern) -{ - int status; - regex_t re; - - if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB) != 0) return(0); - status = regexec(&re, string, (size_t) 0, NULL, 0); - regfree(&re); - if (status != 0) return(0); - - return(1); +int matchs(const char *string, char *pattern) { + int status; + regex_t re; + if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB) != 0) return(0); + status = regexec(&re, string, (size_t) 0, NULL, 0); + regfree(&re); + return status?0:1; } void sreplace(char *s,char *orig,char *rep,char multi,long dsize){ @@ -62,8 +58,7 @@ void sreplace(char *s,char *orig,char *rep,char multi,long dsize){ memFree(buffer); } -char *mreplace(char *string, char *se,char *rep) -{ +char *mreplace(char *string, char *se,char *rep) { int status,i; char noMatch=0; regex_t re; @@ -106,7 +101,8 @@ char *mreplace(char *string, char *se,char *rep) ffound = memReserve(INPUTLINE_BUFFER_REPLACE_SIZE); while(!status){ offset=strlen(temp->address)-strlen(string); - snprintf(found->address,INPUTLINE_BUFFER_REPLACE_SIZE,"%.*s",pm[0].rm_eo - pm[0].rm_so, &string[pm[0].rm_so]);//,&string[pm[0].rm_so]); + snprintf(found->address, INPUTLINE_BUFFER_REPLACE_SIZE, "%.*s", + (int)(size_t)(pm[0].rm_eo - pm[0].rm_so), &string[pm[0].rm_so]);//,&string[pm[0].rm_so]); #if MDEBUG3 printf("------->> found \"%s\" length => %d offset[%d]\n", found->address, @@ -114,7 +110,8 @@ char *mreplace(char *string, char *se,char *rep) #endif sreplace(temp->address+offset,found->address,rep,0,INPUTLINE_BUFFER_REPLACE_SIZE-offset); for(i=1;iaddress,INPUTLINE_BUFFER_REPLACE_SIZE,"%.*s",pm[i].rm_eo - pm[i].rm_so, &string[pm[i].rm_so]);//,&string[pm[i].rm_so]); + snprintf(ffound->address,INPUTLINE_BUFFER_REPLACE_SIZE, "%.*s", + (int)(size_t)(pm[i].rm_eo - pm[i].rm_so), &string[pm[i].rm_so]);//,&string[pm[i].rm_so]); snprintf(field,sizeof(field),"\\%d",i); if(strlen(ffound->address)) { sreplace(temp->address,field,ffound->address,1,INPUTLINE_BUFFER_REPLACE_SIZE); diff --git a/libr/socket/socket.c b/libr/socket/socket.c index ccd7c250b3..a3036599bf 100644 --- a/libr/socket/socket.c +++ b/libr/socket/socket.c @@ -484,3 +484,10 @@ R_API int r_socket_gets(RSocket *s, char *buf, int size) { return i; } + +R_API RSocket *r_socket_new_from_fd (int fd) { + RSocket *s = R_NEW (RSocket); + s->is_ssl = 0; + s->fd = fd; + return s; +}