mtpd: unify the coding style.
Change-Id: Ie0ebbc2511d61ad0102777aa5db0b134a95de237
diff --git a/l2tp.c b/l2tp.c
index f75fd6c..656d6ea 100644
--- a/l2tp.c
+++ b/l2tp.c
@@ -195,8 +195,8 @@
/* We only handle packets in our tunnel. */
if ((incoming.length != ACK_SIZE && incoming.length < MESSAGE_HEADER_SIZE)
- || (p[0] & htons(MESSAGE_MASK)) != htons(MESSAGE_FLAG)
- || p[1] > htons(incoming.length) || p[2] != local_tunnel) {
+ || (p[0] & htons(MESSAGE_MASK)) != htons(MESSAGE_FLAG) ||
+ ntohs(p[1]) != incoming.length || p[2] != local_tunnel) {
return 0;
}
@@ -362,7 +362,7 @@
.local = {.tunnel = local_tunnel, .session = local_session},
.remote = {.tunnel = remote_tunnel, .session = remote_session},
};
- if (connect(pppox, (struct sockaddr *)&address, sizeof(address)) != 0) {
+ if (connect(pppox, (struct sockaddr *)&address, sizeof(address))) {
log_print(FATAL, "Connect() %s", strerror(errno));
close(pppox);
return -1;
@@ -400,11 +400,11 @@
if (secret) {
uint8_t response[MD5_DIGEST_LENGTH];
if (get_attribute_raw(CHALLENGE_RESPONSE, response, MD5_DIGEST_LENGTH)
- != MD5_DIGEST_LENGTH) {
+ != MD5_DIGEST_LENGTH) {
return 0;
}
return !memcmp(compute_response(SCCRP, challenge, CHALLENGE_SIZE),
- response, MD5_DIGEST_LENGTH);
+ response, MD5_DIGEST_LENGTH);
}
return 1;
}
@@ -436,18 +436,18 @@
switch(incoming.message) {
case SCCRP:
if (state == SCCRQ) {
- if (get_attribute_u16(ASSIGNED_TUNNEL, &tunnel) && tunnel
- && verify_challenge()) {
+ if (get_attribute_u16(ASSIGNED_TUNNEL, &tunnel) && tunnel &&
+ verify_challenge()) {
remote_tunnel = tunnel;
log_print(DEBUG, "Received SCCRP (remote_tunnel = %d) -> "
- "Sending SCCCN", remote_tunnel);
+ "Sending SCCCN", remote_tunnel);
state = SCCCN;
answer_challenge();
set_message(0, SCCCN);
break;
}
log_print(DEBUG, "Received SCCRP without %s", tunnel ?
- "valid challenge response" : "assigned tunnel");
+ "valid challenge response" : "assigned tunnel");
log_print(ERROR, "Protocol error");
return tunnel ? -CHALLENGE_FAILED : -PROTOCOL_ERROR;
}
@@ -458,7 +458,7 @@
if (get_attribute_u16(ASSIGNED_SESSION, &session) && session) {
remote_session = session;
log_print(DEBUG, "Received ICRP (remote_session = %d) -> "
- "Sending ICCN", remote_session);
+ "Sending ICCN", remote_session);
state = ICCN;
set_message(remote_session, ICCN);
add_attribute_u32(CONNECT_SPEED, htonl(100000000));
@@ -480,7 +480,7 @@
case CDN:
if (session && session == local_session) {
log_print(DEBUG, "Received CDN (local_session = %d)",
- local_session);
+ local_session);
log_print(INFO, "Remote server hung up");
return -REMOTE_REQUESTED;
}
@@ -490,13 +490,13 @@
case HELLO:
case WEN:
case SLI:
- /* These are harmless, so we just treat them the same way. */
+ /* These are harmless, so we just treat them in the same way. */
if (state == SCCCN) {
while (!local_session) {
local_session = random();
}
log_print(DEBUG, "Received %s -> Sending ICRQ (local_session = "
- "%d)", messages[incoming.message], local_session);
+ "%d)", messages[incoming.message], local_session);
log_print(INFO, "Tunnel established");
state = ICRQ;
set_message(0, ICRQ);
@@ -526,7 +526,7 @@
* accept ICRQ or OCRQ. Always send CDN with a proper error. */
if (get_attribute_u16(ASSIGNED_SESSION, &session) && session) {
log_print(DEBUG, "Received %s (remote_session = %d) -> "
- "Sending CDN", messages[incoming.message], session);
+ "Sending CDN", messages[incoming.message], session);
set_message(session, CDN);
add_attribute_u32(RESULT_CODE, htonl(0x00020006));
add_attribute_u16(ASSIGNED_SESSION, 0);
diff --git a/pptp.c b/pptp.c
index 6c67afc..ee5d165 100644
--- a/pptp.c
+++ b/pptp.c
@@ -208,7 +208,7 @@
return 1;
}
log_print(DEBUG, "Ignored non-control message (type = %d)",
- ntohs(incoming.header.type));
+ ntohs(incoming.header.type));
}
return 0;
}
@@ -245,7 +245,7 @@
.local = local,
.remote = remote,
};
- if (connect(pppox, (struct sockaddr *)&address, sizeof(address)) != 0) {
+ if (connect(pppox, (struct sockaddr *)&address, sizeof(address))) {
log_print(FATAL, "Connect() %s", strerror(errno));
close(pppox);
return -1;
@@ -284,20 +284,20 @@
}
if (incoming.length < lengths[incoming.message]) {
log_print(DEBUG, "Received %s with invalid length (length = %d)",
- messages[incoming.message], incoming.length);
+ messages[incoming.message], incoming.length);
return 0;
}
switch(incoming.message) {
case SCCRP:
if (state == SCCRQ) {
- if (incoming.sccrp.protocol_version == PROTOCOL_VERSION
- && ESTABLISHED(incoming.sccrp.result)) {
+ if (incoming.sccrp.protocol_version == PROTOCOL_VERSION &&
+ ESTABLISHED(incoming.sccrp.result)) {
while (!local) {
local = random();
}
log_print(DEBUG, "Received SCCRP -> Sending OCRQ "
- "(local = %d)", local);
+ "(local = %d)", local);
log_print(INFO, "Tunnel established");
state = OCRQ;
set_message(OCRQ);
@@ -312,7 +312,7 @@
return 0;
}
log_print(DEBUG, "Received SCCRP (result = %d)",
- incoming.sccrq.result);
+ incoming.sccrq.result);
log_print(INFO, "Remote server hung up");
return -REMOTE_REQUESTED;
}
@@ -329,7 +329,7 @@
return 0;
}
log_print(DEBUG, "Received OCRP (result = %d)",
- incoming.ocrp.result);
+ incoming.ocrp.result);
log_print(INFO, "Remote server hung up");
return -REMOTE_REQUESTED;
}
@@ -375,7 +375,7 @@
case ICRQ:
log_print(DEBUG, "Received ICRQ (remote = %d) -> Sending ICRP "
- "with error", incoming.icrq.call);
+ "with error", incoming.icrq.call);
set_message(ICRP);
outgoing.icrp.peer = incoming.icrq.call;
outgoing.icrp.result = RESULT_ERROR;
@@ -384,7 +384,7 @@
case OCRQ:
log_print(DEBUG, "Received OCRQ (remote = %d) -> Sending OCRP "
- "with error", incoming.ocrq.call);
+ "with error", incoming.ocrq.call);
set_message(OCRP);
outgoing.ocrp.peer = incoming.ocrq.call;
outgoing.ocrp.result = RESULT_ERROR;