Created
October 10, 2019 04:47
-
-
Save myrual/b2953e387a2c0a821d2725b5757493d6 to your computer and use it in GitHub Desktop.
code to check linux kernel support af_alg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <linux/if_alg.h> | |
#include <errno.h> | |
int main(){ | |
//Alternatively you can set the path to argv[1] | |
int sockfd = socket(AF_ALG, SOCK_SEQPACKET, 0); | |
if(sockfd == -1){ | |
if(errno == EAFNOSUPPORT){ | |
//Unavailable, put whatever you want here | |
printf("#define AF_ALG_UNAVAILABLE\n"); | |
} else { | |
//Unable to detect for some other error | |
} | |
} else { //AF_ALG is available | |
printf("#define AF_ALG_AVAILABLE\n"); | |
} | |
close(sockfd); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment