Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P62422
MSS from getsockopt
Active
Public
Actions
Authored by
BBlack
on May 15 2024, 6:58 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Tags
None
Referenced Files
F53367472: MSS from getsockopt
May 15 2024, 6:58 PM
2024-05-15 18:58:58 (UTC+0)
Subscribers
None
----- OUTPUT ------
bblack@cp4049:~$ ./mss-check
Checking text@ulsfo: MSS is 1448
Checking upload@ulsfo: MSS is 1428
------ UGLY QUICK HACK C SOURCE BELOW ----
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <string.h>
#include <unistd.h>
void check_mss(struct sockaddr_in* server) {
const int sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (connect(sock, (struct sockaddr*)server, sizeof(*server))) {
perror("connect() failed");
abort();
}
int maxseg = 0;
socklen_t optlen = sizeof(maxseg);
if (getsockopt(sock, SOL_TCP, TCP_MAXSEG, &maxseg, &optlen)) {
perror("getsockopt() failed");
abort();
}
printf("MSS is %i\n", maxseg);
}
int main(int argc, char* argv[]) {
struct sockaddr_in server_text = { 0 };
server_text.sin_family = AF_INET;
server_text.sin_addr.s_addr = htonl(0xC6231A60);
server_text.sin_port = htons(443);
printf("Checking text@ulsfo: ");
check_mss(&server_text);
struct sockaddr_in server_upload = { 0 };
server_upload.sin_family = AF_INET;
server_upload.sin_addr.s_addr = htonl(0xC6231A70);
server_upload.sin_port = htons(443);
printf("Checking upload@ulsfo: ");
check_mss(&server_upload);
return 0;
}
Event Timeline
BBlack
created this paste.
May 15 2024, 6:58 PM
2024-05-15 18:58:58 (UTC+0)
Log In to Comment