/* * transmit out through the lower layer interface * * infolen - length of the information part of the packet */ void ppp_transmit(GAtPPP *ppp, guint8 *packet, guint infolen) { struct ppp_header *header = (struct ppp_header *) packet; guint16 proto = ppp_proto(packet); guint8 code; gboolean lcp = (proto == LCP_PROTOCOL); guint32 xmit_accm = 0; /* * all LCP Link Configuration, Link Termination, and Code-Reject * packets must be sent with the default sending ACCM */ if (lcp) { code = pppcp_get_code(packet); lcp = code > 0 && code < 8; } if (lcp) { xmit_accm = g_at_hdlc_get_xmit_accm(ppp->hdlc); g_at_hdlc_set_xmit_accm(ppp->hdlc, ~0U); } header->address = PPP_ADDR_FIELD; header->control = PPP_CTRL; if (g_at_hdlc_send(ppp->hdlc, packet, infolen + sizeof(*header)) == FALSE) g_print("Failed to send a frame\n"); if (lcp) g_at_hdlc_set_xmit_accm(ppp->hdlc, xmit_accm); }
static void send_command(GAtHDLC *hdlc, guint8 cmd) { unsigned char cmdbuf[1]; cmdbuf[0] = cmd; g_at_hdlc_send(hdlc, cmdbuf, sizeof(cmdbuf)); }
static void send_subsys_command(GAtHDLC *hdlc, guint8 id, guint16 cmd) { unsigned char cmdbuf[4]; cmdbuf[0] = 0x4b; cmdbuf[1] = id; cmdbuf[2] = cmd & 0xff; cmdbuf[3] = cmd >> 8; g_at_hdlc_send(hdlc, cmdbuf, sizeof(cmdbuf)); }