MCPcopy Create free account
hub / github.com/F-Stack/f-stack / softnic_conn_init

Function softnic_conn_init

dpdk/drivers/net/softnic/conn.c:38–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36};
37
38struct softnic_conn *
39softnic_conn_init(struct softnic_conn_params *p)
40{
41 struct sockaddr_in server_address;
42 struct softnic_conn *conn;
43 int fd_server, fd_client_group, status;
44
45 memset(&server_address, 0, sizeof(server_address));
46
47 /* Check input arguments */
48 if (p == NULL ||
49 p->welcome == NULL ||
50 p->prompt == NULL ||
51 p->addr == NULL ||
52 p->buf_size == 0 ||
53 p->msg_in_len_max == 0 ||
54 p->msg_out_len_max == 0 ||
55 p->msg_handle == NULL)
56 return NULL;
57
58 status = inet_aton(p->addr, &server_address.sin_addr);
59 if (status == 0)
60 return NULL;
61
62 /* Memory allocation */
63 conn = calloc(1, sizeof(struct softnic_conn));
64 if (conn == NULL)
65 return NULL;
66
67 conn->welcome = calloc(1, CONN_WELCOME_LEN_MAX + 1);
68 conn->prompt = calloc(1, CONN_PROMPT_LEN_MAX + 1);
69 conn->buf = calloc(1, p->buf_size);
70 conn->msg_in = calloc(1, p->msg_in_len_max + 1);
71 conn->msg_out = calloc(1, p->msg_out_len_max + 1);
72
73 if (conn->welcome == NULL ||
74 conn->prompt == NULL ||
75 conn->buf == NULL ||
76 conn->msg_in == NULL ||
77 conn->msg_out == NULL) {
78 softnic_conn_free(conn);
79 return NULL;
80 }
81
82 /* Server socket */
83 server_address.sin_family = AF_INET;
84 server_address.sin_port = htons(p->port);
85
86 fd_server = socket(AF_INET,
87 SOCK_STREAM | SOCK_NONBLOCK,
88 0);
89 if (fd_server == -1) {
90 softnic_conn_free(conn);
91 return NULL;
92 }
93
94 status = bind(fd_server,
95 (struct sockaddr *)&server_address,

Callers 1

pmd_initFunction · 0.85

Calls 10

memsetFunction · 0.85
inet_atonFunction · 0.85
callocFunction · 0.85
softnic_conn_freeFunction · 0.85
epoll_createFunction · 0.85
strncpyFunction · 0.85
socketClass · 0.50
bindFunction · 0.50
closeFunction · 0.50
listenFunction · 0.50

Tested by

no test coverage detected