type
stringclasses
5 values
content
stringlengths
9
163k
functions
int pr_ctrls_copy_args(pr_ctrls_t *src_ctrl, pr_ctrls_t *dst_ctrl) { /* Sanity checks */ if (!src_ctrl || !dst_ctrl) { errno = EINVAL; return -1; }
functions
int pr_ctrls_copy_resps(pr_ctrls_t *src_ctrl, pr_ctrls_t *dst_ctrl) { /* sanity checks */ if (!src_ctrl || !dst_ctrl) { errno = EINVAL; return -1; }
functions
int pr_ctrls_add_response(pr_ctrls_t *ctrl, char *fmt, ...) { char buf[PR_TUNABLE_BUFFER_SIZE] = {'\0'}
functions
int pr_ctrls_flush_response(pr_ctrls_t *ctrl) { /* Sanity check */ if (!ctrl) { errno = EINVAL; return -1; }
functions
int pr_ctrls_parse_msg(pool *msg_pool, char *msg, unsigned int *msgargc, char ***msgargv) { char *tmp = msg, *str = NULL; pool *tmp_pool = NULL; array_header *msgs = NULL; /* Sanity checks */ if (!msg_pool || !msgargc || !msgargv) { errno = EINVAL; return -1; }
functions
int pr_ctrls_recv_request(pr_ctrls_cl_t *cl) { pr_ctrls_t *ctrl = NULL, *next_ctrl = NULL; char reqaction[512] = {'\0'}
functions
int pr_ctrls_recv_response(pool *resp_pool, int ctrls_sockfd, int *status, char ***respargv) { register int i = 0; array_header *resparr = NULL; unsigned int respargc = 0, resparglen = 0; char response[PR_TUNABLE_BUFFER_SIZE] = {'\0'}
functions
int pr_ctrls_send_msg(int sockfd, int msgstatus, unsigned int msgargc, char **msgargv) { register int i = 0; unsigned int msgarglen = 0; /* Sanity checks */ if (sockfd < 0) { errno = EINVAL; return -1; }
functions
int pr_get_registered_actions(pr_ctrls_t *ctrl, int flags) { ctrls_action_t *act = NULL; /* Are ctrls blocked? */ if (ctrls_blocked) { errno = EPERM; return -1; }
functions
int pr_set_registered_actions(module *mod, const char *action, unsigned char skip_disabled, unsigned int flags) { ctrls_action_t *act = NULL; unsigned char have_action = FALSE; /* Is flags a valid combination of settable flags? */ if (flags && flags != PR_CTRLS_ACT_DISABLED) { errno = EINVAL; retur...
functions
int ctrls_connect_local_creds(int sockfd) { char buf[1] = {'\0'}
functions
int pr_ctrls_connect(const char *socket_file) { int sockfd = -1, len = 0; struct sockaddr_un cl_sock, ctrl_sock; /* No interruptions */ pr_signals_block(); /* Create a Unix domain socket */ sockfd = socket(AF_UNIX, SOCK_STREAM, 0); if (sockfd < 0) { int xerrno = errno; pr_signals_unblock(); ...
functions
int pr_ctrls_issock_unix(mode_t sock_mode) { if (ctrls_use_isfifo) { #ifdef S_ISFIFO if (S_ISFIFO(sock_mode)) { return 0; }
functions
int ctrls_get_creds_peercred(int sockfd, uid_t *uid, gid_t *gid, pid_t *pid) { struct ucred cred; socklen_t credlen = sizeof(cred); if (getsockopt(sockfd, SOL_SOCKET, SO_PEERCRED, &cred, &credlen) < 0) { int xerrno = errno; pr_trace_msg(trace_channel, 2, "error obtaining peer credentials using...
functions
int ctrls_get_creds_peereid(int sockfd, uid_t *uid, gid_t *gid) { if (getpeereid(sockfd, uid, gid) < 0) { int xerrno = errno; pr_trace_msg(trace_channel, 7, "error obtaining credentials using " "getpeereid(2) on fd %d: %s", sockfd, strerror(xerrno)); errno = xerrno; return -1; }
functions
int ctrls_get_creds_peerucred(int sockfd, uid_t *uid, gid_t *gid) { ucred_t *cred = NULL; if (getpeerucred(sockfd, &cred) < 0) { int xerrno = errno; pr_trace_msg(trace_channel, 7, "error obtaining credentials using " "getpeerucred(3) on fd %d: %s", sockfd, strerror(xerrno)); errno = xerrno; ...
functions
int ctrls_get_creds_local(int sockfd, uid_t *uid, gid_t *gid, pid_t *pid) { int res; char buf[1]; struct iovec iov; struct msghdr msg; # if defined(SOCKCREDSIZE) # define MINCREDSIZE (sizeof(struct cmsghdr) + SOCKCREDSIZE(0)) # else # if defined(HAVE_STRUCT_CMSGCRED) # define MINCREDSIZE (sizeof(stru...
functions
int ctrls_get_creds_basic(struct sockaddr_un *sock, int cl_fd, unsigned int max_age, uid_t *uid, gid_t *gid, pid_t *pid) { pid_t cl_pid = 0; char *tmp = NULL; time_t stale_time; struct stat st; /* Check the path -- hmmm... */ PRIVS_ROOT while (stat(sock->sun_path, &st) < 0) { int xerrno = errno; ...
functions
int pr_ctrls_accept(int sockfd, uid_t *uid, gid_t *gid, pid_t *pid, unsigned int max_age) { socklen_t len = 0; struct sockaddr_un sock; int cl_fd = -1; int res = -1; len = sizeof(sock); while ((cl_fd = accept(sockfd, (struct sockaddr *) &sock, &len)) < 0) { int xerrno = errno; if (xerrno == E...
functions
void pr_block_ctrls(void) { ctrls_blocked = TRUE; }
functions
void pr_unblock_ctrls(void) { ctrls_blocked = FALSE; }
functions
int pr_check_actions(void) { ctrls_action_t *act = NULL; for (act = ctrls_action_list; act; act = act->next) { if (act->flags & PR_CTRLS_ACT_SOLITARY) { /* This is a territorial action -- only one instance allowed */ if (ctrls_lookup_action(NULL, act->action, FALSE)) { pr_log_pri(PR_LOG_NO...
functions
int pr_run_ctrls(module *mod, const char *action) { pr_ctrls_t *ctrl = NULL; /* Are ctrls blocked? */ if (ctrls_blocked) { errno = EPERM; return -1; }
functions
else if (!action) { pr_trace_msg(trace_channel, 7, "calling '%s' control handler", ctrl->ctrls_action); /* If no action was given, invoke every callback */ pr_unblock_ctrls(); ctrl->ctrls_cb_retval = ctrl->ctrls_cb(ctrl, (ctrl->ctrls_cb_args ? ctrl->ctrls_cb_args->nelts : 0), ...
functions
int pr_reset_ctrls(void) { pr_ctrls_t *ctrl = NULL; /* NOTE: need a clean_ctrls() or somesuch that will, after sending any * responses, iterate through the list and "free" any ctrls whose * ctrls_cb_retval is zero. This feature is used to handle things like * shutdown requests in the future -- the reques...
functions
char pr_ctrls_check_group_acl(gid_t cl_gid, const ctrls_grp_acl_t *grp_acl) { register int i = 0; unsigned char res = FALSE; /* Note: the special condition of ngids of 1 and gids of NULL signals * that all groups are to be treated according to the allow member. */ if (grp_acl->gids) { for (i = 0;...
functions
char pr_ctrls_check_user_acl(uid_t cl_uid, const ctrls_usr_acl_t *usr_acl) { register int i = 0; unsigned char res = FALSE; /* Note: the special condition of nuids of 1 and uids of NULL signals * that all users are to be treated according to the allow member. */ if (usr_acl->uids) { for (i = 0; i...
functions
char pr_ctrls_check_acl(const pr_ctrls_t *ctrl, const ctrls_acttab_t *acttab, const char *action) { register unsigned int i = 0; for (i = 0; acttab[i].act_action; i++) { if (strcmp(acttab[i].act_action, action) == 0) { if (!pr_ctrls_check_user_acl(ctrl->ctrls_cl->cl_uid, &(acttab[i].act_...
functions
void pr_ctrls_init_acl(ctrls_acl_t *acl) { /* Sanity check */ if (!acl) return; memset(acl, 0, sizeof(ctrls_acl_t)); acl->acl_usrs.allow = acl->acl_grps.allow = TRUE; }
functions
void pr_ctrls_set_group_acl(pool *grp_acl_pool, ctrls_grp_acl_t *grp_acl, const char *allow, char *grouplist) { char *group = NULL, **groups = NULL; array_header *gid_list = NULL; gid_t gid = 0; pool *tmp_pool = NULL; if (grp_acl_pool == NULL || grp_acl == NULL || allow == NULL || group...
functions
void pr_ctrls_set_user_acl(pool *usr_acl_pool, ctrls_usr_acl_t *usr_acl, const char *allow, char *userlist) { char *user = NULL, **users = NULL; array_header *uid_list = NULL; uid_t uid = 0; pool *tmp_pool = NULL; /* Sanity checks */ if (usr_acl_pool == NULL || usr_acl == NULL || allow == N...
functions
int pr_ctrls_set_logfd(int fd) { /* Close any existing log fd. */ if (ctrls_logfd >= 0) { (void) close(ctrls_logfd); }
functions
int pr_ctrls_log(const char *module_version, const char *fmt, ...) { va_list msg; int res; /* sanity check */ if (ctrls_logfd < 0) return 0; va_start(msg, fmt); res = pr_log_vwritefile(ctrls_logfd, module_version, fmt, msg); va_end(msg); return res; }
functions
void init_ctrls(void) { struct stat st; int sockfd; struct sockaddr_un sockun; size_t socklen; char *sockpath = PR_RUN_DIR "/test.sock"; if (ctrls_pool) { destroy_pool(ctrls_pool); }
functions
qboolean AI_CanMove(edict_t *self, int direction) { vec3_t forward, right; vec3_t offset,start,end; vec3_t angles; trace_t tr; // Now check to see if move will move us off an edge VectorCopy(self->s.angles,angles); if(direction == BOT_MOVE_LEFT) angles[1] += 90; else if(direction == BOT_MOVE_RIGHT) angles...
functions
qboolean AI_IsStep (edict_t *ent) { vec3_t point; trace_t trace; //determine a point below point[0] = ent->s.origin[0]; point[1] = ent->s.origin[1]; point[2] = ent->s.origin[2] - (1.6*AI_STEPSIZE); //trace to point // trap_Trace (&trace, ent->s.origin, ent->mins, ent->maxs, point, ent, MASK_PLAYERSOLID); ...
functions
qboolean AI_IsLadder(vec3_t origin, vec3_t v_angle, vec3_t mins, vec3_t maxs, edict_t *passent) { vec3_t spot; vec3_t flatforward, zforward; trace_t trace; AngleVectors( v_angle, zforward, NULL, NULL); // check for ladder flatforward[0] = zforward[0]; flatforward[1] = zforward[1]; flatforward[2] = 0; VectorN...
functions
qboolean AI_CheckEyes(edict_t *self, usercmd_t *ucmd) { vec3_t forward, right; vec3_t leftstart, rightstart,focalpoint; vec3_t dir,offset; trace_t traceRight; trace_t traceLeft; // Get current angle and set up "eyes" VectorCopy(self->s.angles,dir); AngleVectors (dir, forward, right, NULL); if(!self->movet...
functions
qboolean AI_SpecialMove(edict_t *self, usercmd_t *ucmd) { vec3_t forward; trace_t tr; vec3_t boxmins, boxmaxs, boxorigin; // Get current direction AngleVectors( tv(0, self->s.angles[YAW], 0), forward, NULL, NULL ); //make sure we are bloqued VectorCopy( self->s.origin, boxorigin ); VectorMA( boxorigin, 8, for...
functions
void AI_ChangeAngle (edict_t *ent) { float ideal_yaw; float ideal_pitch; float current_yaw; float current_pitch; float move; float speed; vec3_t ideal_angle; // Normalize the move angle first VectorNormalize(ent->ai.move_vector); current_yaw = anglemod(ent->s.angles[YAW]); current_pitch = anglemod(ent...
functions
Pitch if (current_pitch != ideal_pitch) { move = ideal_pitch - current_pitch; speed = ent->yaw_speed; if (ideal_pitch > current_pitch) { if (move >= 180) move = move - 360; }
functions
qboolean AI_MoveToGoalEntity(edict_t *self, usercmd_t *ucmd) { if (!self->movetarget || !self->client) return false; // If a rocket or grenade is around deal with it // Simple, but effective (could be rewritten to be more accurate) if(!Q_stricmp(self->movetarget->classname,"rocket") || !Q_stricmp(self->movet...
includes
#include <linux/types.h>
includes
#include <linux/kernel.h>
includes
#include <linux/module.h>
includes
#include <linux/mod_devicetable.h>
includes
#include <linux/device.h>
includes
#include <linux/clk.h>
includes
#include <linux/err.h>
includes
#include <linux/dma-mapping.h>
includes
#include <linux/io.h>
includes
#include <linux/platform_device.h>
includes
#include <linux/spinlock.h>
includes
#include <linux/delay.h>
includes
#include <linux/crypto.h>
includes
#include <crypto/hash.h>
includes
#include <crypto/sha.h>
includes
#include <linux/qcedev.h>
includes
#include <linux/qcota.h>
includes
#include <mach/dma.h>
defines
#define LI_SG_CMD (1 << 31) /* last index in the scatter gather cmd */
defines
#define SRC_INDEX_SG_CMD(index) ((index & 0x3fff) << 16)
defines
#define DST_INDEX_SG_CMD(index) (index & 0x3fff)
defines
#define ADM_DESC_LAST (1 << 31)
defines
#define ADM_CE_BLOCK_SIZE 16
defines
#define QCE_FIFO_SIZE 0x8000
defines
#define ADM_SHA_BLOCK_SIZE 64
defines
#define ADM_DESC_LENGTH_MASK 0xffff
defines
#define ADM_DESC_LENGTH(x) (x & ADM_DESC_LENGTH_MASK)
defines
#define ADM_STATUS_OK 0x80000002
defines
#define QCE_MAX_NUM_DESC 128
structs
struct dmov_desc { uint32_t addr; uint32_t len; };
structs
struct qce_device { struct device *pdev; /* Handle to platform_device structure */ unsigned char *coh_vmem; /* Allocated coherent virtual memory */ dma_addr_t coh_pmem; /* Allocated coherent physical memory */ void __iomem *iobase; /* Virtual io base of CE HW */ unsigned int phy_iobase; /* Ph...
functions
void _aes_expand_key_schedule(uint32_t keysize, uint32_t *AES_KEY, uint32_t *AES_RND_KEY) { uint32_t i; uint32_t Nk; uint32_t Nr, rot_data; uint32_t Rcon = 0x01000000; uint32_t temp; uint32_t data_in; uint32_t MSB_store; uint32_t byte_for_sub; uint32_t word_sub[4]; switch (keysize) { case 192: Nk = 6; ...
functions
else if (Nr == 12) { switch (i) { case 6: Rcon = 0x01000000; break; case 12: Rcon = 0x02000000; break; case 18: Rcon = 0x04000000; break; case 24: Rcon = 0x08000000; break; case 30: Rcon = 0x10000000; break; case 36: Rcon = 0x20000000; break; ...
functions
else if (Nr == 10) { switch (i) { case 4: Rcon = 0x01000000; break; case 8: Rcon = 0x02000000; break; case 12: Rcon = 0x04000000; break; case 16: Rcon = 0x08000000; break; case 20: Rcon = 0x10000000; break; case 24: Rcon = 0x20000000; break; ...
functions
void _byte_stream_to_net_words(uint32_t *iv, unsigned char *b, unsigned int len) { unsigned n; n = len / sizeof(uint32_t) ; for (; n > 0; n--) { *iv = ((*b << 24) & 0xff000000) | (((*(b+1)) << 16) & 0xff0000) | (((*(b+2)) << 8) & 0xff00) | (*(b+3) & 0xff); b += sizeof(uint32_...
functions
else if (n == 2) { *iv = ((*b << 24) & 0xff000000) | (((*(b+1)) << 16) & 0xff0000) ; }
functions
else if (n == 1) { *iv = ((*b << 24) & 0xff000000) ; }
functions
void _net_words_to_byte_stream(uint32_t *iv, unsigned char *b, unsigned int len) { unsigned n = len / sizeof(uint32_t); for (; n > 0; n--) { *b++ = (unsigned char) ((*iv >> 24) & 0xff); *b++ = (unsigned char) ((*iv >> 16) & 0xff); *b++ = (unsigned char) ((*iv >> 8) & 0xff); *b++ = (unsigned char) (...
functions
else if (n == 2) { *b++ = (unsigned char) ((*iv >> 24) & 0xff); *b = (unsigned char) ((*iv >> 16) & 0xff); }
functions
else if (n == 1) { *b = (unsigned char) ((*iv >> 24) & 0xff); }
functions
int count_sg(struct scatterlist *sg, int nbytes) { int i; for (i = 0; nbytes > 0; i++, sg = sg_next(sg)) nbytes -= sg->length; return i; }
functions
int dma_map_pmem_sg(struct buf_info *pmem, unsigned entries, struct scatterlist *sg) { int i = 0; for (i = 0; i < entries; i++) { sg->dma_address = (dma_addr_t)pmem->offset; sg++; pmem++; }
functions
int _probe_ce_engine(struct qce_device *pce_dev) { unsigned int val; unsigned int rev; unsigned int eng_availability; /* engine available functions */ val = readl_relaxed(pce_dev->iobase + CRYPTO_STATUS_REG); if ((val & 0xfffffff) != 0x0200004) { dev_err(pce_dev->pdev, "unknown Qualcomm crypto device at ...
functions
else if (rev == 0x1) { dev_info(pce_dev->pdev, "Qualcomm Crypto 3 device found at 0x%x\n", pce_dev->phy_iobase); }
functions
else if (rev == 0x0) { dev_info(pce_dev->pdev, "Qualcomm Crypto 2 device found at 0x%x\n", pce_dev->phy_iobase); }
functions
int _init_ce_engine(struct qce_device *pce_dev) { unsigned int val; /* reset qce */ writel_relaxed(1 << CRYPTO_SW_RST, pce_dev->iobase + CRYPTO_CONFIG_REG); /* Ensure previous instruction (write to reset bit) * was completed. */ mb(); /* configure ce */ val = (1 << CRYPTO_MASK_DOUT_INTR) | (1 << CRYPTO_MAS...
functions
int _sha_ce_setup(struct qce_device *pce_dev, struct qce_sha_req *sreq) { uint32_t auth32[SHA256_DIGEST_SIZE / sizeof(uint32_t)]; uint32_t diglen; int rc; int i; uint32_t cfg = 0; /* if not the last, the size has to be on the block boundary */ if (sreq->last_blk == 0 && (sreq->size % SHA256_BLOCK_SIZE)) retur...
functions
int _ce_setup(struct qce_device *pce_dev, struct qce_req *q_req, uint32_t totallen, uint32_t coffset) { uint32_t hmackey[HMAC_KEY_SIZE/sizeof(uint32_t)] = { 0, 0, 0, 0, 0}
functions
int _aead_complete(struct qce_device *pce_dev) { struct aead_request *areq; struct crypto_aead *aead; uint32_t ivsize; uint32_t iv_out[4]; unsigned char iv[4 * sizeof(uint32_t)]; uint32_t status; areq = (struct aead_request *) pce_dev->areq; aead = crypto_aead_reqtfm(areq); ivsize = crypto_aead_ivsize(aead); ...
functions
void _sha_complete(struct qce_device *pce_dev) { struct ahash_request *areq; uint32_t auth_data[2]; uint32_t status; areq = (struct ahash_request *) pce_dev->areq; dma_unmap_sg(pce_dev->pdev, areq->src, pce_dev->src_nents, DMA_TO_DEVICE); /* check ce error status */ status = readl_relaxed(pce_dev->iobase ...
functions
int _ablk_cipher_complete(struct qce_device *pce_dev) { struct ablkcipher_request *areq; uint32_t iv_out[4]; unsigned char iv[4 * sizeof(uint32_t)]; uint32_t status; areq = (struct ablkcipher_request *) pce_dev->areq; if (areq->src != areq->dst) { dma_unmap_sg(pce_dev->pdev, areq->dst, pce_dev->dst_nents, ...
functions
int _ablk_cipher_use_pmem_complete(struct qce_device *pce_dev) { struct ablkcipher_request *areq; uint32_t iv_out[4]; unsigned char iv[4 * sizeof(uint32_t)]; uint32_t status; areq = (struct ablkcipher_request *) pce_dev->areq; /* check ce error status */ status = readl_relaxed(pce_dev->iobase + CRYPTO_STATUS_R...
functions
int qce_split_and_insert_dm_desc(struct dmov_desc *pdesc, unsigned int plen, unsigned int paddr, int *index) { while (plen > QCE_FIFO_SIZE) { pdesc->len = QCE_FIFO_SIZE; if (paddr > 0) { pdesc->addr = paddr; paddr += QCE_FIFO_SIZE; }
functions
int _chain_sg_buffer_in(struct qce_device *pce_dev, struct scatterlist *sg, unsigned int nbytes) { unsigned int len; unsigned int dlen; struct dmov_desc *pdesc; pdesc = pce_dev->ce_in_src_desc + pce_dev->ce_in_src_desc_index; /* * Two consective chunks may be handled by the old * buffer descriptor. */ wh...
functions
int _chain_pm_buffer_in(struct qce_device *pce_dev, unsigned int pmem, unsigned int nbytes) { unsigned int dlen; struct dmov_desc *pdesc; pdesc = pce_dev->ce_in_src_desc + pce_dev->ce_in_src_desc_index; dlen = pdesc->len & ADM_DESC_LENGTH_MASK; if (dlen == 0) { pdesc->addr = pmem; pdesc->len = nbytes; }
functions
void _chain_buffer_in_init(struct qce_device *pce_dev) { struct dmov_desc *pdesc; pce_dev->ce_in_src_desc_index = 0; pce_dev->ce_in_dst_desc_index = 0; pdesc = pce_dev->ce_in_src_desc; pdesc->len = 0; }
functions
void _ce_in_final(struct qce_device *pce_dev, int ncmd, unsigned total) { struct dmov_desc *pdesc; dmov_sg *pcmd; pdesc = pce_dev->ce_in_src_desc + pce_dev->ce_in_src_desc_index; pdesc->len |= ADM_DESC_LAST; pdesc = pce_dev->ce_in_dst_desc; if (total > QCE_FIFO_SIZE) { qce_split_and_insert_dm_desc(pdesc, tota...
functions
void _ce_in_dump(struct qce_device *pce_dev) { int i; struct dmov_desc *pdesc; dev_info(pce_dev->pdev, "_ce_in_dump: src\n"); for (i = 0; i <= pce_dev->ce_in_src_desc_index; i++) { pdesc = pce_dev->ce_in_src_desc + i; dev_info(pce_dev->pdev, "%x , %x\n", pdesc->addr, pdesc->len); }