• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/pptpd/pptpd-1.3.4/

Lines Matching defs:packet

4  * PPTP Control Message packet reading, formatting and writing.
39 static ssize_t read_pptp_header(int clientFd, unsigned char *packet, int *ctrl_message_type);
40 static void deal_start_ctrl_conn(unsigned char *packet, unsigned char *rply_packet, ssize_t * rply_size);
41 static void deal_stop_ctrl_conn(unsigned char *packet, unsigned char *rply_packet, ssize_t * rply_size);
42 static void deal_out_call(unsigned char *packet, unsigned char *rply_packet, ssize_t * rply_size);
43 static void deal_echo(unsigned char *packet, unsigned char *rply_packet, ssize_t * rply_size);
44 static void deal_call_clr(unsigned char *packet, unsigned char *rply_packet, ssize_t * rply_size);
45 static void deal_set_link_info(unsigned char *packet);
56 * Sees if a packet can be read and if so what type of packet it is. The
58 * packet and form a suitable reply packet.
61 * packet (OUT) - Packet read from the client.
62 * rply_packet (OUT) - Reply packet for the client.
63 * rply_size (OUT) - Size of the reply packet.
65 * retn: PPTP control message type of the packet on success.
69 int read_pptp_packet(int clientFd, unsigned char *packet, unsigned char *rply_packet, ssize_t * rply_size)
75 /* read a packet and parse header */
76 if ((bytes_read = read_pptp_header(clientFd, packet, &pptp_ctrl_type)) <= 0) {
77 /* error reading packet */
78 syslog(LOG_ERR, "CTRL: couldn't read packet header (%s)", bytes_read ? "retry" : "exit");
82 /* launch appropriate method to form suitable reply to the packet */
85 deal_start_ctrl_conn(packet, rply_packet, rply_size);
89 deal_stop_ctrl_conn(packet, rply_packet, rply_size);
93 deal_out_call(packet, rply_packet, rply_size);
97 deal_echo(packet, rply_packet, rply_size);
101 deal_call_clr(packet, rply_packet, rply_size);
105 /* no reply packet but process it */
106 deal_set_link_info(packet);
112 /* no reply packet */
127 * Sends a PPTP packet to a file descriptor.
129 * args: clientFd (IN) - file descriptor to write the packet to.
130 * packet (IN) - the packet data to write.
131 * packet_size (IN) - the packet size.
136 size_t send_pptp_packet(int clientFd, unsigned char *packet, size_t packet_size)
141 if ((bytes_written = write(clientFd, packet, packet_size)) == -1) {
143 syslog(LOG_ERR, "CTRL: Couldn't write packet to client.");
150 syslog(LOG_DEBUG, "CTRL: Sent packet to client");
190 * Reads a packet from a file descriptor and determines whether it is a
192 * it extracts the Control Message type from the packet header.
195 * packet (OUT) - Packet we read from the client.
196 * pptp_ctrl_type (OUT) - PPTP Control Message type of the packet.
202 ssize_t read_pptp_header(int clientFd, unsigned char *packet, int *pptp_ctrl_type)
206 u_int16_t length; /* length of this packet */
216 memcpy(packet, buffer, buffered);
222 syslog(LOG_DEBUG, "CTRL: Read in previous incomplete ctrl packet");
228 bytes_this = read(clientFd, packet + bytes_ttl, 2 - bytes_ttl);
238 memcpy(buffer, packet, bytes_ttl);
240 syslog(LOG_ERR, "CTRL: Error reading ctrl packet length (bytes_ttl=%d): %s", bytes_ttl, strerror(errno));
245 syslog(LOG_ERR, "CTRL: EOF or bad error reading ctrl packet length.");
255 memcpy(buffer, packet, bytes_ttl);
257 syslog(LOG_DEBUG, "CTRL: Incomplete ctrl packet length, retry later");
265 * trying to hack into us or a badly corrupted packet.
267 * packet to struct pptp_header and use at least the 10 first bytes..
270 length = htons(*(u_int16_t *) packet);
272 syslog(LOG_ERR, "CTRL: 11 < Control packet (length=%d) < "
281 /* Now read the actual control packet */
282 bytes_this = read(clientFd, packet + bytes_ttl, length - bytes_ttl);
292 memcpy(buffer, packet, bytes_ttl);
294 syslog(LOG_ERR, "CTRL: Error reading ctrl packet (bytes_ttl=%d,length=%d): %s", bytes_ttl, length, strerror(errno));
299 syslog(LOG_ERR, "CTRL: EOF or bad error reading ctrl packet.");
309 memcpy(buffer, packet, bytes_ttl);
311 syslog(LOG_DEBUG, "CTRL: Incomplete ctrl packet, retry later");
318 /* Cast the packet into the PPTP Control Message format */
319 header = (struct pptp_header *) packet;
330 /* Woohoo! Looks like we got a valid PPTP packet */
351 syslog(LOG_DEBUG, "CTRL: Made a " what " packet")
360 * args: packet (IN) - the packet that we have to deal with (should be a
361 * START-CONTROL-CONNECTION-REQUEST packet)
362 * rply_packet (OUT) - suitable reply to the 'packet' we got.
363 * rply_size (OUT) - size of the reply packet
365 void deal_start_ctrl_conn(unsigned char *packet, unsigned char *rply_packet, ssize_t * rply_size)
370 start_ctrl_conn_rqst = (struct pptp_start_ctrl_conn_rqst *) packet;
394 void deal_stop_ctrl_conn(unsigned char *packet, unsigned char *rply_packet, ssize_t * rply_size)
413 * args: packet (IN) - the packet that we have to deal with (should be a
414 * OUT-GOING-CALL-REQUEST packet)
415 * rply_packet (OUT) - suitable reply to the 'packet' we got.
416 * rply_size (OUT) - size of the reply packet
419 void deal_out_call(unsigned char *packet, unsigned char *rply_packet, ssize_t * rply_size)
425 out_call_rqst = (struct pptp_out_call_rqst *) packet;
465 * args: packet (IN) - the packet that we have to deal with (should be a
466 * ECHO-REQUEST packet)
467 * rply_packet (OUT) - suitable reply to the 'packet' we got.
468 * rply_size (OUT) - size of the reply packet
471 void deal_echo(unsigned char *packet, unsigned char *rply_packet, ssize_t * rply_size)
476 echo_rqst = (struct pptp_echo_rqst *) packet;
494 * args: packet (IN) - the packet that we have to deal with (should be a
495 * CALL-CLEAR-REQUEST packet)
496 * rply_packet (OUT) - suitable reply to the 'packet' we got.
497 * rply_size (OUT) - size of the reply packet
500 void deal_call_clr(unsigned char *packet, unsigned char *rply_packet, ssize_t *rply_size)
506 * The reply packet is a CALL-DISCONECT-NOTIFY
533 * args: packet (IN) - the packet that we have to deal with (should be a
534 * SET-LINK-INFO packet)
535 * rply_packet (OUT) - suitable reply to the 'packet' we got.
536 * rply_size (OUT) - size of the reply packet
539 void deal_set_link_info(unsigned char *packet)
543 set_link_info = (struct pptp_set_link_info *) packet;
545 syslog(LOG_ERR, "CTRL: Ignored a SET LINK INFO packet with real ACCMs!");
547 syslog(LOG_DEBUG, "CTRL: Got a SET LINK INFO packet with standard ACCMs");
578 * The reply packet is a CALL-DISCONECT-NOTIFY