Lines Matching defs:pcb
298 static err_t smtp_tcp_recv(void *arg, struct altcp_pcb *pcb, struct pbuf *p, err_t err);
300 static err_t smtp_tcp_poll(void *arg, struct altcp_pcb *pcb);
301 static err_t smtp_tcp_sent(void *arg, struct altcp_pcb *pcb, u16_t len);
302 static err_t smtp_tcp_connected(void *arg, struct altcp_pcb *pcb, err_t err);
310 static void smtp_send_body(struct smtp_session *s, struct altcp_pcb *pcb);
311 static void smtp_process(void *arg, struct altcp_pcb *pcb, struct pbuf *p);
313 static void smtp_send_body_data_handler(struct smtp_session *s, struct altcp_pcb *pcb);
459 struct altcp_pcb* pcb;
464 pcb = altcp_tls_new(smtp_server_tls_config, IP_GET_TYPE(remote_ip));
468 pcb = altcp_tcp_new_ip_type(IP_GET_TYPE(remote_ip));
470 if (pcb != NULL) {
471 altcp_arg(pcb, s);
472 altcp_recv(pcb, smtp_tcp_recv);
473 altcp_err(pcb, smtp_tcp_err);
474 altcp_poll(pcb, smtp_tcp_poll, SMTP_POLL_INTERVAL);
475 altcp_sent(pcb, smtp_tcp_sent);
477 return pcb;
487 struct altcp_pcb* pcb = NULL;
544 pcb = smtp_setup_pcb(s, &addr);
545 if (pcb == NULL) {
549 err = altcp_connect(pcb, &addr, smtp_server_port, smtp_tcp_connected);
561 if (pcb != NULL) {
562 altcp_arg(pcb, NULL);
563 altcp_close(pcb);
770 /** Try to close a pcb and free the arg if successful */
772 smtp_close(struct smtp_session *s, struct altcp_pcb *pcb, u8_t result,
775 if (pcb != NULL) {
776 altcp_arg(pcb, NULL);
777 if (altcp_close(pcb) == ERR_OK) {
783 altcp_arg(pcb, s);
792 /** Raw API TCP err callback: pcb is already deallocated */
805 smtp_tcp_poll(void *arg, struct altcp_pcb *pcb)
813 smtp_process(arg, pcb, NULL);
819 smtp_tcp_sent(void *arg, struct altcp_pcb *pcb, u16_t len)
823 smtp_process(arg, pcb, NULL);
830 smtp_tcp_recv(void *arg, struct altcp_pcb *pcb, struct pbuf *p, err_t err)
834 altcp_recved(pcb, p->tot_len);
835 smtp_process(arg, pcb, p);
838 smtp_close((struct smtp_session*)arg, pcb, SMTP_RESULT_ERR_CLOSED, 0, err);
844 smtp_tcp_connected(void *arg, struct altcp_pcb *pcb, err_t err)
853 smtp_close((struct smtp_session*)arg, pcb, SMTP_RESULT_ERR_CONNECT, 0, err);
866 struct altcp_pcb *pcb;
873 pcb = smtp_setup_pcb(s, ipaddr);
874 if (pcb != NULL) {
876 err = altcp_connect(pcb, ipaddr, smtp_server_port, smtp_tcp_connected);
883 LWIP_DEBUGF(SMTP_DEBUG_STATE, ("smtp_dns_found: failed to allocate tcp pcb\n"));
890 pcb = NULL;
894 smtp_close(s, pcb, result, 0, err);
1031 smtp_prepare_helo(struct smtp_session *s, u16_t *tx_buf_len, struct altcp_pcb *pcb)
1034 const char *ipa = ipaddr_ntoa(altcp_get_ip(pcb, 1));
1215 smtp_send_body(struct smtp_session *s, struct altcp_pcb *pcb)
1222 smtp_send_body_data_handler(s, pcb);
1228 u16_t snd_buf = altcp_sndbuf(pcb);
1234 err = altcp_write(pcb, &s->body[s->body_sent], (u16_t)send_len, TCP_WRITE_FLAG_COPY);
1250 err = altcp_write(pcb, SMTP_CMD_BODY_FINISHED, SMTP_CMD_BODY_FINISHED_LEN, 0);
1265 smtp_process(void *arg, struct altcp_pcb *pcb, struct pbuf *p)
1295 smtp_close(s, pcb, SMTP_RESULT_ERR_TIMEOUT, 0, ERR_TIMEOUT);
1299 smtp_send_body(s, pcb);
1327 next_state = smtp_prepare_helo(s, &tx_buf_len, pcb);
1412 smtp_close(s, pcb, SMTP_RESULT_ERR_SVR_RESP, response_code, ERR_OK);
1417 if (altcp_write(pcb, s->tx_buf, tx_buf_len, TCP_WRITE_FLAG_COPY) == ERR_OK) {
1430 smtp_send_body(s, pcb);
1433 altcp_arg(pcb, NULL);
1448 smtp_send_bodyh_data(struct altcp_pcb *pcb, const char **from, u16_t *howmany)
1453 len = (u16_t)LWIP_MIN(len, altcp_sndbuf(pcb));
1454 err = altcp_write(pcb, *from, len, TCP_WRITE_FLAG_COPY);
1511 smtp_send_body_data_handler(struct smtp_session *s, struct altcp_pcb *pcb)
1522 if((res = smtp_send_bodyh_data(pcb, (const char **)&s->body, &s->body_len))
1542 ((res = smtp_send_bodyh_data(pcb, (const char **)&s->body, &s->body_len)) == BDHALLDATASENT)